CentOS 7 默认网卡名如何修改成eth*
1、首先修改网卡的配置文件/etc/sysconfig/network-scripts/enp0s8文件,将 enp0s8里的 DEVICE和NAME项改为eth
[root@localhost ~]# ifconfig -a|grep enp0
enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
[root@localhost network-scripts]# cat ifcfg-enp0s8
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eth1
DEVICE=eth1
ONBOOT=yes
PEERDNS=yes
PEERROUTES=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_PRIVACY=no
2、然后将该配置的文件名改成eth
[root@localhost network-scripts]# mv ifcfg-enp0s8 ifcfg-eth1
3、禁用该可预测命名规则。对于这一点,你可以在启动时传递“net.ifnames=0 biosdevname=0 ”的内核参数。这是通过编辑/etc/default/grub
在变量GRUBCMDLINELINUX后面加入“net.ifnames=0 biosdevname=0 ”来实现的。参数间以空格来间隔
[root@localhost rules.d]# cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=" ( s e d ′ s , r e l e a s e . ∗ (sed 's, release .* (sed′s,release.∗,g’ /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT=“console”
GRUB_CMDLINE_LINUX=“rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet net.ifnames=0 biosdevname=0”
GRUB_DISABLE_RECOVERY=“true”
4、运行命令grub2-mkconfig -o /boot/grub2/grub.cfg 来重新生成GRUB配置并更新内核参数
[root@localhost rules.d]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file …
Found linux image: /boot/vmlinuz-3.10.0-514.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-514.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-39f6145acde440cca472bfc508ed858e
Found initrd image: /boot/initramfs-0-rescue-39f6145acde440cca472bfc508ed858e.img
done
5、编辑修改命名规则的配置文件 vim /etc/udev/rules.d/70-persistent-net.rules 这个文件CentOS7没有,按照CentOS6的规则填写,保存!
[root@localhost ~]# cat /etc/udev/rules.d/70-persistent-net.rules
… …
SUBSYSTEM==“net”, ACTION==“add”, DRIVERS=="?", ATTR{address}“08:00:27:ef:93:5f”, ATTR{type}“1”, KERNEL=="eth", NAME=“eth1”
6、重启机器加载修改项,OK!
[root@localhost ~]# reboot