host-only方式共享上网

之前用桥接模式,老是ip冲突。改用host-only方式。
主机是win7系统,虚拟机是ubuntu
1.虚拟机的网络连接方式选择“host-only”。
2.设置host-only网卡通过物理网卡共享上网:主机的本地连接->属性->共享->勾上“..通过此计算机的Internet连接来连接”,选择host-only网卡。
3.host-only网卡设置:
IP Address. . . . . . . . . . . . : 192.168.137.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0
其他可以不填
4.ubuntu网卡设置
vi /etc/network/interfaces修改如下
iface eth0 inet static
address 192.168.137.101
netmask 255.255.255.0
gateway 192.168.137.1
broadcast 192.168.137.255
/etc/init.d/networking restart 重启网络
5.ping测试一下,能全通的,虚拟机ping路由器也是可以的。
问题解决:
1.虚拟机ping 192.168.137.1不通,网络配置不对或者漏了设置:虚拟机的网络连接方式选择“host-only”。
2.ping 域名不行,ping对应的ip可以,dns设置为192.168.137.1就可以了。
vi /etc/resolvconf/resolv.conf.d/base
nameserver 192.168.137.1

猜你喜欢

转载自jh108020.iteye.com/blog/1434482