1. 程式人生 > >Centos7.x 更改網絡卡名稱eth0

Centos7.x 更改網絡卡名稱eth0

1、修改網絡卡資訊
cd /etc/sysconfig/network-scripts/
重新命名網絡卡名稱
mv ifcfg-eno16777728 ifcfg-eth0
編輯網絡卡資訊
vim ifcfg-eth0 
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eth0 #name修改為eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=172.16.8.254
PREFIX=24
GATEWAY=172.16.8.1
DNS1=114.114.114.114

2、修改grub檔案

編輯核心資訊,新增net.ifnames=0 biosdevname=0欄位的
vim /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 rd.lvm.lv=devops/root rd.lvm.lv=devops/swap rhgb net.ifnames=0 biosdevname=0 quiet"
GRUB_DISABLE_RECOVERY="true"

執行命令grub2-mkconfig -o /boot/grub2/grub.cfg 來重新生成GRUB配置並更新核心引數                             
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-cd4cedc54acd4c289771cd4af02255e8
Found initrd image: /boot/initramfs-0-rescue-cd4cedc54acd4c289771cd4af02255e8.img
done

3、重啟系統及驗證

必須重啟系統生效
reboot  

[
[email protected]
~]# ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 172.16.8.254 netmask 255.255.255.0 broadcast 172.16.8.255 inet6 fe80::20c:29ff:fe30:707a prefixlen 64 scopeid 0x20<link> ether 00:0c:29:30:70:7a txqueuelen 1000 (Ethernet) RX packets 105 bytes 13994 (13.6 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 112 bytes 14592 (14.2 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 0 (Local Loopback) RX packets 4 bytes 340 (340.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 4 bytes 340 (340.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0