一、因爲安裝時使用的是最小化安裝CentOS 7,安裝完成後沒有發現ifconfig命令linux
檢查/sbin下也沒有這個命令。使用的是root身份。vim
#yum install -y net-tools\*centos
能夠成功安裝ifconfigbash
[root@localhost ~]# ls /sbin/if* /sbin/ifcfg /sbin/ifconfig /sbin/ifdown /sbin/ifenslave /sbin/ifstat /sbin/ifup
二、安裝過程當中沒有提示設置網卡,安裝好後也沒有發現ifcfg-eth0的 配置文件。less
[root@localhost ~]# ls /etc/sysconfig/network-scripts/ ifcfg-eno16777736 ifdown-ib ifdown-ppp ifdown-tunnel ifup-ib ifup-plusb ifup-Team network-functions ifcfg-lo ifdown-ippp ifdown-routes ifup ifup-ippp ifup-post ifup-TeamPort network-functions-ipv6 ifdown ifdown-ipv6 ifdown-sit ifup-aliases ifup-ipv6 ifup-ppp ifup-tunnel ifdown-bnep ifdown-isdn ifdown-Team ifup-bnep ifup-isdn ifup-routes ifup-wireless ifdown-eth ifdown-post ifdown-TeamPort ifup-eth ifup-plip ifup-sit init.ipv6-global
使用dmesg | grep -in eth檢查開機信息中有沒有eth0的消息ide
[root@localhost ~]# dmesg | grep -in eth 1688:[ 1.850428] e1000 0000:02:01.0 eth0: (PCI:66MHz:32-bit) 00:0c:29:41:57:0b 1689:[ 1.850433] e1000 0000:02:01.0 eth0: Intel(R) PRO/1000 Network Connection
發現由interface eth0改成了eno16777736oop
三、更改網卡的名字 - 由eno16777736改成eth0post
[root@localhost ~]# 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="net.ifnames=0 crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet" GRUB_DISABLE_RECOVERY="true"
修改grub中的GRUB_CMDLINE_LINUX,追加語句"net.ifnames=0 「。ui
而後執行# grub2-mkconfig -o /etc/grub2.cfgspa
以後重啓# reboot
[root@localhost ~]# grub2-mkconfig -o /etc/grub2.cfg Generating grub configuration file ... Found linux p_w_picpath: /boot/vmlinuz-3.10.0-327.el7.x86_64 Found initrd p_w_picpath: /boot/initramfs-3.10.0-327.el7.x86_64.img Found linux p_w_picpath: /boot/vmlinuz-0-rescue-4e4bd6a60e2f4848aa19b757b0d96522 Found initrd p_w_picpath: /boot/initramfs-0-rescue-4e4bd6a60e2f4848aa19b757b0d96522.img done [root@localhost ~]# reboot
再查看網卡,發現名字已經更改過來了。
[root@localhost ~]# ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.1.124 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::20c:29ff:fe41:570b prefixlen 64 scopeid 0x20<link> ether 00:0c:29:41:57:0b txqueuelen 1000 (Ethernet) RX packets 124 bytes 13087 (12.7 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 68 bytes 9617 (9.3 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 4 bytes 344 (344.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 4 bytes 344 (344.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
可是仍須要將/etc/sysconfig/network-scripts/ifcfg-eno16777736改名爲ifcfg-eth0,同時修改其內容,指定IP、NETMASK及GATEWAY,同時修改onboot=no爲yes。最後執行service restart network。
[root@localhost ~]# cp -a ifcfg-eno16777736 ifcfg-eth0