第一步:系统安装结束后查看当前网卡名称为ens33.
[root@jason2 ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.2.131 netmask 255.255.255.0 broadcast 192.168.2.255
inet6 fe80::1dc3:7a21:103e:c958 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:d5:85:54 txqueuelen 1000 (Ethernet)
RX packets 117 bytes 14086 (13.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 109 bytes 15871 (15.4 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/network-scripts/ifcfg-ens33“的NAME与DEVICE参数项修改为eth0。将网卡配置文件ifcfg-ens33修改为ifcfg-eth0
第三步:修改grub来禁用该命名规则
编辑grub配置文件/etc/sysconfig/grub,在GRUB_CMDLINE_LINUX变量中添加一句”net.ifnames=0 biosdevname=0“.
[root@jason2 grub2]#vi /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 quiet"
GRUB_DISABLE_RECOVERY="true"
[root@jason2 grub2]# vi /etc/default/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 quiet net.ifnames=0 biosdevname=0"
GRUB_DISABLE_RECOVERY="true
第四步:重新生成grub配置并更新内核参数
运行命令:grub2-mkconfig -o /boot/grub2/grub.cfg
[root@jason2 grub2]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /bootmlinuz-3.10.0-693.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-693.el7.x86_64.img
Found linux image: /bootmlinuz-0-rescue-77419a0d119c43968d735f6a0b8534f4
Found initrd image: /boot/initramfs-0-rescue-77419a0d119c43968d735f6a0b8534f4.img
done
[root@jason2 grub2]#
第5步:重启系统后验证
[root@jason2 ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.2.131 netmask 255.255.255.0 broadcast 192.168.2.255
inet6 fe80::bf21:39fc:b077:3c9b prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:d5:85:54 txqueuelen 1000 (Ethernet)
RX packets 801 bytes 84912 (82.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 520 bytes 83725 (81.7 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
京公网安备11010602022021 京ICP备11016550号-7号 24小时客服QQ 504927 客服微信 504927
Copyright © 2010-2025 北京世博云创科技有限公司 《中华人民共和国增值电信业务经营许可证 B1-20161178》
想了解更多的我们
关注我们的微信吧!