vmware player 配置NAT模式下虚拟机的端口映射

在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
...

这次,我是想实现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端口的连接;同理设置【出站规则】

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值