1、由于安装时使用的是最小化安装CentOS 7,安装完成后没有发现ifconfig命令
检查/sbin下也没有这个命令。使用的是root身份。
#yum install -y net-tools\*
可以成功安装ifconfig[root@localhost ~]# ls /sbin/if*
/sbin/ifcfg /sbin/ifconfig /sbin/ifdown /sbin/ifenslave /sbin/ifstat /sbin/ifup
2、安装过程中没有提示设置网卡,安装好后也没有发现ifcfg-eth0的 配置文件。[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的消息[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改为了eno16777736
3、更改网卡的名字 - 由eno16777736改为eth0[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 “。
然后执行# grub2-mkconfig -o /etc/grub2.cfg
之后重启# 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 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
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 mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
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