On CentOS / RHEL 7, a new naming scheme is introduced.
For instance:
# ip addr show ..... eno1: [BROADCAST,MULTICAST,UP,LOWER_UP] mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 6c:0b:84:6c:48:1c brd ff:ff:ff:ff:ff:ff inet 10.10.10.11/24 brd 10.10.10.255 scope global eno1 inet6 2606:b400:c00:48:6e0b:84ff:fe6c:481c/128 scope global dynamic valid_lft 2326384sec preferred_lft 339184sec inet6 fe80::6e0b:84ff:fe6c:481c/64 scope link valid_lft forever preferred_lft forever
This post describes how to revert to legacy naming scheme with Network Interface names as eth0, eth1, etc.
1. Edit kernel boot parameter.
Edit file /etc/default/grub and add net.ifnames=0 biosdevname=0 to line GRUB_CMDLINE_LINUX, for instance:
GRUB_CMDLINE_LINUX=" crashkernel=auto net.ifnames=0 biosdevname=0 rhgb quiet"
Regenerate a GRUB configuration file and overwrite existing one:
# grub2-mkconfig -o /boot/grub2/grub.cfg
2. Correct ifcfg file configuration:
Edit NAME and DEVICE parameters in ifcfg file to new Network Interface name.
# cat /etc/sysconfig/network-scripts/ifcfg-eno1 ...... NAME=eth0 DEVICE=eth0 ......
Edit ifcfg file name:
# mv /etc/sysconfig/network-scripts/ifcfg-eno1 /etc/sysconfig/network-scripts/ifcfg-eth0
3. Disable NetworkManager
# systemctl disable NetworkManager rm '/etc/systemd/system/multi-user.target.wants/NetworkManager.service' rm '/etc/systemd/system/dbus-org.freedesktop.NetworkManager.service' rm '/etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service'
4. Reboot system.
# shutdown -r now
5. Verify.
Verify the change of device name to eth0 in ip addr show.
# ip addr show ..... eth0: [BROADCAST,MULTICAST,UP,LOWER_UP] mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 6c:0b:84:6c:48:1c brd ff:ff:ff:ff:ff:ff inet 10.10.10.11/24 brd 10.10.10.255 scope global eno1 inet6 2606:b400:c00:48:6e0b:84ff:fe6c:481c/128 scope global dynamic valid_lft 2326384sec preferred_lft 339184sec inet6 fe80::6e0b:84ff:fe6c:481c/64 scope link valid_lft forever preferred_lft forever
方法一:
在进入安装界面的时候把光标移动到Install CentOS7,按下tab键,在后面输入“ifnames=0 biosdevname=0”回车即可。
方法二:
进入网卡配置文件目录
[root@centos7 ~]# cd /etc/sysconfig/network-scripts/
重命名网卡
[root@centos7 network-scripts]# mv ifcfg-eno16777736 ifcfg-eth0
修改配置文件NAME、DEVICE
[root@centos7 network-scripts]# vim ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=static
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
NAME=eth0
UUID=552c01f7-fd9d-4f19-913e-379a2bf5a467
DEVICE=eth0
ONBOOT=yes
IPADDR=10.0.0.111
"ifcfg-eth0" 14L, 239C written
修改grub
sed -i.bak 's#crashkernel=auto rhgb quiet#crashkernel=auto rhgb net.ifnames=0 biosdevname=0 quiet#g' /etc/sysconfig/grub
[root@centos7 network-scripts]# vim /etc/sysconfig/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb net.ifnames=0 biosdevname=0 quiet"
"/etc/sysconfig/grub" 7L, 263C written
生成启动菜单
[root@centos7 network-scripts]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-7ed5d4eebe4c43e3aadbda68cd0ef311
Found initrd image: /boot/initramfs-0-rescue-7ed5d4eebe4c43e3aadbda68cd0ef311.img
done
重启系统生效
[root@centos7 network-scripts]# reboot
查看是否成功
centos7默认没有ifconfig命令,需yum install net-tools -y安装
[root@centos7 ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.0.111 netmask 255.255.255.0 broadcast 10.0.0.255
inet6 fe80::20c:29ff:fe57:875c prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:57:87:5c txqueuelen 1000 (Ethernet)
RX packets 39 bytes 4887 (4.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 43 bytes 7502 (7.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0