LINUX入门:CentOS6 虚拟机迁移后网卡名更改问题解决

介绍《LINUX入门:CentOS6 虚拟机迁移后网卡名更改问题解决》开发教程,希望对您有用。

《LINUX入门:CentOS6 虚拟机迁移后网卡名更改问题解决》要点:
本文介绍了LINUX入门:CentOS6 虚拟机迁移后网卡名更改问题解决,希望对您有用。如果有疑问,可以联系我们。

实验过程中,我们经常必要复制虚拟机,以模仿生产过程中同等配置的条件.

但无论是初次打开,选择”我已复制该虚拟机“也好,还是在虚拟机设置>网络适配器>高级中重新生成Mac地址,开机后选择”我已移动该虚拟机“也罢.开机后查询IP时,我们都会很遗憾的发现,网卡的名字,纷歧样了.

这是因为原Mac地址占用旧网卡,新Mac地址只能使用新的网卡名称.复制虚拟机为了不与原虚拟机冲突,也是天生了新的Mac地址.

[root@CentOS6 ~]# ifconfig
eth2 Link encap:Ethernet HWaddr 00:50:56:22:C9:22
inet addr:192.168.234.187 Bcast:192.168.234.255 Mask:255.255.255.0
inet6 addr: fe80::250:56ff:fe22:c922/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:806 (806.0 b) TX bytes:1152 (1.1 KiB)
eth3 Link encap:Ethernet HWaddr 00:50:56:3A:FD:74
inet addr:172.17.251.174 Bcast:172.17.255.255 Mask:255.255.0.0
inet6 addr: fe80::250:56ff:fe3a:fd74/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2565 errors:0 dropped:0 overruns:0 frame:0
TX packets:61 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:243027 (237.3 KiB) TX bytes:9974 (9.7 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:65536 Metric:1
RX packets:4 errors:0 dropped:0 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:240 (240.0 b) TX bytes:240 (240.0 b)

虽然不影响使用,但怎么看都不舒服啊.而且有些实验中网卡名不统一也只有麻烦.正所谓没有标准化就很难进行自动化管理.
那么,如何变动迁移后的虚拟机的网卡名呢?

(1).改动配置文件/etc/udev/rules.d/70-persistent-net.rules
[root@centos6 ~]# vim /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program,run by the persistent-net-generator.rules rules file.
#
# You can modify it,as long as you keep each rule on a single
# line,and change only the value of the NAME= key.
# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM==”net”,ACTION==”add”,DRIVERS==”?*”,ATTR{address}==”00:0c:29:13:d6:94″,ATTR{type}==”1″,KERNEL==”eth*”,NAME=”eth0″

# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM==”net”,ATTR{address}==”00:0c:29:13:d6:9e”,NAME=”eth1″

# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM==”net”,ATTR{address}==”00:50:56:22:c9:22″,NAME=”eth2″

# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM==”net”,ATTR{address}==”00:50:56:3a:fd:74″,NAME=”eth3″

删除原Mac,变动NAME值,搞定.改好后是这个样子.
[root@centos6 rules.d]# vim /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program,NAME=”eth0″
# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM==”net”,NAME=”eth1″
~

(2).重启或重装网卡驱动,使配置文件生效
查看网卡驱动名:ethtool -i eth2或dmesg|grep -i eth
卸载网卡驱动:modprobe -r e1000 或rmmod e1000
装载网卡驱动:modprobe e1000
[root@centos6 rules.d]# dmesg|grep -i eth
e1000 0000:02:01.0: eth0: (PCI:66MHz:32-bit) 00:50:56:3a:fd:74
e1000 0000:02:01.0: eth0: Intel(R) PRO/1000 Network Connection
e1000 0000:02:02.0: eth1: (PCI:66MHz:32-bit) 00:50:56:22:c9:22
e1000 0000:02:02.0: eth1: Intel(R) PRO/1000 Network Connection
udev: renamed network interface eth1 to eth2
udev: renamed network interface eth0 to eth3
e1000: eth3 NIC Link is Up 1000 Mbps Full Duplex,Flow Control: None
8021q: adding VLAN 0 to HW filter on device eth3
e1000: eth2 NIC Link is Up 1000 Mbps Full Duplex,Flow Control: None
8021q: adding VLAN 0 to HW filter on device eth2
eth2: no IPv6 routers present
eth3: no IPv6 routers present
#阿拉的网卡驱动只有e1000一块,所以阿拉卸载一块就够了.有的网卡名纷歧样,要分别卸载
[root@centos6 rules.d]# rmmod e1000
#再用ifconfig查看会发现原网卡信息不见了.(阿拉这一步就不粘代码了)
#装载网卡驱动
[root@centos6 rules.d]# modprobe e1000
#再次查看,修改成功
[root@centos6 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:50:56:22:C9:22
inet addr:192.168.234.187 Bcast:192.168.234.255 Mask:255.255.255.0
inet6 addr: fe80::250:56ff:fe22:c922/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:746 (746.0 b) TX bytes:1152 (1.1 KiB)

eth1 Link encap:Ethernet HWaddr 00:50:56:3A:FD:74
inet addr:172.17.251.174 Bcast:172.17.255.255 Mask:255.255.0.0
inet6 addr: fe80::250:56ff:fe3a:fd74/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:475 errors:0 dropped:0 overruns:0 frame:0
TX packets:50 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:48665 (47.5 KiB) TX bytes:7289 (7.1 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:65536 Metric:1
RX packets:80 errors:0 dropped:0 overruns:0 frame:0
TX packets:80 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:6148 (6.0 KiB) TX bytes:6148 (6.0 KiB)

本文永远更新链接地址:

《LINUX入门:CentOS6 虚拟机迁移后网卡名更改问题解决》是否对您有启发,欢迎查看更多与《LINUX入门:CentOS6 虚拟机迁移后网卡名更改问题解决》相关教程,学精学透。脚本之家PHP学院为您提供精彩教程。

作者: dawei

【声明】:永州站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

为您推荐

联系我们

联系我们

0577-28828765

在线咨询: QQ交谈

邮箱: xwei067@foxmail.com

工作时间:周一至周五,9:00-17:30,节假日休息

返回顶部