CentOS 7虚拟机网卡启动不了解决办法

在VMMare12里安装了CentOS7虚拟机,但是开机发现连不了网,ifconfig一下,发现网卡没有启动。

eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

ether 00:0c:29:2b:c0:1e  txqueuelen 1000  (Ethernet)

RX packets 1  bytes 251 (251.0 B)

RX errors 0  dropped 0  overruns 0  frame 0

TX packets 0  bytes 0 (0.0 B)

TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: 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 386  bytes 33512 (32.7 KiB)

RX errors 0  dropped 0  overruns 0  frame 0

TX packets 386  bytes 33512 (32.7 KiB)

TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

习惯性的重启网卡服务“service network restart”

提示:

Restarting network (via systemctl):                        [  OK  ]

重启OK,,,,

再查看网卡"ifconfig"

还是老样子

于是"ifup eno16777736"手动重启网卡

提示:

Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/0)

启动成功

再查看网卡状态"ifconfig"

eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

inet 192.168.41.128  netmask 255.255.255.0  broadcast 192.168.41.255

inet6 fe80::20c:29ff:fe2b:c01e  prefixlen 64  scopeid 0x20<link>

ether 00:0c:29:2b:c0:1e  txqueuelen 1000  (Ethernet)

RX packets 74  bytes 9637 (9.4 KiB)

RX errors 0  dropped 0  overruns 0  frame 0

TX packets 61  bytes 7083 (6.9 KiB)

TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: 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 650  bytes 56612 (55.2 KiB)

RX errors 0  dropped 0  overruns 0  frame 0

TX packets 650  bytes 56612 (55.2 KiB)

TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

OK,,得到IP问题解决。

后续:

本来这个问题不会出现的,主要是我的网络环境是有DHCP服务器,IP地址可以自动获得。如果是手动输入IP就不会出现这个问题了,因为在网卡配置文件里有一项"ONBOOT=no"表示引导时不激活网卡,由于对centos7不熟悉,所以未发现这个问题。

上面的解决方法是不彻底的,因为每重启一次服务器就需要输入一次"ifup eno16777736",很是麻烦,我们可以修改网卡的配置文件"/etc/sysconfig/network-scripts/ifcfg-eno16777736"里面的"ONBOOT=no"修改成"ONBOOT=yes",至此问题彻底解决!

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/13642.html