linux 6 网卡名称修改
转自:http://blog.csdn.net/tianlesoftware/article/details/8737700
一.问题说明
测试环境中出现的小问题,因为虚拟机之间经常复制来复制去,导致网卡配置这块的不一致现象。
配置文件的信息:
[root@ora10g network-scripts]# catifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
TYPE=Ethernet
BOOTPROTO=none
IPADDR=192.168.1.12
PREFIX=24
GATEWAY=192.168.1.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
NAME="System eth0"
UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
HWADDR=08:00:27:BD:A6:ED
[root@ora10g network-scripts]# catifcfg-eth1
DEVICE="eth1"
NM_CONTROLLED="yes"
ONBOOT=yes
TYPE=Ethernet
BOOTPROTO=none
IPADDR=192.168.1.13
PREFIX=24
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth1"
UUID=9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04
HWADDR=08:00:27:6E:86:10
这里对应的是网卡名称是eth0和eth1.
但是如果我们使用ifconfig 命令查看:
[root@ora10g network-scripts]# ifconfig -a
eth2 Link encap:Ethernet HWaddr08:00:27:BD:A6:ED
inet addr:192.168.1.12 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:febd:a6ed/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:187 errors:0 dropped:0 overruns:0 frame:0
TX packets:59 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:16356 (15.9 KiB) TXbytes:6116 (5.9 KiB)
eth3 Link encap:Ethernet HWaddr08:00:27:6E:86:10
inet addr:192.168.1.13 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe6e:8610/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1357 errors:0 dropped:0 overruns:0 frame:0
TX packets:1099 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:120604 (117.7 KiB) TXbytes:115937 (113.2 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:480 (480.0 b) TXbytes:480 (480.0 b)
这里的网卡名称是eth2和eth3.
二.解决方法
修改 /etc/udev/rules.d/70-persistent-net.rules文件中的映射关系就可以了。
--修改之前:
[root@ora10g network-scripts]# cat/etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated bythe /lib/udev/write_net_rules
# program, run by thepersistent-net-generator.rules rules file.
#
# You can modify it, as long as you keepeach rule on a single
# line, and change only the value of theNAME= key.
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net",ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:d4:ab:67",ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net",ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:af:2b:37",ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net",ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:bd:a6:ed",ATTR{dev_id}=="0x0", ATTR{type}=="1",KERNEL=="eth*", NAME="eth2"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net",ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:6e:86:10",ATTR{dev_id}=="0x0", ATTR{type}=="1",KERNEL=="eth*", NAME="eth3"
--修改之后:
[root@ora10g network-scripts]# cat/etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated bythe /lib/udev/write_net_rules
# program, run by thepersistent-net-generator.rules rules file.
#
# You can modify it, as long as you keepeach rule on a single
# line, and change only the value of theNAME= key.
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net",ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:6E:86:10",ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net",ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:BD:A6:ED",ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
注意这里的MAC地址要和ifcfg-eth0 保持一致。
然后重启一下网卡和udev:
--ifdown 网卡:
ifdown eth0
ifdown eth1
--重启udev
/etc/init.d/udev-post stop;
/etc/init.d/udev-post start
或者使用:
service udev-post stop
service udev-post start
注意: 对与Oracle Linux 是udev-post, 而redhat 是udev
--ifup:
Ifup eth0
Ifup eth1
不过在我的测试中,这2个都没有效果,我是把整个OS都重启了,才生效的。 小知识,随笔记之。
linux 6 网卡名称修改的更多相关文章
- linux网卡名称修改
vim /etc/sysconfig/grub ,在倒数第二行添加如下代码 net.ifnames=0 biosdevname=0 GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR=&q ...
- centos 把网卡名称修改为 eth0
默认网卡名称是 eno16777736 1.修改配置文件 ifcfg-eno16777736 [root@localhost ~]# cd /etc/sysconfig/network-scripts ...
- 虚拟机网卡名称修改为 eth0
默认网卡名称是 eno16777736 1.修改配置文件 ifcfg-eno16777736 [root@localhost ~]# cd /etc/sysconfig/network-scripts ...
- centos 6 网卡名称修改
centos6 中网卡的名字有时不是eth0,这时就会带来诸多不便,为此需要修改网卡的名称. 修改网卡名称vim /etc/sysconfig/network-scripts/ifcfg-eno167 ...
- centos 网卡名称修改
在centos6.4之前,如果6.2,6.3安装后网卡名称都是em开始,如果想用eth0这种名称,或者是自定义名称,可以参照以下来实施. 第一步:修改/boot/grub/grub.conf增加一个 ...
- centos7网卡名称修改以及配置
1.vi /etc/sysconfig/network-scripts/ifcfg-enoxxxxxx 为ifcfg-eth0并 将里面的NAME项修改为eth0 2.禁用该可预测命名规则.在启动时传 ...
- ubuntu 修改网卡名称 更改设备网卡名称 修改eno16777736为eth0 ubuntu 15.10网卡名称为eno16777736
ubuntu linux 进入root用户,管理员模式 编辑这个文件需要管理员模式 在GRUB_CMD_LINUX后面增加图中所示 看到这个地方了没,有提示信息的,想要改变这个文件,记得运行 upda ...
- L09-Linux系统修改网卡名称(eth1修改为eth0)
一.环境 VirtualBox + CentOS6.5 二.问题 有时候在克隆服务器之后配置网络时,或者在维护别人建好的服务器时,会遇到这样一种情况.如下图所示: 即:在接口配置文件ifcfg-e ...
- linux修改网卡名称
本文转载自江一<linux修改网卡名称> 终端输入:vi /etc/udev/rules.d/70-persistent-net.rules 出现以下文件 # This file was ...
随机推荐
- Python(名称空间、函数嵌套、函数对象)
一.名称空间: 名称空间 定义:存放名字和值的绑定关系 内置名称空间 python自带的名字,如print.int.str 解释器启动就会生效 全局名称空间 文件级别定义的名字,都会放 ...
- Delphi 正则表达式之TPerlRegEx 类的属性与方法(4): Replace
Delphi 正则表达式之TPerlRegEx 类的属性与方法(4): Replace // Replace var reg: TPerlRegEx; begin reg := TPerlRe ...
- 启动Django服务让其他电脑可访问
1.修改 Django项目中的settings.py中的 ALLOWED_HOSTS 的值为 [*] # 准许那些地址访问,* 表示任意地址 ALLOWED_HOSTS = ['*'] # ALLOW ...
- 一个很牛的计算pi的c程序!
C语言是面向过程的一种高级程序设计语言,它在世界范围内使用很广泛,而且很流行.很多大型的应用软件,基本上是用C语言所编写的.在对操作系统以及系统使用程序.需要对硬件进行操作的场合,C语言较其他的高级语 ...
- 转:asp.net获取url各项参数
假设当前页完整地址是:http://www.test.com/aaa/bbb.aspx?id=5&name=kelli "http://"是协议名 "www.te ...
- Java Web架构总结
转载至:http://www.cnblogs.com/wuxl360/p/7489763.html 初始搭建 开始的开始,就是各种框架一搭,然后扔到Tomcat容器中跑就是了,这时候我们的文件,数据库 ...
- 450. Delete Node in a BST
Given a root node reference of a BST and a key, delete the node with the given key in the BST. Retur ...
- [转]毕设- 深入HBase架构解析(二)
深入HBase架构解析(二) 前言 这是<深入HBase架构解析(一)>的续,不多废话,继续.... HBase读的实现 通过前文的描述,我们知道在HBase写时,相同Cell(RowKe ...
- cache工作原理
转:http://www.360doc.com/content/11/0307/21/3791508_99049437.shtml
- jQuery 3D垂直多级菜单
在线演示 本地下载