CentOS 7默认的网卡名称是eno16777736,让人看上去非常不爽,且一些网卡相关的操作需要输入一长串数字,也是非常不方便。下面,将描述如何将CentOS 7网卡名称改为我们熟悉的eth0样式。
vi/etc/sysconfig/grub
找到GRUB_CMDLINE_LINUX
这行,在后面添加net.ifnames=0 biosdevname=0
,最终效果如下:
GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR="$(sed's,release.*$,g'/etc/system-release)"GRUB_DEFAULT=saved GRUB_DISABLE_SUBMENU=trueGRUB_TERMINAL_OUTPUT="console"GRUB_CMDLINE_LINUX="crashkernel=autord.lvm.lv=centos/rootrd.lvm.lv=centos/swaprhgbquietnet.ifnames=0biosdevname=0" GRUB_DISABLE_RECOVERY="true"
紧接着执行如下命令:
grub2-mkconfig-o/boot/grub2/grub.cfg
结果如下:
Generatinggrubconfigurationfile... Foundlinuximage:/boot/vmlinuz-3.10.0-327.el7.x86_64 Foundinitrdimage:/boot/initramfs-3.10.0-327.el7.x86_64.img Foundlinuximage:/boot/vmlinuz-0-rescue-960f6a38a735453e95ee6c9d58823cb0 Foundinitrdimage:/boot/initramfs-0-rescue-960f6a38a735453e95ee6c9d58823cb0.imgdone
2. 重命名网卡配置文件
mv/etc/sysconfig/network-scripts/ifcfg-eno16777736ifcfg-eth0
[root@linux-node1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPADDR=192.168.1.101
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=202.106.0.20
DNS2=223.5.5.5
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eth0
#UUID=d33a877c-98b2-40a8-a76a-7572ec190605
DEVICE=eth0
ONBOOT=yes
此时,如果需要静态ip,桥接等网络功能,也可以顺便一起设置了,此处不表。
3. 重启系统
systemctlreboot原文链接:https://www.f2er.com/centos/377679.html