centos7修改网卡名字的方法

Freya ·
更新时间:2024-09-20
· 406 次阅读

很多同学在装完centos7,发现网卡接口名字变了, 不再是eth*或者em*了,而是ens*,但是这样统一维护起来就比较麻烦,那么怎么修改呢,请看下文:

1. 拷贝网卡接口配置文件

Ruby Code复制内容到剪贴板 # cd /etc/sysconfig/network-scripts/   

# cp ifcfg-ens32 ifcfg-eth0  

编辑ifcfg-eth0, 将文件中的ens32改为eth0

Ruby Code复制内容到剪贴板 # cd /etc/sysconfig/network-scripts/   

# cp ifcfg-ens32 ifcfg-eth0  

编辑ifcfg-eth0, 将文件中的ens32改为eth0

2. 修改grub

Ruby Code复制内容到剪贴板 # vim /etc/default/grub   

修改GRUB_CMDLINE_LINUX 行内容,在后面加上 net.ifnames=0 biosdevname=0,如下:   

GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet net.ifnames=0 biosdevname=0"  

# vim /etc/default/grub   

修改GRUB_CMDLINE_LINUX 行内容,在后面加上 net.ifnames=0 biosdevname=0,如下:   

GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet net.ifnames=0 biosdevname=0"  

3. 重新生成grub.cfg文件

Python

Ruby Code复制内容到剪贴板 # grub2-mkconfig -o /boot/grub2/grub.cfg   

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-cbe15acd3ca347f4a373c8f4adaf2619   

Found initrd image: /boot/initramfs-0-rescue-cbe15acd3ca347f4a373c8f4adaf2619.img   

done   

# grub2-mkconfig -o /boot/grub2/grub.cfg   

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-cbe15acd3ca347f4a373c8f4adaf2619   

Found initrd image: /boot/initramfs-0-rescue-cbe15acd3ca347f4a373c8f4adaf2619.img   

done  

4. reboot 重启

以上所述是小编给大家介绍的centos7修改网卡名字的方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对软件开发网网站的支持!



centos7 方法 centos

需要 登录 后方可回复, 如果你还没有账号请 注册新账号
相关文章