eth2->eth0

一台Vmware虚拟机更换宿主Server启动以后提示找不到eth0,网卡无法加载。出现这个问题的原因我想是因为更换了宿主Server,原来虚拟出来的网卡Mac地址也跟着改变,也就相当于更换了Vmware虚拟机的网卡。

用 ifconfig -a 命令查看所有的网络设置,果然没有eth0的相关设置,多出来一个eth2。显示如下:
QUOTE:
eth2 Link encap:Ethernet HWaddr 00:0C:29:AF:1C:C7
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:185 Base address:0x1480
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:3054386 errors:0 dropped:0 overruns:0 frame:0
TX packets:3054386 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1067784027 (1018.3 MiB) TX bytes:1067784027 (1018.3 MiB)

由于系统默认的启动网卡是eth0,所以怎么样把eth2更改为eth0成了当务之急。查了很多资料最终终于找到解决方法,方法如下:

修改文件/etc/udev/rules.d/z25_persistent-net.rules 文件,原来为:
QUOTE:
protime-linux:/etc/udev/rules.d# cat z25_persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, probably run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single line.
# MAC addresses must be written in lowercase.
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:0c:29:15:3a:48", NAME="eth0"
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:0c:29:15:3a:52", NAME="eth1"
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:0c:29:af:1c:c7", NAME="eth2"

修改后:
QUOTE:
protime-linux:/etc/udev/rules.d# cat z25_persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, probably run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single line.
# MAC addresses must be written in lowercase.
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:0c:29:15:3a:48", NAME="eth2"
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:0c:29:15:3a:52", NAME="eth1"
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:0c:29:af:1c:c7", NAME="eth0"

保存重启后可以看到原来的网络配置又回来了。

还有一个方法就是把eth2设置为默认启动的网卡,修改/etc/network/interfaces:

修改前:
QUOTE:
protime-linux:/etc/udev/rules.d# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
#allow-hotplug eth0
auto eth0
iface eth0 inet static
address 192.168.0.224
netmask 255.255.255.0
gateway 192.168.0.9
#iface eth0 inet dhcp
auto eth0:0
iface eth0:0 inet static
name Ethernet Lan card
address 192.168.0.223
netmask 255.255.255.0
gateway 192.168.0.9

修改后为:
QUOTE:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
#allow-hotplug eth0
auto eth2
iface eth2 inet static
address 192.168.0.224
netmask 255.255.255.0
gateway 192.168.0.9
#iface eth0 inet dhcp
auto eth2:0
iface eth0:0 inet static
name Ethernet Lan card
address 192.168.0.223
netmask 255.255.255.0
gateway 192.168.0.9

保存后重启server应该也可以启动网卡。(注:此方法没有经过测试,只是本人的理解,有条件的朋友可以测试下)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值