默认 centos7 安装不设置内核版本,会影响网卡的名称。所以为了我们统一管理我们需要将网卡名称修改为 eth 开头
第一步查看服务器版本
[root@localhost ~]# cat /etc/redhat-releaseCentOS Linux release 7.6.1810 (Core)
第二步查看当前网卡名称
我们可以看到当前网卡名称都是 en0 开头的,不方便我们集中管理
[root@localhost ~]# ip a
1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eno1: mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether f4:1d:6b:86:8a:09 brd ff:ff:ff:ff:ff:ff
3: eno2: mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether f4:1d:6b:86:8a:0a brd ff:ff:ff:ff:ff:ff
4: eno3: mtu 1500 qdisc mq state UP group default qlen 1000
link/ether f4:1d:6b:86:8a:0b brd ff:ff:ff:ff:ff:ff
inet 10.4.81.93/24 brd 10.4.81.255 scope global noprefixroute eno3
valid_lft forever preferred_lft forever
inet6 fe80::687f:25f8:b435:887b/64 scope link noprefixroute
valid_lft forever preferred_lft forever
5: eno4: mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether f4:1d:6b:86:8a:0c brd ff:ff:ff:ff:ff:ff
第三步进入网卡配置文件
将所有的文件 mv 更换名称
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# ls
ifcfg-eno1 ifcfg-lo ifdown-ippp ifdown-ppp ifdown-TeamPort ifup-bnep ifup-isdn ifup-ppp ifup-TeamPort network-functions
ifcfg-eno2 ifdown ifdown-ipv6 ifdown-routes ifdown-tunnel ifup-eth ifup-plip ifup-routes ifup-tunnel network-functions-ipv6
ifcfg-eno3 ifdown-bnep ifdown-isdn ifdown-sit ifup ifup-ippp ifup-plusb ifup-sit ifup-wireless
ifcfg-eno4 ifdown-eth ifdown-post ifdown-Team ifup-aliases ifup-ipv6 ifup-post ifup-Team init.ipv6-global
[root@localhost network-scripts]#
[root@localhost network-scripts]# mv ifcfg-eno1 ifcfg-eth0
[root@localhost network-scripts]# mv ifcfg-eno2 ifcfg-eth1
[root@localhost network-scripts]# mv ifcfg-eno3 ifcfg-eth2
[root@localhost network-scripts]# mv ifcfg-eno4 ifcfg-eth3
第四步修改网卡信息
需要修改的主要几点
1.NAME
2.DEVICE
3.BOOTPROTO [dhcp or static or none]none 和 static 需要在输入 ip 地址
4. 添加 HWADDR 默认网卡没有 mac 地址,需要添加 mac 地址
第五步修改内核参数
[root@localhost network-scripts]# vi /etc/sysconfig/grub
在倒数第二行 quiet 前面添加 net.ifnames=0 biosdevname=0
第六步生成启动菜单
[root@localhost network-scripts]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-957.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-957.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-f9f84382fb844c0a84e9ee9b2a2906b5
Found initrd image: /boot/initramfs-0-rescue-f9f84382fb844c0a84e9ee9b2a2906b5.img
done
第七步验证是否修改成功
[root@localhost ~]# reboot #重启生效 centos7 默认不支持 ifconfig, 如果需要 ifconfig 请 yum install net-t
修改完毕!
正文完