1.在虚拟机下面设置网络适配器为桥接模式(自动)
在编辑--->虚拟网络编辑器--->桥接模式.
2.在终端配置ip地址.
手动配置ip,gateway和dns
longhtml@ubuntu:~$sudo nano /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.251
netmask 255.255.255.0
gateway 192.168.1.254
接下来添加DNS
longhtml@ubuntu:~$cat /etc/resolv.conf
longhtml@ubuntu:~$sudo nano /etc/resolv.conf
nameserver 202.96.128.188 //深圳电信
nameserver 202.96.134.133
nameserver 192.168.1.254
longhtml@ubuntu:~$sudo /etc/init.d/networking restart
或者
longhtml@ubuntu:~$sudo service networking restart
如果配置失败,可以使用手工配置方法:
longhtml@ubuntu:~$sudo ifconfig eth0 192.168.1.251 netmask 255.255.255.0 up
longhtml@ubuntu:~$sudo route add default gw 192.168.1.254 eth0