
默认网卡名称是 eno16777736
1、修改配置文件 ifcfg-eno16777736
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# vim ifcfg-eno16777736
将 NAME 和 DEVICE 修改为 eth0
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=eth0
UUID=0fea6de7-54d9-4a8d-bddc-3061678e8a0e
DEVICE=eth0
ONBOOT=yes
PEERDNS=yes
PEERROUTES=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
重命名该文件
mv ifcfg-eno16777736 ifcfg-eth0
如果不启动 dhcp,则可以设置静态 ip 配置
TYPE=Ethernet
DEVICE=eth0
ONBOOT=yes #系统启动时是否自动加载
BOOTPROTO=static #启用地址协议 --static:静态协议 --bootp协议 --dhcp协议
IPADDR=192.168.81.128
NETMASK=255.255.255.0
GATEWAY=192.168.81.2
DNS1=192.168.81.2
HWADDR=:0C:::5D:
BROADCAST=192.168.81.255
2、禁用该可预测命名规则
在 grup 文件里面的 GRUB_CMDLINE_LINUX 变量添加 net.ifnames=0 biosdevname=0
[root@localhost network-scripts]# vim /etc/default/grub
GRUB_TIMEOUT=
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 net.ifnames=0 biosdevname=0 rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
运行命令重新生成GRUB配置并更新内核参数
[root@localhost network-scripts]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.-.el7.x86_64
Found initrd image: /boot/initramfs-3.10.-.el7.x86_64.img
Found linux image: /boot/vmlinuz--rescue-692c580a413f41d8b51ddc4724500560
Found initrd image: /boot/initramfs--rescue-692c580a413f41d8b51ddc4724500560.img
done
3、重启系统
[root@localhost network-scripts]# reboot now
查看网卡信息
[root@localhost network-scripts]# ifconfig
eth0: flags=<UP,BROADCAST,RUNNING,MULTICAST> mtu
inet 192.168.81.128 netmask 255.255.255.0 broadcast 192.168.81.255
inet6 fe80::20c:29ff:fe5b:1a46 prefixlen scopeid 0x20<link>
ether :0c::5b:1a: txqueuelen (Ethernet)
RX packets bytes (40.9 KiB)
RX errors dropped overruns frame
TX packets bytes (44.9 KiB)
TX errors dropped overruns carrier collisions lo: flags=<UP,LOOPBACK,RUNNING> mtu
inet 127.0.0.1 netmask 255.0.0.0
inet6 :: prefixlen scopeid 0x10<host>
loop txqueuelen (Local Loopback)
RX packets bytes (564.0 B)
RX errors dropped overruns frame
TX packets bytes (564.0 B)
TX errors dropped overruns carrier collisions virbr0: flags=<UP,BROADCAST,MULTICAST> mtu
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether ::::: txqueuelen (Ethernet)
RX packets bytes (0.0 B)
RX errors dropped overruns frame
TX packets bytes (0.0 B)
TX errors dropped overruns carrier collisions