背景
本人虚拟你测试cenots,虚拟机删除了几次网卡,有重新添加,结果网卡名字中的数字就递增了。但是仍然想使用eth0,通过下面的内容可以解决。
环境
[root@test ~]# cat /etc/redhat-release
CentOS release 6.5 (Final)
步骤
备注:网卡的命名规则实际是在/etc/udev/rules.d/
目录下对应的文件中配置的
步骤1
由于不知道是那个文件,所以搜索下cd /etc/udev/rules.d && grep -rni eth ./**
在我的环境中可以搜索到eth全部出现在**`70-persistent-net.rules`**文件中
步骤2
修改/etc/udev/rules.d/70-persistent-net.rules文件内容。根据已有的内容按照葫芦画瓢就知道怎么改了,主要是修改NAME字段。
我修改后的内容如下:
cat 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 0x10ec:0x8139 (8139cp)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="fe:fc:fe:90:4a:13", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
步骤3
此时如果要能IP生效,还要修改配置文件
/etc/sysconfig/network-scprits/
目录下对应的配置文件,将DEVICE
字段的值修改为eth0- 另外,为了方便管理,将配置文件的名字也修改为ifcfg-eth0
步骤4
重启设备
步骤5
查看网卡信息:ifconfig
就可以看到网卡的名称改为了eth0