Linux下找不到 eth0文件,但是ifconfig可以看到其ip地址,why?

Linux下找不到 eth0文件,但是ifconfig可以看到其ip地址,why?

一 问题-找不到网卡配置文件(ifcfg-eth0)

Centos 6.5 Linux 系统中,有的同学发现自己的网卡在/etc/sysconfig/network-scripts/下面没有发现有ifcfg-eth0,针对这个问题我们进行讨论.

在/etc/sysconfig/network-scripts/xu下没有发现有ifcfg-eth0 的文件,检测如下:

-rw-r--r--. 1 root root 254 Oct 10 2013 ifcfg-lo lrwxrwxrwx. 1 root root 20 Mar 20 2017 ifdown -> ../../../sbin/ifdown -rwxr-xr-x. 1 root root 627 Oct 10 2013 ifdown-bnep -rwxr-xr-x. 1 root root 5430 Oct 10 2013 ifdown-eth -rwxr-xr-x. 1 root root 781 Oct 10 2013 ifdown-ippp -rwxr-xr-x. 1 root root 4168 Oct 10 2013 ifdown-ipv6 lrwxrwxrwx. 1 root root 11 Mar 20 2017 ifdown-isdn -> ifdown-ippp -rwxr-xr-x. 1 root root 1481 Oct 10 2013 ifdown-post -rwxr-xr-x. 1 root root 1064 Oct 10 2013 ifdown-ppp -rwxr-xr-x. 1 root root 835 Oct 10 2013 ifdown-routes -rwxr-xr-x. 1 root root 1465 Oct 10 2013 ifdown-sit -rwxr-xr-x. 1 root root 1434 Oct 10 2013 ifdown-tunnel lrwxrwxrwx. 1 root root 18 Mar 20 2017 ifup -> ../../../sbin/ifup -rwxr-xr-x. 1 root root 12444 Oct 10 2013 ifup-aliases -rwxr-xr-x. 1 root root 859 Oct 10 2013 ifup-bnep -rwxr-xr-x. 1 root root 10556 Oct 10 2013 ifup-eth -rwxr-xr-x. 1 root root 11971 Oct 10 2013 ifup-ippp -rwxr-xr-x. 1 root root 10490 Oct 10 2013 ifup-ipv6 lrwxrwxrwx. 1 root root 9 Mar 20 2017 ifup-isdn -> ifup-ippp -rwxr-xr-x. 1 root root 727 Oct 10 2013 ifup-plip -rwxr-xr-x. 1 root root 954 Oct 10 2013 ifup-plusb -rwxr-xr-x. 1 root root 2364 Oct 10 2013 ifup-post -rwxr-xr-x. 1 root root 4154 Oct 10 2013 ifup-ppp -rwxr-xr-x. 1 root root 1925 Oct 10 2013 ifup-routes -rwxr-xr-x. 1 root root 3289 Oct 10 2013 ifup-sit -rwxr-xr-x. 1 root root 2488 Oct 10 2013 ifup-tunnel -rwxr-xr-x. 1 root root 3770 Oct 10 2013 ifup-wireless -rwxr-xr-x. 1 root root 4623 Oct 10 2013 init.ipv6-global -rwxr-xr-x. 1 root root 1125 Oct 10 2013 net.hotplug -rw-r--r--. 1 root root 13386 Oct 10 2013 network-functions -rw-r--r--. 1 root root 29853 Oct 10 2013 network-functions-ipv6  

网卡信息

 [root@localhost network-scripts]# ifconfig eth0 Link encap:Ethernet HWaddr 00:0C:29:AD:6F:DC   inet addr:192.168.1.115 Bcast:192.168.1.255 Mask:255.255.255.0  inet6 addr: fe80::20c:29ff:fead:6fdc/64 Scope:Link  UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1  RX packets:194313 errors:0 dropped:0 overruns:0 frame:0  TX packets:2643 errors:0 dropped:0 overruns:0 carrier:0  collisions:0 txqueuelen:1000  RX bytes:112599638 (107.3 MiB) TX bytes:157256 (153.5 KiB) lo Link encap:Local Loopback   inet addr:127.0.0.1 Mask:255.0.0.0  inet6 addr: ::1/128 Scope:Host  UP LOOPBACK RUNNING MTU:16436 Metric:1  RX packets:1077 errors:0 dropped:0 overruns:0 frame:0  TX packets:1077 errors:0 dropped:0 overruns:0 carrier:0  collisions:0 txqueuelen:0  RX bytes:105953 (103.4 KiB) TX bytes:105953 (103.4 KiB)  

网卡有地址,并且工作正常,那原因出在什么地方呢?

二 问题分析

在centos 6.X 版本中,有两个服务来负责网络的管理,network和networkmanager 两个服务,其中这两个服务可以同时不存在,但是如果你运行的级别是在id=3(命令多用户模式)使用的服务为network, 如果是id=5(多用户图形化)使用的是networkmanager服务。

如果没有发现ifcfg-eth0 文件,很有可能是因为network这个服务没有开启,检测如下:

[root@localhost network-scripts]# chkconfig --list | grep -i netw NetworkManager 0:off 1:off 2:on 3:on 4:on 5:on 6:off network 0:off 1:off 2:off 3:off 4:off 5:off 6:off [root@localhost network-scripts]#   

三 解决问题

如果出现了冲突,尽可能使用一个服务即可,不要同时使用,对其他的服务进行关闭,操作如下

chkconfig networkmanager off 

然后重启系统,复制lo的文件,修改名字为eth0,然后进行修改内容如下:

EVICE="eth0" BOOTPROTO=“static” // 选择静态 HWADDR="00:0C:29:E8:08:2B" IPV6INIT="yes" NM_CONTROLLED="yes" ONBOOT="yes" IPADDR=192.168.2.89 NETMASK=255.255.255.0 GATEWAY=192.168.2.1 TYPE="Ethernet" UUID="e264bc1a-e8ca-4637-951d-ece828187789 

发表评论

电子邮件地址不会被公开。 必填项已用*标注