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的 @R_404_382@。
[root@localhost~]#ls/etc/sysconfig/network-scripts/ ifcfg-eno16777736ifdown-ibifdown-pppifdown-tunnelifup-ibifup-plusbifup-Teamnetwork-functions ifcfg-loifdown-ipppifdown-routesifupifup-ipppifup-postifup-TeamPortnetwork-functions-ipv6 ifdownifdown-ipv6ifdown-sitifup-aliasesifup-ipv6ifup-pppifup-tunnel ifdown-bnepifdown-isdnifdown-Teamifup-bnepifup-isdnifup-routesifup-wireless ifdown-ethifdown-postifdown-TeamPortifup-ethifup-plipifup-sitinit.ipv6-global
使用dmesg | grep -in eth检查开机信息中有没有eth0的消息
[root@localhost~]#dmesg|grep-ineth 1688:[1.850428]e10000000:02:01.0eth0:(PCI:66MHz:32-bit)00:0c:29:41:57:0b 1689:[1.850433]e10000000:02:01.0eth0:Intel(R)PRO/1000NetworkConnection
发现由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=0crashkernel=autord.lvm.lv=centos/rootrd.lvm.lv=centos/swaprhgbquiet" 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 Generatinggrubconfigurationfile... Foundlinuximage:/boot/vmlinuz-3.10.0-327.el7.x86_64 Foundinitrdimage:/boot/initramfs-3.10.0-327.el7.x86_64.img Foundlinuximage:/boot/vmlinuz-0-rescue-4e4bd6a60e2f4848aa19b757b0d96522 Foundinitrdimage:/boot/initramfs-0-rescue-4e4bd6a60e2f4848aa19b757b0d96522.img done [root@localhost~]#reboot
再查看网卡,发现名字已经更改过来了。
[root@localhost~]#ifconfig eth0:flags=4163<UP,BROADCAST,RUNNING,MULTICAST>mtu1500 inet192.168.1.124netmask255.255.255.0broadcast192.168.1.255 inet6fe80::20c:29ff:fe41:570bprefixlen64scopeid0x20<link> ether00:0c:29:41:57:0btxqueuelen1000(Ethernet) RXpackets124bytes13087(12.7KiB) RXerrors0dropped0overruns0frame0 TXpackets68bytes9617(9.3KiB) TXerrors0dropped0overruns0carrier0collisions0 lo:flags=73<UP,LOOPBACK,RUNNING>mtu65536 inet127.0.0.1netmask255.0.0.0 inet6::1prefixlen128scopeid0x10<host> looptxqueuelen0(LocalLoopback) RXpackets4bytes344(344.0B) RXerrors0dropped0overruns0frame0 TXpackets4bytes344(344.0B) TXerrors0dropped0overruns0carrier0collisions0
但是仍需要将/etc/sysconfig/network-scripts/ifcfg-eno16777736更名为ifcfg-eth0,同时修改其内容,指定IP、NETMASK及GATEWAY,同时修改onboot=no为yes。最后执行service restart network。
[root@localhost~]#cp-aifcfg-eno16777736ifcfg-eth0原文链接:https://www.f2er.com/centos/380219.html