1. Set the network adapter for the virtual machine to NAT mode
2. Edit the Virtual network editor
selected VMNet8 Change Settings
Sub-network ip:192.168.101.0
Subnet Mask: 255.255.255.0
NAT Set
Gateway: 192.168.101.2
DHCP Set
Start Address: 192.168.101.128
End Address: 192.168.101.254
3. Host VMNET8 Change adapter settings
IP Address: 192.168.101.1
Subnet Mask: 255.255.255.0
None of the rest is set.
4. Virtual machine static IP settings
Right-click Network icon, Edit Connections, IPV4 Settings
Method:manual
address:192.168.101.128
netmask:255.255.255.0
gateway:192.168.101.2
DNS servers:192.168.101.2
Search Domains:localdomain
5. Test out-of-network access
Ping www.baidu.com
Host is connected with Xshell
Configuration Results View:
-----------------------------------------------------------------
Vi/etc/sysconfig/network-scripts/ifcfg-eth0
Device= "Eth0"
Bootproto=none
ipv6init= "Yes"
Nm_controlled= "Yes"
onboot= "Yes"
Type= "Ethernet"
Uuid= "aa8f2b19-fea9-4d05-a84c-fa419abc4537"
ipaddr=192.168.101.128
Prefix=24
gateway=192.168.101.2
dns1=192.168.101.2
Domain=localdomain
Defroute=yes
Ipv4_failure_fatal=yes
Ipv6_autoconf=yes
Ipv6_defroute=yes
Ipv6_failure_fatal=no
Name= "System eth0"
hwaddr=00:0c:29:f2:17:46
Ipv6_peerdns=yes
Ipv6_peerroutes=yes
last_connect=1469458152
Vi/etc/sysconfig/network
Networking=yes
Hostname=localhost.localdomain
Vi/etc/resolv.conf
# Generated by NetworkManager
Search Localdomain
NameServer 192.168.101.2
-----------------------------------------------------------------
CentOS set static IP and access to extranet