linux CentOS 7网卡ens33修改为eth0
linux CentOS7的网卡ens33修改为eth0
- Linux 操作系统的网卡设备的传统命名方式是 eth0、eth1、eth2等,而 CentOS7 提供了不同的命名规则,默认是基于固件、拓扑、位置信息来分配。这样做的优点是命名全自动的、可预知的,缺点是比 eth0、wlan0 更难读,比如 ens33 。
- 如果不习惯使用新的命名规则,可以恢复使用传统的方式命名
1、先编辑网卡的配置文件将里面的NAME, DEVICE项修改为eth0
vim /etc/sysconfig/network-scripts/ifcfg-ens33
NAME=eth0 //修改为eth0
...
DEVICE=eth0 //修改为eth0
把网卡配置文件改为 ifcfg-eth0
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# mv ifcfg-ens33 ifcfg-eth0禁用该可预测命名规则。
- 你可以在启动时传递“net.ifnames=0 biosdevname=0 ”的内核参数。
- 这是通过编辑/etc/default/grub并加入“net.ifnames=0 biosdevname=0 ”到GRUBCMDLINELINUX变量来实现。
编辑 grub 配置文件
[root@mysql ~]# vi /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 rd.lvm.lv=centos/root rd.lvm.lv=centos/swap net.ifnames=0 biosdevname=0 rhgb quiet"
' /在上面添加 "net.ifnames=0 biosdevname=0" '
GRUB_DISABLE_RECOVERY="true"
运行命令grub2-mkconfig -o /boot/grub2/grub.cfg 来重新生成GRUB配置并更新内核参数。
[root@mysql ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
重启网络服务会报错,重启linux系统就好了
systemctl restart network
重新启动linux系统,重启后通过ipaddr 或者ifconfig命令验证
reboot
可以看到网卡改为eth0
[root@client1 ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 20.0.0.13 netmask 255.255.255.0 broadcast 20.0.0.255
inet6 fe80::6d44:3c07:4465:144f prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:6a:e9:5c txqueuelen 1000 (Ethernet)
RX packets 163 bytes 220240 (215.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 146 bytes 12383 (12.0 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 1 (Local Loopback)
RX packets 12 bytes 1404 (1.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 12 bytes 1404 (1.3 KiB)
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 52:54:00:14:ad:d1 txqueuelen 1000 (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
ping www.baidu.com
[root@client1 ~]# ping www.baidu.com
PING www.wshifen.com (103.235.46.39) 56(84) bytes of data.
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=1 ttl=128 time=412 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=3 ttl=128 time=330 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=4 ttl=128 time=349 ms
还没有评论,来说两句吧...