Linux网卡名称命名

版权声明: https://blog.csdn.net/zhydream77/article/details/81701388

在centos7服务器,默认网卡名是ifcfg-eno16777736,如果想更改它的名称为ifcfg-eth0

1.编写/etc/sysconfig/grub文件,在倒数第二行加net.ifnames=0 biosdevname=0"

[root@host55 ~]# 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 quiet net.ifnames=0 biosdevname=0"
GRUB_DISABLE_RECOVERY="true"

2.执行grub2-mkconfig -o /boot/grub2/grub.cfg,生成新的grub.cfg文件,命名如下
[root@host55 ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-693.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-693.el7.x86_64.img
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-eaef47d4b7d140bbb95217c73cd4d2e9
Found initrd image: /boot/initramfs-0-rescue-eaef47d4b7d140bbb95217c73cd4d2e9.img
done

3.重命名网卡名称:执行ifcfg-eno16777736 ifcfg-eth0 ,修改ifcfg-eth0文件中DEVICE=eth0

[root@host55 ~]# cd /etc/sysconfig/network-scripts/
[root@host55 network-scripts]# ls
[root@host55 network-scripts]# mv ifcfg-eno16777736 ifcfg-eth0

[root@host55 network-scripts]# vim ifcfg-eth0

DEVICE=eth0
4,重启服务器,验证网卡名称是否为eth0

[root@host55 ~]# ifconfig 
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 176.130.3.22  netmask 255.255.255.0  broadcast 176.130.3.255
        inet6 fe80::d608:4fad:6f07:61d5  prefixlen 64  scopeid 0x20<link>
        ether 50:9a:4c:55:b5:4a  txqueuelen 1000  (Ethernet)
        RX packets 193048  bytes 208682650 (199.0 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 141117  bytes 22443570 (21.4 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
 

猜你喜欢

转载自blog.csdn.net/zhydream77/article/details/81701388