一、 NAT模式网络访问
(1)在linux中输入命令ifconfig查看网络信息
(2)在mac中输入命令ifconfig查看网络信息
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384 options=3<RXCSUM,TXCSUM> inet6 ::1 prefixlen 128 inet 127.0.0.1 netmask 0xff000000 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 nd6 options=1<PERFORMNUD> gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280 stf0: flags=0<> mtu 1280 en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 ether a4:5e:60:ec:ff:3f inet6 fe80::a65e:60ff:feec:ff3f%en0 prefixlen 64 scopeid 0x4 inet 192.168.199.185 netmask 0xffffff00 broadcast 192.168.199.255 nd6 options=1<PERFORMNUD> media: autoselect status: active en1: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500 options=60<TSO4,TSO6> ether 6a:00:00:60:6a:e0 media: autoselect <full-duplex> status: inactive en2: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500 options=60<TSO4,TSO6> ether 6a:00:00:60:6a:e1 media: autoselect <full-duplex> status: inactive p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304 ether 06:5e:60:ec:ff:3f media: autoselect status: inactive awdl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1452 ether 7a:d1:9a:f2:6c:10 inet6 fe80::78d1:9aff:fef2:6c10%awdl0 prefixlen 64 scopeid 0x8 nd6 options=1<PERFORMNUD> media: autoselect status: active bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 options=63<RXCSUM,TXCSUM,TSO4,TSO6> ether a6:5e:60:ce:c0:00 Configuration: id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0 maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200 root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0 ipfilter disabled flags 0x2 member: en1 flags=3<LEARNING,DISCOVER> ifmaxaddr 0 port 5 priority 0 path cost 0 member: en2 flags=3<LEARNING,DISCOVER> ifmaxaddr 0 port 6 priority 0 path cost 0 nd6 options=1<PERFORMNUD> media: <unknown type> status: inactive vboxnet0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 ether 0a:00:27:00:00:00 inet 192.168.56.2 netmask 0xffffff00 broadcast 192.168.56.255 vmnet1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 ether 00:50:56:c0:00:01 inet 192.168.227.1 netmask 0xffffff00 broadcast 192.168.227.255 vmnet8: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 ether 00:50:56:c0:00:08 inet 172.16.53.1 netmask 0xffffff00 broadcast 172.16.53.255
发现多了两个vmnet1,vmnet8接口,玩过VMware的都知道这是虚拟网络,vmnet1是host-only的方式,vmnet8是NAT的方式。
(3)查看VMware Fusion配置
@webm ➜ ~ sudo more /Library/Preferences/VMware Fusion/networking VERSION=1,0 answer VNET_1_DHCP yes answer VNET_1_DHCP_CFG_HASH **** answer VNET_1_HOSTONLY_NETMASK 255.255.255.0 answer VNET_1_HOSTONLY_SUBNET 192.168.227.0 answer VNET_1_VIRTUAL_ADAPTER yes answer VNET_8_DHCP yes answer VNET_8_DHCP_CFG_HASH **** answer VNET_8_HOSTONLY_NETMASK 255.255.255.0 answer VNET_8_HOSTONLY_SUBNET 172.16.53.0 answer VNET_8_NAT yes answer VNET_8_VIRTUAL_ADAPTER yes
(4)编辑System ech0网络,
选择IP4Settings
Method选择"Manual"
点击Add
ip地址: 172.16.53.100
netmask: 255.255.255.0
gateway: 172.16.53.2
(5)vi /etc/sysoconfig/network-scripts/ifcfg-eth0
添加一行 DNS1=172.16.53.2(网关地址)
(6) vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=yeahwell.abc.com
(6)vi /etc/hosts
文件尾添加一行 172.16.53.100 yeahwell.abc.com
service network restart
(7)网络断开并重新连接
(8)ping www.baidu.com