当前位置: 首页 > LINUX > 正文

最近在测试gc 12c发邮件的功能,但是由于客户网络原因,不能通过桥接方式上网,只能通过nat方式让虚拟主机上网了。

1,win上面配置nat网卡与相应的ip地址,通过vmware提供的Virtual Network Editor来配置,要使用nat,在win主机上面必须保证vmware nat service是正常启动的,如果需要使用dhcp功能,vmware dhcp service服务也要正常启动

配置nat网口的IP地址

image

配置nat的默认网关,如果有特殊的端口映射的也可以在这里配置,点上面中的nat settings就会出现下图

image

2,虚拟主机配置网卡

在创建虚拟机的时候,如下图。在网卡这里选择自定义,并且选择vmnet1(nat),注意网卡的名字,不同的环境网卡的名字不同,如默认的是vmnet8(nat)。

image

3,虚拟主机中配置网卡的IP地址与默认网关

这里的虚拟主机是rhel 4.8,rhel平台的5,6版本的配置方式也一样。网卡IP地址配置

[root@rhel4 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
HWADDR=00:0C:29:8F:9C:7E
NETMASK=255.255.255.0
IPADDR=192.168.111.2
USERCTL=no
IPV6INIT=no
PEERDNS=yes
GATEWAY=192.168.111.3
TYPE=Ethernet

域名服务器配置

[root@rhel4 ~]# cat /etc/resolv.conf
; generated by /sbin/dhclient-script
search localdomain
nameserver 192.168.111.3

重启网卡服务,可以直接远程重启

[root@rhel4 ~]# /etc/init.d/network restart
Shutting down interface eth0:  [  OK  ]
Shutting down interface eth1:  [  OK  ]
Shutting down interface eth2:  [  OK  ]
Shutting down loopback interface:  [  OK  ]
Setting network parameters:  [  OK  ]
Bringing up loopback interface:  [  OK  ]
Bringing up interface eth0:  [  OK  ]
Bringing up interface eth1:  [  OK  ]
Bringing up interface eth2:  [  OK  ]

测试是否成功

[root@rhel4 ~]# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.112.0   0.0.0.0         255.255.255.0   U         0 0          0 eth1
192.168.113.0   0.0.0.0         255.255.255.0   U         0 0          0 eth2
192.168.111.0   0.0.0.0         255.255.255.0   U         0 0          0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth2
0.0.0.0         192.168.111.3   0.0.0.0         UG        0 0          0 eth0
[root@rhel4 ~]# nslookup www.htz.pw
Server:         192.168.111.3
Address:        192.168.111.3#53

Non-authoritative answer:
Name:   www.htz.pw
Address: 14.102.247.222

[root@rhel4 ~]# ping www.htz.pw
PING www.htz.pw (14.102.247.222) 56(84) bytes of data.
64 bytes from 014102247222.pccw.ttzz.org (14.102.247.222): icmp_seq=0 ttl=128 time=56.0 ms
64 bytes from 014102247222.pccw.ttzz.org (14.102.247.222): icmp_seq=1 ttl=128 time=154 ms
64 bytes from 014102247222.pccw.ttzz.org (14.102.247.222): icmp_seq=2 ttl=128 time=76.0 ms
64 bytes from 014102247222.pccw.ttzz.org (14.102.247.222): icmp_seq=3 ttl=128 time=200 ms
64 bytes from 014102247222.pccw.ttzz.org (14.102.247.222): icmp_seq=4 ttl=128 time=87.2 ms

能正常解析www.htz.pw,并且也能PING通主机www.htz.pw,说明配置成功。

vmware中的虚拟机通过nat方式上网:等您坐沙发呢!

发表评论

gravatar

? razz sad evil ! smile oops grin eek shock ??? cool lol mad twisted roll wink idea arrow neutral cry mrgreen

快捷键:Ctrl+Enter