Ubuntu VM nat模式上網

(一)服務器安裝,選擇nat模式shell

(二)打開VMware workstation ,菜單欄選項-->編輯-->虛擬網絡編輯器,如圖:服務器

注意:上圖的子網IP能夠本身指定,我這裏指定了192.168.1.0,之前是192.168.186.1。因爲我家路由器IP爲192.168.1.1,家裏別的電腦都是1段,因此這裏我也指定了1段,我修改成別的段就是不能上網,也不能用xshell鏈接Ubuntu系統網絡

點擊NAT設置能夠看到 VMware Network Adapter VMnet8 ,網關爲192.168.1.2編輯器

注意,等會DNS也配置這個IPoop

(三)配置服務器IP測試

vi /etc/network/interfacesspa

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).orm

# The loopback network interface
auto lo
iface lo inet loopbackserver

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.2dns

(四)配置DNS

網上有些方法說配置到這裏 ,可是重啓動dns就沒了: /etc/resolv.conf

永久DNS配置方法:

vi /etc/resolvconf/resolv.conf.d/base

nameserver  192.168.1.2

注意:這裏的DNS就上上面的網關IP

(五)測試

我是把防火牆關閉後測試的:apt-get remove iptables

重啓動系統,ping 百度,以下所示:

PING baidu.com (180.149.132.47) 56(84) bytes of data. 64 bytes from 180.149.132.47: icmp_seq=1 ttl=128 time=26.8 ms 64 bytes from 180.149.132.47: icmp_seq=2 ttl=128 time=28.1 ms 64 bytes from 180.149.132.47: icmp_seq=3 ttl=128 time=27.0 ms 64 bytes from 180.149.132.47: icmp_seq=4 ttl=128 time=29.7 ms

相關文章
相關標籤/搜索