1. Background introduction
In centos5, we used to name network devices like eth0. In centos6, we found that network devices had changed to em1. In version 7 of CentOS, we redefined the naming rules of network cards. Therefore, the modification of this naming rules still makes many people feel headache and unable to adapt to this random naming. The name of the network card generated by the machine, the following will teach you how to fix the network card to eth0, the operation steps are very simple;
2. Modification methods
- Go into / etc/sysconfig/network-scripts / directory and backup the network card files
[root@192168088102-NFS-Server ~]# cd /etc/sysconfig/network-scripts/ [root@192168088102-NFS-Server network-scripts]# ls ifcfg-ens33 ifdown-bnep ifdown-ipv6 ifdown-ppp ifdown-Team ifup ifup-eth ifup-isdn ifup-post ifup-sit ifup-tunnel network-functions ifcfg-lo ifdown-eth ifdown-isdn ifdown-routes ifdown-TeamPort ifup-aliases ifup-ippp ifup-plip ifup-ppp ifup-Team ifup-wireless network-functions-ipv6 ifdown ifdown-ippp ifdown-post ifdown-sit ifdown-tunnel ifup-bnep ifup-ipv6 ifup-plusb ifup-routes ifup-TeamPort init.ipv6-global [root@192168088102-NFS-Server network-scripts]# cp ifcfg-ens33 ifcfg-ens33.bak [root@192168088102-NFS-Server network-scripts]# ll ifcfg-ens33* -rw-r--r--. 1 root root 347 Jul 27 11:41 ifcfg-ens33 -rw-r--r--. 1 root root 347 Jul 27 12:48 ifcfg-ens33.bak
- Change the name of the network card file to ifcfg-eth0 and modify the network card configuration file
[root@192168088102-NFS-Server network-scripts]# mv ifcfg-ens33 ifcfg-eth0 [root@192168088102-NFS-Server network-scripts]# ll ifcfg-eth0 -rw-r--r--. 1 root root 347 Jul 27 11:41 ifcfg-eth0 [root@192168088102-NFS-Server network-scripts]# cat ifcfg-eth0 TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=static DEFROUTE=yes IPV4_FAILURE_FATAL=no #Change ens33 to eth0 NAME=eth0 UUID=7615d0b6-d6c2-46bf-9140-45083e4aed4b #Change ens33 to eth0 DEVICE=eth0 ONBOOT=yes IPADDR=192.168.88.102 NETMASK=255.255.255.0 GATEWAY=192.168.88.2
- Modify the grub file and add the kernel parameter net.ifnames=0 biosdevname=0 to change the network card name to eth0
[root@192168088102-NFS-Server network-scripts]# cat /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" GRUB_DISABLE_RECOVERY="true"
- Generate startup menu, reload to startup, and restart the system
[root@192168088102-NFS-Server network-scripts]# grub2-mkconfig -o /boot/grub2/grub.cfg Generating grub configuration file ... Found linux image: /boot/vmlinuz-3.10.0-957.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-957.el7.x86_64.img Found linux image: /boot/vmlinuz-0-rescue-dc723d2d2d444cf0ae3794ab211366b8 Found initrd image: /boot/initramfs-0-rescue-dc723d2d2d444cf0ae3794ab211366b8.img done [root@192168088102-NFS-Server network-scripts]# reboot
- Verify that the network card has been successfully modified to eth0
[root@192168088102-NFS-Server ~]# ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 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 group default qlen 1000 link/ether 00:0c:29:b6:52:ed brd ff:ff:ff:ff:ff:ff inet 192.168.88.102/24 brd 192.168.88.255 scope global noprefixroute eth0 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:feb6:52ed/64 scope link valid_lft forever preferred_lft forever