centos7默认服务器网卡名称,如下图:
[root@localhost ~]# ifconfig ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.0.160 netmask 255.255.255.0 broadcast 192.168.0.255 inet6 fe80::250:56ff:fe37:a950 prefixlen 64 scopeid 0x20<link> ether 00:50:56:37:a9:50 txqueuelen 1000 (Ethernet) RX packets 335 bytes 33930 (33.1 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 210 bytes 23175 (22.6 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 1 (Local Loopback) RX packets 24 bytes 2920 (2.8 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 24 bytes 2920 (2.8 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
修改linux网卡名称为传统的eth开头,如下图:
[root@localhost ~]# ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.0.112 netmask 255.255.255.0 broadcast 192.168.0.255 inet6 fe80::20c:29ff:fe4b:66b prefixlen 64 scopeid 0x20<link> ether 00:0c:29:4b:06:6b txqueuelen 1000 (Ethernet) RX packets 71 bytes 7624 (7.4 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 63 bytes 8717 (8.5 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 1 (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
修改网卡名称方法步骤如下:
第一步:编辑/etc/sysconfig/grub文件或者/etc/default/grub文件,再倒数第二行quit后面添加如下代码:
net.ifnames=0 biosdevname=0
[root@localhost ~]# 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="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet net.ifnames = 0 biosdevname = 0 " GRUB_DISABLE_RECOVERY="true"
第二步:执行命令,grub2-mkconfig -o /boot/grub2/grub.cfg,生产新的grub.cfg文件。
[root@localhost ~]#grub2-mkconfig -o /boot/grub2/grub.cfg
第三步:修改网卡配置文件
[root@localhost ~]# cd /etc/sysconfig/network-scripts/ [root@localhost ~]# mv ifcfg-ens33 ifcfg-eth0 DEVICE=eth0 [root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 IPADDR=192.168.0.112 PREFIX=24 BROADCAST=192.168.0.255 ONBOOT=yes NAME=eth0
第四步:重启服务器生效
[root@localhost ~]#reboot [root@localhost ~]# ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.0.112 netmask 255.255.255.0 broadcast 192.168.0.255 inet6 fe80::20c:29ff:fe4b:66b prefixlen 64 scopeid 0x20<link> ether 00:0c:29:4b:06:6b txqueuelen 1000 (Ethernet) RX packets 243 bytes 21680 (21.1 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 165 bytes 20161 (19.6 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 1 (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
选中Install CentOS 7不要回车,直接按Tab键,在行尾加入如下参数net.ifnames=0 biosdevname=0再回车进行下一步,则系统安装完成后默认网卡名称为eth模式