RHEL7之前的网卡命名方式为eth0,改版后更为enoxxxxxxxx,使用起来很不方便,修改如下配置可将网卡命名方式变更为原来的方式,方法如下:
1. 变更之前网卡命名:
[root@bogon ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:32:5a:3b brd ff:ff:ff:ff:ff:ff
inet 192.168.100.131/24 brd 192.168.100.255 scope global dynamic eno16777736
valid_lft 1687sec preferred_lft 1687sec
inet6 fe80::20c:29ff:fe32:5a3b/64 scope link
valid_lft forever preferred_lft forever
2. 编辑grub配置文件
[root@bogon ~]#
vim /etc/sysconfig/grub
GRUB_TIMEOUT=5
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap net.ifnames=0 biosdevname=0 rhgb quiet" #需要添加
GRUB_DISABLE_RECOVERY="true"
3. 生成启动配置文件
[root@bogon ~]#
grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-229.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-229.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-22adb3ea314741fca53600ae4bc5fd2a
Found initrd image: /boot/initramfs-0-rescue-22adb3ea314741fca53600ae4bc5fd2a.img
done
4. 删除网卡
[root@bogon ~]#
nmcli device delete eno16777736
# eno16777736 为随机值
5. 添加网卡
[root@bogon network-scripts]#
nmcli connection add con-name eth0 ifname eth0 type ethernet
成功添加的连接 'eth0'(2a6e89b7-8fc4-4190-a000-e10cf436b0c7)。
[root@bogon ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:32:5a:3b brd ff:ff:ff:ff:ff:ff
inet 192.168.100.131/24 brd 192.168.100.255 scope global dynamic eth0
valid_lft 1803sec preferred_lft 1803sec
inet6 fe80::20c:29ff:fe32:5a3b/64 scope link
valid_lft forever preferred_lft forever