centos把网卡名称修改为eth0的方法
程序员文章站
2023-09-28 08:15:47
centos 把网卡名称修改为 eth0
默认网卡名称是 eno16777736
1、修改配置文件 ifcfg-eno16777736
[root@lo...
centos 把网卡名称修改为 eth0
默认网卡名称是 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
2、禁用该可预测命名规则
在 grup 文件里面的 grub_cmdline_linux 变量添加 net.ifnames=0 biosdevname=0
[root@localhost network-scripts]# vim /etc/default/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 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.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-692c580a413f41d8b51ddc4724500560 found initrd image: /boot/initramfs-0-rescue-692c580a413f41d8b51ddc4724500560.img done
3、重启系统
[root@localhost network-scripts]# reboot now
查看网卡信息
[root@localhost network-scripts]# ifconfig eth0: flags=4163<up,broadcast,running,multicast> mtu 1500 inet 192.168.81.128 netmask 255.255.255.0 broadcast 192.168.81.255 inet6 fe80::20c:29ff:fe5b:1a46 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:5b:1a:46 txqueuelen 1000 (ethernet) rx packets 474 bytes 41909 (40.9 kib) rx errors 0 dropped 0 overruns 0 frame 0 tx packets 266 bytes 45987 (44.9 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 6 bytes 564 (564.0 b) rx errors 0 dropped 0 overruns 0 frame 0 tx packets 6 bytes 564 (564.0 b) tx errors 0 dropped 0 overruns 0 carrier 0 collisions 0 virbr0: flags=4099<up,broadcast,multicast> mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether 00:00:00:00:00:00 txqueuelen 0 (ethernet) rx packets 0 bytes 0 (0.0 b) rx errors 0 dropped 0 overruns 0 frame 0 tx packets 0 bytes 0 (0.0 b) tx errors 0 dropped 0 overruns 0 carrier 0 collisions 0
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。