跳到主要内容

Hyper-V 端口占用问题

· 阅读需 2 分钟

参考:

管理员身份运行以下命令:

# 设置 IPv4 和 IPv6 动态端口范围为 60001-64999
netsh interface ipv4 set dynamic tcp start=60001 num=4998
netsh interface ipv6 set dynamic tcp start=60001 num=4998

# 设置 IPv4 和 IPv6 排除端口范围为 2000-9000
netsh interface ipv4 add excludedportrange protocol=tcp startport=2000 numberofports=7000
netsh interface ipv6 add excludedportrange protocol=tcp startport=2000 numberofports=7000

# 重启 Windows NAT Driver 使配置生效
net stop winnat
net start winnat

# 查看 TCP 协议动态端口范围
netsh interface ipv4 show dynamicport tcp
netsh interface ipv6 show dynamicport tcp

# 查看 TCP 协议端口排除范围
netsh interface ipv4 show excludedportrange protocol=tcp
netsh interface ipv6 show excludedportrange protocol=tcp

# 查看特定端口是否被占用
netstat -ano | findstr 3000