2.NAT模式(网络地址转换模式)
NAT模式:使用NAT模式,就是让虚拟系统借助NAT(网络地址转换)功能,通过宿主机器所在的网络来访问公网。也就是说使用NAT模式可以实现在虚拟系统里访问互联网。
例子:
①虚拟机中编辑网络模式,选择NAT模式:
②虚拟机中设置为网络连接的IP地址设置为自动获得:
③宿主机的VMnet8的网络连接IP设置为:
④网络拓扑图:
虚拟机通过VMnet8网卡与宿主机进行通信,在VMnet8的两端宿主机与虚拟机在同一网段。
虚拟机想要与外界网络进行通信,通过VMnet8先与宿主机进行通信,宿主机通过本地连接网卡 将消息传递出去,保证了虚拟机可以与外界进行通信。
⑤测试:
在虚拟机中ping宿主机:
C:\Documents and Settings\Administrator>ping 192.168.188.1 Pinging 192.168.188.1 with 32 bytes of data: Reply from 192.168.188.1: bytes=32 time<1ms TTL=64 Reply from 192.168.188.1: bytes=32 time<1ms TTL=64 Reply from 192.168.188.1: bytes=32 time<1ms TTL=64 Reply from 192.168.188.1: bytes=32 time<1ms TTL=64 Ping statistics for 192.168.188.1: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms
在虚拟中ping外界网络:
C:\Documents and Settings\Administrator>ping 172.16.1.32 Pinging 172.16.1.32 with 32 bytes of data: Reply from 172.16.1.32: bytes=32 time=3ms TTL=128 Reply from 172.16.1.32: bytes=32 time=1ms TTL=128 Reply from 172.16.1.32: bytes=32 time=1ms TTL=128 Reply from 172.16.1.32: bytes=32 time=1ms TTL=128 Ping statistics for 172.16.1.32: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 1ms, Maximum = 3ms, Average = 1ms
时间: 2024-10-11 19:38:48