標籤:centos網卡
1、由於安裝時使用的是迷你安裝CentOS 7,安裝完成後沒有發現ifconfig命令
檢查/sbin下也沒有這個命令。使用的是root身份。
#yum install -y net-tools\*
可以成功安裝ifconfig
[[email protected] ~]# ls /sbin/if*/sbin/ifcfg /sbin/ifconfig /sbin/ifdown /sbin/ifenslave /sbin/ifstat /sbin/ifup
2、安裝過程中沒有提示設定網卡,安裝好後也沒有發現ifcfg-eth0的 設定檔。
[[email protected] ~]# ls /etc/sysconfig/network-scripts/ifcfg-eno16777736 ifdown-ib ifdown-ppp ifdown-tunnel ifup-ib ifup-plusb ifup-Team network-functionsifcfg-lo ifdown-ippp ifdown-routes ifup ifup-ippp ifup-post ifup-TeamPort network-functions-ipv6ifdown ifdown-ipv6 ifdown-sit ifup-aliases ifup-ipv6 ifup-ppp ifup-tunnelifdown-bnep ifdown-isdn ifdown-Team ifup-bnep ifup-isdn ifup-routes ifup-wirelessifdown-eth ifdown-post ifdown-TeamPort ifup-eth ifup-plip ifup-sit init.ipv6-global
使用dmesg | grep -in eth檢查開機資訊中有沒有eth0的訊息
[[email protected] ~]# dmesg | grep -in eth1688:[ 1.850428] e1000 0000:02:01.0 eth0: (PCI:66MHz:32-bit) 00:0c:29:41:57:0b1689:[ 1.850433] e1000 0000:02:01.0 eth0: Intel(R) PRO/1000 Network Connection
發現由interface eth0改為了eno16777736
3、更改網卡的名字 - 由eno16777736改為eth0
[[email protected] ~]# 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
[[email protected] ~]# grub2-mkconfig -o /etc/grub2.cfg Generating grub configuration file ...Found linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64Found initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.imgFound linux image: /boot/vmlinuz-0-rescue-4e4bd6a60e2f4848aa19b757b0d96522Found initrd image: /boot/initramfs-0-rescue-4e4bd6a60e2f4848aa19b757b0d96522.imgdone[[email protected] ~]# reboot
再查看網卡,發現名字已經更改過來了。
[[email protected] ~]# 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 0lo: 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。
[[email protected] ~]# cp -a ifcfg-eno16777736 ifcfg-eth0
CentOS 7中沒有ifconfig命令,而且不能發現eth0