centos把网卡名称修改为eth0的方法
centos把网卡名称修改为eth0
默认网卡名称是eno16777736
1、修改配置文件ifcfg-eno16777736
[root@localhost~]#cd/etc/sysconfig/network-scripts/ [root@localhostnetwork-scripts]#vimifcfg-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
重命名该文件
mvifcfg-eno16777736ifcfg-eth0
2、禁用该可预测命名规则
在grup文件里面的GRUB_CMDLINE_LINUX变量添加net.ifnames=0biosdevname=0
[root@localhostnetwork-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=autonet.ifnames=0biosdevname=0rhgbquiet" GRUB_DISABLE_RECOVERY="true"
运行命令重新生成GRUB配置并更新内核参数
[root@localhostnetwork-scripts]#grub2-mkconfig-o/boot/grub2/grub.cfg Generatinggrubconfigurationfile... Foundlinuximage:/boot/vmlinuz-3.10.0-327.el7.x86_64 Foundinitrdimage:/boot/initramfs-3.10.0-327.el7.x86_64.img Foundlinuximage:/boot/vmlinuz-0-rescue-692c580a413f41d8b51ddc4724500560 Foundinitrdimage:/boot/initramfs-0-rescue-692c580a413f41d8b51ddc4724500560.img done
3、重启系统
[root@localhostnetwork-scripts]#rebootnow
查看网卡信息
[root@localhostnetwork-scripts]#ifconfig eth0:flags=4163<UP,BROADCAST,RUNNING,MULTICAST>mtu1500 inet192.168.81.128netmask255.255.255.0broadcast192.168.81.255 inet6fe80::20c:29ff:fe5b:1a46prefixlen64scopeid0x20<link> ether00:0c:29:5b:1a:46txqueuelen1000(Ethernet) RXpackets474bytes41909(40.9KiB) RXerrors0dropped0overruns0frame0 TXpackets266bytes45987(44.9KiB) TXerrors0dropped0overruns0carrier0collisions0 lo:flags=73<UP,LOOPBACK,RUNNING>mtu65536 inet127.0.0.1netmask255.0.0.0 inet6::1prefixlen128scopeid0x10<host> looptxqueuelen0(LocalLoopback) RXpackets6bytes564(564.0B) RXerrors0dropped0overruns0frame0 TXpackets6bytes564(564.0B) TXerrors0dropped0overruns0carrier0collisions0 virbr0:flags=4099<UP,BROADCAST,MULTICAST>mtu1500 inet192.168.122.1netmask255.255.255.0broadcast192.168.122.255 ether00:00:00:00:00:00txqueuelen0(Ethernet) RXpackets0bytes0(0.0B) RXerrors0dropped0overruns0frame0 TXpackets0bytes0(0.0B) TXerrors0dropped0overruns0carrier0collisions0
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。