标签:int running yum gen 命令 重启 ethernet print err
网络设备的名称从eth0开始排序,使用vmware创建网络的时候,网络设备的名称缺省的被设定为了eno16777736,使用ip addr或者ifconfig确认的时候,我们看到的是eno16777736而不是eth0,本来这不是什么事,但是使用诸如DCOS或者kubernetes1.4等的时候,有些版本对这个还是有些介意的,本文将简单介绍一下如何在centos7下改变网络设备名称。
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来解决这个问题。
修正/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 -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 ~]#
修正对象文件
[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了。
再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://www.cnblogs.com/captainbed
标签:int running yum gen 命令 重启 ethernet print err
原文地址:https://www.cnblogs.com/firsttry/p/10232371.html