CentOS 7 更改网卡名到之前的eth0 Centos 配置eth0 提示Device does not seem to be present

 

      最近安装了CentOS7,内核总算升级到3.10,支持Linux容器,network namespace·······html

      可是安装完以后,发现ifconfig没看到熟悉的eth0,倒是enp0s3,虽然只是一个网卡代号,但明显会影响一些脚本,带来诸多不方便,也不知道CentOS为什么设置成这样。因而想把他改回来。ios

[root@localhost fbw]# ifconfig 
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500 inet 10.0.2.5 netmask 255.255.255.0 broadcast 10.0.2.255 inet6 fe80::a00:27ff:fe80:4d3c prefixlen 64 scopeid 0x20<link> ether 08:00:27:80:4d:3c txqueuelen 1000 (Ethernet) RX packets 2134 bytes 176901 (172.7 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1504 bytes 206316 (201.4 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 538 bytes 46716 (45.6 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 538 bytes 46716 (45.6 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

 

  因而参考以前的一篇日志 Centos 配置eth0 提示Device does not seem to be present ,先去将ifcfg-enp0s3重命名为ifcfg-eth0,而后去查看/etc/udev/rules.d/70-persistent-net.rules文件,竟然发现CentOS7里面没有这个文件,看来以前删除这个重启的方法不奏效了。vim

   先百度一下,找到了一篇《 Centos Linux系统安装后网卡em改回eth的两种方法》看了其中的第二个方法,改了一下grub的引导文件,重启一下,发现仍是没有更名。wordpress

   后google了一下,找到了一篇《Change default network name to old “eth0″ on RHEL 7 / Fedora 19 above》也是改了一下grub文件,重启以后成功解决!!!oop

 

具体步骤以下:

   一、 vim /etc/default/grub post

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=”rd.lvm.lv=rootvg/usrlv rd.lvm.lv=rootvg/swaplv crashkernel=auto vconsole.keymap=us rd.lvm.lv=rootvg/rootlv vconsole.font=latarcyrheb-sun16 rhgb quiet”
GRUB_DISABLE_RECOVERY=”true”

 

    在GRUB_CMDLINE_LINUX的最后,加上 net.ifnames=0 biosdevname=0 的参数ui

GRUB_CMDLINE_LINUX=”rd.lvm.lv=rootvg/usrlv rd.lvm.lv=rootvg/swaplv crashkernel=auto vconsole.keymap=us rd.lvm.lv=rootvg/rootlv vconsole.font=latarcyrheb-sun16 rhgb quiet net.ifnames=0 biosdevname=0

 

  二、 grub2-mkconfig -o /boot/grub2/grub.cfggoogle

  三、 mv /etc/sysconfig/network-scripts/ifcfg-enp0s3  /etc/sysconfig/network-scripts/ifcfg-eth0 url

  四、 rebootspa

 

  最后成功将网卡重名为eth0,嗯~~,仍是那个味道,仍是那么亲切~~~

[fbw@localhost ~]$ ifconfig 
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.2.5  netmask 255.255.255.0  broadcast 10.0.2.255
        inet6 fe80::a00:27ff:fe80:4d3c  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:80:4d:3c  txqueuelen 1000  (Ethernet)
        RX packets 56  bytes 7959 (7.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 70  bytes 10796 (10.5 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 5  bytes 580 (580.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5  bytes 580 (580.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
相关文章
相关标签/搜索