8

更改centos7的网卡名称为eth0

 2 years ago
source link: https://blog.51cto.com/u_13753753/5656988
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

更改centos7的网卡名称为eth0

精选 原创

雍州无名 2022-09-07 08:35:45 博主文章分类:centos7 ©著作权

文章标签 重启 网络设备 vim 文章分类 其它 数据库 阅读数212

1.首先查看当前虚拟机的网卡名称

ifconfig
更改centos7的网卡名称为eth0_重启

2.修改网卡配置,对NAME和DEVICE进行修改,将ens18修改成eth0

vim /etc/sysconfig/network-scripts/ifcfg-ens18
更改centos7的网卡名称为eth0_网络设备_02

3.更改网卡文件的名称

cd /etc/sysconfig/network-scripts/
mv ifcfg-ens18 ifcfg-eth0
更改centos7的网卡名称为eth0_重启_03

4.禁用可预测命名规则

编辑 /etc/default/grub 并加入以下参数来实现

"net.ifnames=0 biosdevname=0"

CentOS 7 这种变化的原因,是由于systemd 和 udev 引入了一种新的网络设备命名方式–一致网络设备命名(CONSISTENT NETWORK DEVICE NAMING) 。可以根据固件、拓扑、位置信息来设置固定名字,带来的好处是命名自动化,名字完全可预测,在硬件坏了以后更换也不会影响设备的命名,这样可以让硬件的更换无缝化。带来的不利是新的设备名称比传统的名称难以阅读。比如名称是ens18.

vim /etc/default/grub

更改centos7的网卡名称为eth0_vim_04

5.重新生成GRUB配置并更新内核参数

grub2-mkconfig -o /boot/grub2/grub.cfg
更改centos7的网卡名称为eth0_重启_05

此时查看网卡名称是否已经更改

更改centos7的网卡名称为eth0_vim_06

发现网卡名称并没改变,此时还是需要重启虚拟机才可以生效

6.重启虚拟机使其生效

reboot

重启后再次查看

更改centos7的网卡名称为eth0_重启_07

可以看到网卡名已经改成eth0


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK