«

Centos7更改ens33网卡名称为eth0

指尖二进制 • 1 年前 • 909 次点击 • CentOS


用ifconfig查看网卡名称为ens33,现在要将它修改成eth0

[root@localhost ~]# ifconfig 
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.3  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 2409:8a02:9014:8440:20c:29ff:fe95:cc8f  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::20c:29ff:fe95:cc8f  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:95:cc:8f  txqueuelen 1000  (Ethernet)
        RX packets 10403  bytes 15311311 (14.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 957  bytes 64104 (62.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

编辑配置文件/etc/sysconfig/network-scripts/ifcfg-ens33
将DEVICE=ens33修改成DEVICE=eth0

[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# mv ifcfg-ens33 ifcfg-eth0
[root@localhost network-scripts]# vim ifcfg-eth0
BOOTPROTO=dhcp
DEVICE=eth0
ONBOOT=yes
DNS1=8.8.8.8

编辑/etc/default/grub并加入“net.ifnames=0 biosdevname=0”

[root@localhost ~]# vim /etc/default/grub

运行命令grub2-mkconfig -o /boot/grub2/grub.cfg来重新生成GRUB配置并更新内核参数

[root@localhost ~]# 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-db7bab5d4db84dedbfad3bc210d90ded
Found initrd image: /boot/initramfs-0-rescue-db7bab5d4db84dedbfad3bc210d90ded.img
done

使用reboot命令重启操作系统

[root@localhost ~]# reboot

重启完成之后进入系统使用ifconfig命令查看网卡名称已经修改成eth0了

[root@localhost ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.3  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 2409:8a02:9014:8440:20c:29ff:fe95:cc8f  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::20c:29ff:fe95:cc8f  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:95:cc:8f  txqueuelen 1000  (Ethernet)
        RX packets 13  bytes 2223 (2.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 21  bytes 2495 (2.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
还没收到回复