vmware 端口映射

来源:互联网 发布:听相声的软件 编辑:程序博客网 时间:2024/06/16 09:35

在windows7系统中,我有时候会使用vmware player来跑Linux虚拟机。当要想实现端口转发功能的话,就需要做些手动配置。

vmware nat的配置文件在 C:\ProgramData\VMware\vmnetnat.conf。
这个文件里面有一些注释,可以参考来配置自己想要的端口映射。

如:

...[incomingtcp]# Use these with care - anyone can enter into your virtual machine through these...# FTP (both active and passive FTP is always enabled)#      ftp localhost 8887#8887 = 192.168.27.128:21# WEB (make sure that if you are using named webhosting, names point to#     your host, not to guest... And if you are forwarding port other#     than 80 make sure that your server copes with mismatched port#     number in Host: header)#      lynx http://localhost:8888#8888 = 192.168.27.128:80# SSH#      ssh -p 8889 root@localhost#8889 = 192.168.27.128:22...
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19

这次,我是想实现ssh的22端口从宿主机到虚拟主机的跳转,虚拟机的IP为192.168.87.128,所以添加以下配置:
22 = 192.168.87.128:22

添加并保持配置文件后,需要重启下vmware nat service的服务才能生效。
服务的查看方法,在cmd中执行:
sc query|find /i “vmware”

执行后发现有如下服务名:
DISPLAY_NAME: VMware Authorization Service
DISPLAY_NAME: VMware DHCP Service
DISPLAY_NAME: VMware USB Arbitration Service
SERVICE_NAME: VMware NAT Service
DISPLAY_NAME: VMware NAT Service

在cmd中使用下面命令可以重启服务:
net stop “VMware NAT Service”&net start “VMware NAT Service”

需要注意的是,重启之后如果端口还是不同,可能是应为防火墙阻止了对应的端口,需要进行设置:
从【控制面板】选择【Windows防火墙】,然后选择【高级设置】,然后【入站规则】里选择【新建规则】,然后按照界面引导设置允许22端口的连接;同理设置【出站规则】

0 0
原创粉丝点击