1、System - Administration - Network Tools

2、Devices下选择Ethernet interface(eth0),即第0块网卡

3、选择Configure

4、选中Auto eth0 - edit - ipv4 setting:

    address:和宿主机器同一网段,避免ip冲突,例如:192.168.31.247

    netmask:255.255.255.0

    Gateway:和宿主机器同一网关,例如:192.168.31.1

    DNS Servers:和宿主机器相同,例如:192.168.31.1

5、重启网络服务

    Ubuntu:sudo /etc/init.d/networking restart

    other:service network restart

    如果上面两条命令不起作用,就重启系统试一试吧

方式二:修改interfaces文件,重启系统(推荐,简单,易用)

vi /etc/network/interfaces

auto lo
iface lo inet loopback

iface eth0 inet static

address 192.168.31.247

netmask 255.255.255.0

gateway 192.168.31.1

auto eth0

如果还是上不了网,注意查看宿主机器的相关服务是否开启

如果ping不通,注意查看宿主机器和虚拟机系统的防火墙是否关闭

关闭防火墙:

centos
 chkconfig iptables off  不重启不会生效:
 service iptables stop  不需要重启

ubuntu
 ufw disable    需要重启系统
 sudo iptables -F
 sudo ufw status

转载于:https://my.oschina.net/sniperLi/blog/490240

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐