Docker 之 Windows Hyper-V 导致的端口占用问题

为什么会出现保留端口?
为什么排除一个系统的保留端口执行的是 "netsh interface ipv4 add excludeportrange ..." 而不是 "netsh interface ipv4 delete excludeportrange ..."?
"netsh interface ipv4 show excludedportrange protocol=tcp" 中的 "Administered port exclusions" 是啥意思?
以上问题可以参考:https://stackoverflow.com/questions/58216537/what-is-administered-port-exclusions-in-windows-10

 

netstat 查不到,启动程序却提示端口占用的解决办法:

# 查看动态端口范围
netsh int ipv4 show dynamicport tcp
# 查看例外端口范围
netsh interface ipv4 show excludedportrange protocol=tcp

# 如果提示被占用的端口在例外端口范围中,执行以下步骤
# 禁用Hyper-V [需要重启电脑]
dism.exe /Online /Disable-Feature:Microsoft-Hyper-V

# 添加例外端口 或者 设置动态端口范围
netsh int ipv4 add excludedportrange protocol=tcp startport=1099 numberofports=1
netsh int ipv4 set dynamic tcp start=45000 num=10000

# 启动Hyper-V [需要重启电脑]
dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All

 

以下是常用命令:

# 禁用Hyper-V
dism.exe /Online /Disable-Feature:Microsoft-Hyper-V

# 启动Hyper-V
dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All

# 显示动态端口范围
netsh int ipv4 show dynamicport tcp
# 显示例外端口范围
netsh interface ipv4 show excludedportrange protocol=tcp

# 设置动态端口TCP范围
netsh int ipv4 set dynamicport tcp start=1024 num=13977
# 设置动态端口UDP范围
netsh int ipv4 set dynamicport udp start=1024 num=13977

# 添加例外端口
netsh int ipv4 add excludedportrange protocol=tcp startport=1099 numberofports=1

 

列举几个端口如下:

22
80
8080
443
1099
3306
6379
5672
15672
25672
61616
61613

netsh int ipv4 add excludedportrange protocol=tcp startport=22 numberofports=1
netsh int ipv4 add excludedportrange protocol=tcp startport=80 numberofports=1
netsh int ipv4 add excludedportrange protocol=tcp startport=8000 numberofports=1000
netsh int ipv4 add excludedportrange protocol=tcp startport=443 numberofports=1
netsh int ipv4 add excludedportrange protocol=tcp startport=1099 numberofports=1
netsh int ipv4 add excludedportrange protocol=tcp startport=3306 numberofports=1
netsh int ipv4 add excludedportrange protocol=tcp startport=5672 numberofports=1
netsh int ipv4 add excludedportrange protocol=tcp startport=15672 numberofports=1
netsh int ipv4 add excludedportrange protocol=tcp startport=25672 numberofports=1
netsh int ipv4 add excludedportrange protocol=tcp startport=61613 numberofports=1



 

posted on 2022-02-21 18:48  guardianbo  阅读(957)  评论(0编辑  收藏  举报

导航