linux找回eth0方法

环境: Centos 6

背景问题:

当自己复制linux虚拟机,或者采用克隆的方式(右键-管理-克隆)的时候,会发现eth0变成了eth1,再复制的时候就变成了eth2;

问题原因:

每个虚拟机的网卡都有唯一的id,在linux中是使用的UUID,为了保证网卡的唯一,每次复制网卡标识都会自动加一

解决方法:

编辑  /etc/udev/rules.d/70-persistent-net.rules

在行尾位置,设置NAME="eth0" 即可,如下所示,我是因为双网卡,这个时候就可以ifconfig查看物理地址,确认下自己要把哪块网卡设置为eth0了;

# 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:97:06:1d", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:97:06:13", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

 

你可能感兴趣的:(Shell)