CentOS 6和CentOS 7网卡名称区别
- CentOS 6 基于传统的命名方式ethx,如eth0、eth1等。
- CentOS 7 开始系统默认的网卡命名会根据网卡的硬件信息、插槽位置相关。
CentOS 7 较之CentOS 6 的优点是命名全自动、可预知,但也会加大阅读难度。
CentOS 7 配置传统命名方式
系统安装过程中修改
- 选择install CentOS 7 后按Tab键
- 添加修改网卡命名规则参数
net.ifnames=0 biosdevname=0
按回车
系统安装完成后修改
-
查看当前网卡名称
[root@localhost Desktop]# ifconfig eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.75.132 netmask 255.255.255.0 broadcast 192.168.75.255 inet6 fe80::20c:29ff:fe00:839a prefixlen 64 scopeid 0x20<link> ether 00:0c:29:00:83:9a txqueuelen 1000 (Ethernet) RX packets 26 bytes 5227 (5.1 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 26 bytes 4139 (4.0 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
-
编辑网卡配置文件中网卡名称信息
[root@localhost Desktop]# vim /etc/sysconfig/network-scripts/ifcfg-eno16777728 NAME="eth0" DEVICE="eth0"
-
重命名网卡配置文件名称信息
[root@localhost Desktop]# mv /etc/sysconfig/network-scripts/ifcfg-eno16777728 /etc/sysconfig/network-scripts/ifcfg-eth0
-
编辑内核参数
在GRUB_CMDLINE_LINUX后加入net.ifnames=0 biosdevname=0[root@localhost Desktop]# vim /etc/default/grub GRUB_CMDLINE_LINUX="rhgb quiet net.ifnames=0 biosdevname=0"
-
使系统重新加载grub配置文件
编辑完grub配置文件后不会立即生效,需要生成配置文件[root@localhost Desktop]# grub2-mkconfig -o /etc/grub2.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-3e8f17dddca14000849b1775948ff329 Found initrd image: /boot/initramfs-0-rescue-3e8f17dddca14000849b1775948ff329.img done
-
重启系统并验证
[root@localhost Desktop]# ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.75.132 netmask 255.255.255.0 broadcast 192.168.75.255 inet6 fe80::20c:29ff:fe00:839a prefixlen 64 scopeid 0x20<link> ether 00:0c:29:00:83:9a txqueuelen 1000 (Ethernet) RX packets 17 bytes 3752 (3.6 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 24 bytes 4314 (4.2 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0