最近安裝了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 |