Linux7版本,虚拟机安装完后只有lo网卡没有en0或eth0网卡

实验环境:RHEL 7

虚拟机安装RHEL7之后执行ip add发现只有一个网卡lo进入/ect/sysconfig/network-scripts/目录发现只有ifcfg-lo没有eth0,随后自己配置了一个eth0发现并不可行,本人查阅资料解决了此问题,方案如下
关闭RHEL7,进入安装目录找到*.vmx文件,用编辑器打开,在最后一行添加ethernet0.virtualDev="e1000",启动虚拟机,再次执行ip addr发现多了一张网卡的信息,复制其中出现的MAC的地址

[root@system1 ~]#ip addr
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 000:0000:000:00
    inet 127.0.0.1/8 scope host to
        valid_lft forever preferred_lft forever
    inet6::1/128 scope host
        valid_lft forever preferred_lft forever
2:  eno16777736:   mtu 1500 qdisc pfifo_fast state up qlen 1000
      link/ether 00:Oc:29:97:9h:39 brd ff:ff:ff:ff:ff:ff

进入/ect/sysconfig/network-scripts/目录发现只有ifcfg-lo,没有eno16777736的配置文件便自己编写一个

[root@system1 ~]#vim /etc/sysconfig/network-scripts/ifcfg-eno16777736
ONBOOT=yes
USERCTL=no
PEERDNS=yes
TYPE= Ethernet
DEVICE=eno16777736#//(此处的是网卡设备的序号也就是ip addr中看到的网卡名称)
HWADDR=00:0c:29:64:c2:5f#此处可以不添加,根据自己机器而定
BOOTPROTO=dhcp

可是在重启网卡时

[root@system1 ~]#systemctl restart network
Restarting network (via systemctl): Job for network.service failed. See'systemctl status network.service'
and 'journalctl -xn' for details.

根据上面的提示,执行“systemctl status network.service”输出以下的类似信息:

[root@system1 ~]# systemctl status network.service
network.service - LSB: Bring up/down networking
Loaded: loaded (/etc/rc.d/init.d/network)    
Active: failed (Result: exit-code) since 二 2018-04-17 17:39:19 CST; 5min ago
4月 17 17:39:19 localhost.localdomain network[2784]: RTNETLINK answers: File exists 
4月 17 17:39:19 localhost.localdomain network[2784]: RTNETLINK answers: File exists 
4月 17 17:39:19 localhost.localdomain network[2784]: RTNETLINK answers: File exists 
4月 17 17:39:19 localhost.localdomain network[2784]: RTNETLINK answers: File exists 
4月 17 17:39:19 localhost.localdomain network[2784]: RTNETLINK answers: File exists 
4月 17 17:39:19 localhost.localdomain network[2784]: RTNETLINK answers: File exists 
4月 17 17:39:19 localhost.localdomain network[2784]: RTNETLINK answers: File exists 
4月 17 17:39:19 localhost.localdomain systemd[1]: network.service: control process exited, code=exited  status=1 
4月 17 17:39:19 localhost.localdomain systemd[1]: Failed to start LSB: Bring up/down networking. 
4月 17 17:39:19 localhost.localdomain systemd[1]: Unit network.service entered failed state.

解决的办法(由于centos7中没有70-persistent-net.rules这个文件,复制出来的虚拟机需要修改mac地址),就是修改mac地址。
将之前复制的MAC地址写入配置文件中,执行systemctl restart network 就成功了

你可能感兴趣的:(Linux7版本,虚拟机安装完后只有lo网卡没有en0或eth0网卡)