hyper-v NAT网络


 

 宿主机:windows 2008 R2 企业版

hyper-V配置静态IP地址
https://jingyan.baidu.com/article/925f8cb8ae1ee2c0dde05632.html

1、创建虚拟交换机(NAT-test是要创建虚拟机的名字)
New-VMSwitch –SwitchName "NAT-test" –SwitchType Internal –Verbose

2、执行Get-NetAdapter查看所有网路适配器,找到刚刚创建的NAT-test对应ifIndex值

3、新建一个网关为2.254的网关,  33是ifindex的对应值
New-NetIPAddress –IPAddress 192.168.2.254 -PrefixLength 24 -InterfaceIndex 33 –Verbose

4、设置NAT段
New-NetNat –Name NATNetwork –InternalIPInterfaceAddressPrefix 192.168.2.0/24 –Verbose

 

5、端口映射
https://www.cnblogs.com/xishi/p/4738219.html
netsh interface portproxy add v4tov4 listenport=80 listenaddress=192.168.66.168 connectaddress=192.168.2.1 connectport=80

6、删除一个端口映射
netsh interface portproxy delete v4tov4 listenaddress=主IP listenport=外网端口

7、查询端口映射情况
netsh interface portproxy show v4tov4

 

测试:

虚拟机安装httpd服务,后进行端口映射,映射到66.168上

 

 

 

重点参考文章:https://www.cnblogs.com/xishi/p/4738219.html


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM