centos7下网络设备名称修改方法
2016-10-15 19:36
561 查看
网络设备的名称从eth0开始排序,使用vmware创建网络的时候,网络设备的名称缺省的被设定为了eno16777736,使用ip addr或者ifconfig确认的时候,我们看到的是eno16777736而不是eth0,本来这不是什么事,但是使用诸如DCOS或者kubernetes1.4等的时候,有些版本对这个还是有些介意的,本文将简单介绍一下如何在centos7下改变网络设备名称。
缺省的网络设备名称
ifconfig在centos7上已经不再是确认工具,因为net-tools已经被ip工具所代替,我们将会在别的文章中进行介绍,对于不熟悉或者不想熟悉ip命令的,目前仍然可以使用yum install net-tools来解决这个问题。
修正NAME和DEVICE两个项目
可以确认在重启之后,网络设备名称已经从eno16777736变成eth0了。
事前确认
CentOS和Linux内核版本[root@host31 ~]# uname -a Linux host31 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux [root@host31 ~]#
缺省的网络设备名称
[root@host31 ~]# ifconfig eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.32.131 netmask 255.255.255.0 broadcast 192.168.32.255 inet6 fe80::20c:29ff:fe3e:8b29 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:3e:8b:29 txqueuelen 1000 (Ethernet) RX packets 11736 bytes 15663740 (14.9 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 4502 bytes 311217 (303.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 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 [root@host31 ~]#
ifconfig在centos7上已经不再是确认工具,因为net-tools已经被ip工具所代替,我们将会在别的文章中进行介绍,对于不熟悉或者不想熟悉ip命令的,目前仍然可以使用yum install net-tools来解决这个问题。
grub文件修正
修正/etc/sysconfig/grub文件, 在GRUB_CMDLINE_LINUX的末尾追加net.ifnames=0 biosdevname=0[root@host31 ~]# cp /etc/sysconfig/grub /etc/sysconfig/grub.bak [root@host31 ~]# vi /etc/sysconfig/grub [root@host31 ~]# diff /etc/sysconfig/grub /etc/sysconfig/grub.bak 6c6 < GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet net.ifnames=0 biosdevname=0" --- > GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet" [root@host31 ~]#
执行grub2-mkconfig
执行命令:grub2-mkconfig -o /boot/grub2/grub.cfg[root@host31 ~]# 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-54b1ac274dec4980aa1a41f4a54a3245 Found initrd image: /boot/initramfs-0-rescue-54b1ac274dec4980aa1a41f4a54a3245.img done [root@host31 ~]#
生成ifcfg-eth0文件
修正对象文件[root@host31 ~]# cd /etc/sysconfig/network-scripts [root@host31 network-scripts]# ls *eno* ifcfg-eno16777736 [root@host31 network-scripts]# ls *eth0* ls: cannot access *eth0*: No such file or directory [root@host31 network-scripts]# cat ifcfg-eno16777736 TYPE="Ethernet" BOOTPROTO="none" DEFROUTE="yes" IPV4_FAILURE_FATAL="no" IPV6INIT="yes" IPV6_AUTOCONF="yes" IPV6_DEFROUTE="yes" IPV6_FAILURE_FATAL="no" NAME="eno16777736" UUID="dbcb97e7-da55-42f4-b3af-ed4e909320ba" DEVICE="eno16777736" ONBOOT="yes" IPADDR="192.168.32.131" PREFIX="24" GATEWAY="192.168.32.2" DNS1="8.8.8.8" DNS2="8.8.4.4" IPV6_PEERDNS="yes" IPV6_PEERROUTES="yes" IPV6_PRIVACY="no" [root@host31 network-scripts]#
修正NAME和DEVICE两个项目
[root@host31 network-scripts]# mv ifcfg-eno16777736 ifcfg-eth0 [root@host31 network-scripts]# vi ifcfg-eth0 [root@host31 network-scripts]# cat ifcfg-eth0 TYPE="Ethernet" BOOTPROTO="none" DEFROUTE="yes" IPV4_FAILURE_FATAL="no" IPV6INIT="yes" IPV6_AUTOCONF="yes" IPV6_DEFROUTE="yes" IPV6_FAILURE_FATAL="no" NAME="eth0" UUID="dbcb97e7-da55-42f4-b3af-ed4e909320ba" DEVICE="eth0" ONBOOT="yes" IPADDR="192.168.32.131" PREFIX="24" GATEWAY="192.168.32.2" DNS1="8.8.8.8" DNS2="8.8.4.4" IPV6_PEERDNS="yes" IPV6_PEERROUTES="yes" IPV6_PRIVACY="no" [root@host31 network-scripts]#
重启
命令:reboot再确认
命令:ifconfig或者ip addr[root@host31 ~]# ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.32.131 netmask 255.255.255.0 broadcast 192.168.32.255 inet6 fe80::20c:29ff:fe3e:8b29 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:3e:8b:29 txqueuelen 1000 (Ethernet) RX packets 40 bytes 5727 (5.5 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 53 bytes 9326 (9.1 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 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 [root@host31 ~]#
可以确认在重启之后,网络设备名称已经从eno16777736变成eth0了。
相关文章推荐
- 关闭“一致性网络设备命名法” 修改centos网卡名称为 eth0
- Centos7下进入单用户模式及修改网卡名称为eth模式
- centos7下mariadb 首次修改密码及忘记密码处理方法
- centos 最小化安装后网络启用和主机名称修改
- 解决CentOS 7 开机网络设备不启动方法
- Centos 6.X 与Contos 7.x 修改计算机名称方法
- centos 7下修改系统时间方法
- CentOS7下引导Win7修改Win7为默认引导方法
- 如何修改Win8.1系统网络名称?修改Win8.1系统网络名称的方法
- 修改linux设备名称的方法
- CentOS7 网络设置与控制网络设备名称
- CentOS7下的网络设定方法
- 安装centos7.1 32bit时,没有可用的网络设备的解决方法
- centos把网卡名称修改为eth0的方法
- Win10借助修改注册表删除网络及修改网络名称方法图解
- CentOS 7下修改默认网卡名为eth0的两种方法
- Centos克隆后修改主机名称和网络IP
- 修改CentOS下的网络接口名称
- CentOS 7下修改默认网卡名为eth0的两种方法
- CentOS7下的网络设定方法