centos7-32只有lo网卡的解决方法

1、出现问题

VM虚拟机安装Centos7-32之后,执行ip addr发现只有一个网卡lo

进入/etc/sysconfig/network-scripts/目录发现只有ifcfg-lo没有eth0

[root@localhost ~]# ip addr
lo:  mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever

随后自己配置了一个eth0,重启网卡还是启动失败

2、解决办法

打开虚拟机安装目录

centos7-32只有lo网卡的解决方法_第1张图片

 

关闭虚拟机!编辑 *.vmx 文件,加入一行属性ethernet0.virtualDev = "e1000"

centos7-32只有lo网卡的解决方法_第2张图片

启动虚拟机,再次执行ip addr,发现多了一个网卡

[root@localhost ~]# ip addr
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:cc:01:20 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.151/24 scope global eth0
       valid_lft forever preferred_lft forever
    inet 192.168.1.101/24 brd 192.168.1.255 scope global secondary dynamic eth0
       valid_lft 7056sec preferred_lft 7056sec
    inet6 fe80::75ae:9a68:a8df:15de/64 scope link 
       valid_lft forever preferred_lft forever
[root@localhost ~]# 

然后修改eth0文件

[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 
NAME=eth0
DEVICE=eth0
TYPE=Ethernet
UUID=72DD009E-3464-47E0-A84F-1D488A10AB7
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.1.151
NETMASK=255.255.255.0
PREFIX=24
GATEWAY=192.168.1.1
DEFROUTE=yes
IPV4_FALURE_FATAL=yes
IPV6INIT=no
DNS1=114.114.114.114
HWADDR=00:0C:29:CC:01:20

NOTE:HWADDR拷贝 虚拟机--设置--网络适配器--高级--MAC地址

[root@localhost ~]# service network restart
Restarting network (via systemctl):     [ OK ]
[root@localhost ~]# ping www.baidu.com
PING www.a.shifen.com (61.135.169.121) 56(84) bytes of data.
64 bytes from 61.135.169.121 (61.135.169.121): icmp_seq=1 ttl=55 time=19.8 ms
64 bytes from 61.135.169.121 (61.135.169.121): icmp_seq=2 ttl=55 time=20.3 ms

如果依然启动失败,可以尝试改下BOOTPROTO参数 

Job for network.service failed because the control process exited with error code. 
See "systemctl status network.service" and "journalctl -xe" for details.
BOOTPROTO=none

还有一个原因就是有多个配置文件,比如ifcfg-ens33   ifcfg-lo   ifcfg-Winar_connection1等等,只留下自己配置的文件和lo文件,其他都删掉,因为会互相影响。

你可能感兴趣的:(Linux,linux,centos,network-scripts,lo)