赞
踩
网络环境:家庭WIFI
windos-笔记本(内装VM虚拟机)(WIFI连接)
linux台式机(与路由器连接)
桥接模式就是将虚拟机的虚拟网卡利用虚拟网桥与主机的物理网卡进行通信。这时虚拟机与物理主机就相当于在同一个局域网内,它们所使用的IP 地址也是同一个网段,与在办公室里多安装了一台电脑一样,分配给它的IP 与这个局域网内的其它IP 相同会引起冲突,这种方式适用于IP 地址分配较为宽裕的网络环境。
虚拟机通过VMnet1 虚拟网卡直接与主机的网卡进行通信,这种方式将虚拟机与外网隔离,只可以通过物理主机来访问虚拟机资源,而虚拟机也不可以访问互联网的资源,这种模式适用于复杂的网络环境进行学习和测试使用
在NAT 模式中,主机网卡直接与虚拟机的虚拟NAT 设备相连接,然后虚拟机的NAT 设备与虚拟机的虚拟DHCP 服务器一起连接到虚拟网卡VMnet8 上。这时虚拟机与物理主机就不在同一个局域网内,它主要是通过VMnet8 虚拟网卡与主机进行通信,这种方式适用于IP 地址分配较为紧张的网络环境。
(关注IPv4、子网掩码、默认网关)
[root@localhost network-scripts]# ifconfig ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.3.6 netmask 255.255.255.0 broadcast 192.168.3.255 inet6 fe80::ff54:2cd1:1e62:3bb7 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:c6:6a:c2 txqueuelen 1000 (Ethernet) RX packets 2483 bytes 227437 (222.1 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 3267 bytes 1025503 (1001.4 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 4 bytes 336 (336.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 4 bytes 336 (336.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@localhost network-scripts]#
重点关注:
下面配置,有就修改,没有就添加
BOOTPROTO //为static
ONBOOT //为yes
IPADDR
NETMASK
GATEWAY
DNS1 //为8.8.8.8
[root@localhost network-scripts]# cat ifcfg-ens33 TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=static DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ens33 UUID=53274cc6-1b66-4fd5-9568-1ecd2e0b06a3 DEVICE=ens33 ONBOOT=yes IPADDR=192.168.3.6 PREFIX=24 GATEWAY=192.168.3.1 DNS1=8.8.8.8 IPV6_PRIVACY=no [root@localhost network-scripts]#
systemctl restart network
笔记本ping虚拟机-----通
C:\Users\Administrator>ping 192.168.3.6
正在 Ping 192.168.3.6 具有 32 字节的数据:
来自 192.168.3.6 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.3.6 的回复: 字节=32 时间=1ms TTL=64
来自 192.168.3.6 的回复: 字节=32 时间=2ms TTL=64
来自 192.168.3.6 的回复: 字节=32 时间=1ms TTL=64
192.168.3.6 的 Ping 统计信息:
数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
最短 = 0ms,最长 = 2ms,平均 = 1ms
虚拟机ping笔记本-----通
[root@localhost network-scripts]# ping 192.168.3.8
PING 192.168.3.8 (192.168.3.8) 56(84) bytes of data.
64 bytes from 192.168.3.8: icmp_seq=1 ttl=128 time=0.290 ms
64 bytes from 192.168.3.8: icmp_seq=2 ttl=128 time=2.29 ms
64 bytes from 192.168.3.8: icmp_seq=3 ttl=128 time=1.17 ms
^C
--- 192.168.3.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.290/1.255/2.299/0.823 ms
[root@localhost network-scripts]#
虚拟机ping baidu.com-----通
[root@localhost sysconfig]# ping baidu.com PING baidu.com (110.242.68.66) 56(84) bytes of data. 64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=1 ttl=53 time=50.7 ms From 192.168.3.8 (192.168.3.8): icmp_seq=2 Redirect Network(New nexthop: gateway (192.168.3.1)) 64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=2 ttl=53 time=47.0 ms From 192.168.3.8 (192.168.3.8): icmp_seq=3 Redirect Network(New nexthop: gateway (192.168.3.1)) 64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=3 ttl=53 time=43.4 ms From 192.168.3.8 (192.168.3.8): icmp_seq=4 Redirect Network(New nexthop: gateway (192.168.3.1)) 64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=4 ttl=53 time=45.4 ms From 192.168.3.8 (192.168.3.8): icmp_seq=5 Redirect Network(New nexthop: gateway (192.168.3.1)) 64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=5 ttl=53 time=44.7 ms ^C --- baidu.com ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4008ms rtt min/avg/max/mdev = 43.445/46.302/50.797/2.538 ms [root@localhost sysconfig]#
虚拟机ping百度时报错信息:
From 192.168.3.8 (192.168.3.8): icmp_seq=4 Redirect Network(New nexthop: gateway (192.168.3.1))
按如下配置笔记本WIFI共享方式
[root@localhost sysconfig]# ping baidu.com
PING baidu.com (110.242.68.66) 56(84) bytes of data.
64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=1 ttl=53 time=47.3 ms
64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=2 ttl=53 time=43.1 ms
64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=3 ttl=53 time=43.3 ms
64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=4 ttl=53 time=43.9 ms
^C
--- baidu.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 43.164/44.450/47.346/1.696 ms
[root@localhost sysconfig]#
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。