通用排查流程图(先按这个顺序来)
1. 检查虚拟机状态 → 2. 确认网络适配器模式 → 3. 检查 IP 配置 → 4. 测试基础连通性
是否开机?桥接/NAT/仅主机?同网段?ping 通?
是 → 下一步 确认模式正确 否 → 调整IP 是 → 检查服务端口 是 → 下一步 否 → 检查防火墙
一、Windows 宿主机常见问题及解决
问题 1:虚拟机能上网,但宿主机 ping 不通虚拟机
原因:Windows Defender 防火墙阻挡 解决:
# 管理员权限运行 PowerShell
# 1. 允许 ICMP(ping)通过
New-NetFirewallRule -DisplayName "Allow VM Ping" -Direction Inbound -Protocol ICMPv4 -IcmpType 8 -Action Allow
# 2. 或直接关闭防火墙(测试用,生产环境不推荐)
netsh advfirewall set allprofiles state off
# 3. 检查 VMware 服务是否运行
Get-Service | Where-Object {$_.Name -like "*VMware*"} | Select-Object Name, Status
# 确保以下服务运行:
# - VMware NAT Service
# - VMware DHCP Service
# - VMware Authorization Service
问题 2:NAT 模式下端口转发失效
解决步骤:
- 打开 VMware 虚拟网络编辑器
- 开始菜单 → VMware → Virtual Network Editor
- 选择
VMnet8 (NAT 模式)→NAT Settings
- 添加端口转发规则
示例:将宿主机的 8022 端口转发到虚拟机的 22 端口
Host Port: 8022 Type: TCP Virtual IP: 192.168.xxx.xxx (虚拟机 IP) Port: 22
- 检查 Windows 路由表
# CMD 管理员模式
route print
# 应看到类似:
# 网络目标 网络掩码 网关 接口
# 192.168.xxx.0 255.255.255.0 在链路上 192.168.xxx.1
问题 3:桥接模式获取不到 IP
解决:
- 检查物理网卡选择
- 虚拟机设置 → 网络适配器 → 桥接模式
- 点击'桥接到:'选择正确的物理网卡(有线选以太网,无线选 WLAN)
- 重置网络
# CMD 管理员模式
# 重置 Winsock
netsh winsock reset
# 重置 TCP/IP
netsh int ip reset
# 重启 VMware 服务
net stop VMnetDHCP
net start VMnetDHCP
net stop VMnetNAT
net start VMnetNAT


