红联Linux门户
Linux帮助

windows--virtualbox端口号映射失败的解决方法

发布时间:2016-04-21 10:07:39来源:linux网站作者:yanxiangyfg

背景:
在windows 7中安装virtualbox虚拟机运行如ubuntu、android等系统,当采用NAT模式启动时如果主机pc端需要和虚拟机内部镜像通信,则需要采用端口映射方式来实现,一个端口对应虚拟机内部一个服务。当virtualbox启动阶段会对这些端口进行映射,但是在windows中部分机器会出现端口映射失败的现象,端口映射失败日志如下:

00:00:01.125577 NAT: set redirect UDP host 0.0.0.0:6000 => guest 10.0.2.15:6000
00:00:01.125748 NAT: can't create datagram socket
00:00:01.125763 NAT: failed to redirect UDP 0.0.0.0:6000 => 10.0.2.15:6000
00:00:01.125774 NAT: set redirect TCP host 0.0.0.0:6555 => guest 10.0.2.15:5555
00:00:01.125897 NAT: failed to redirect TCP 0.0.0.0:6555 => 10.0.2.15:5555


分析:
1.此处的端口号映射没有占用windows官方分配的端口号,所有不存在端口号被windows服务占用导致无效映射的问题
2.通过netstat -ano查看所有正在使用端口,未发现映射的端口号被占用
3.上述两点都排除了,那就排查windows系统本身环境的问题,通过验证发现,可以通过修复工具修复次问题。即是由于windows本身环境导致的。


具体修复:Repair Winsock & DNS Cache
功能说明如下:
This will clear the stored DNS cache in Windows. When the DNS becomes corrupt you will not be able to get to some sites. Flushing and rebuilding the DNS will fix that problem.
Also resets winsock entries & resets TCP/IP stack.
These extra commands are run on Windows vista and newer.
执行完如下几条命令然后重启,即可修复端口号映射失败问题,此述不仅仅限于virtualbox要使用的端口映射,其他任何软件使用到端口映射且失败时可以考虑用如下几条命令修复:

netsh winsock reset all
netsh int 6to4 reset all
netsh int ipv4 reset all
netsh int ipv6 reset all
netsh int httpstunnel reset all
netsh int isatap reset all
netsh int portproxy reset all
netsh int tcp reset all
netsh int teredo reset all


如上这些命令来源于windows修复工具中其中一项,工具下载地址如下:

windows_repair工具下载:http://www.tweaking.com/content/page/windows_repair_all_in_one.html

windows--virtualbox端口号映射失败的解决方法

如果有其他windows问题可以尝试用此工具镜像修复。


本文永久更新地址:http://www.linuxdiyf.com/linux/19945.html