首页 > 解决方案 > Static NAT with Hyper-V

问题描述

Concerning Hyper-V configuration, on my Windows host I got a NIC with two IP-Addresses (192.168.1.1 and 192.168.1.2).

In my Hyper-V guest I have a virtual NIC configured for NAT and it is working pretty fine to ping hosts on the 192.168.1.0/24 network! The NAT network is in the range 192.168.137.0/24.

Now I would like to use either the 192.168.1.1 or the 192.168.1.2 address depending on the source IP of my NAT network. Therefore I would like to configure a static NAT rule. (e.g. to map all the traffic from IP 192.168.137.10 to 192.168.1.2)

First I tried out (split for readability)

Add-NetNatStaticMapping -NatName "NAT" 
                        -ExternalPort 80 
                        -InternalPort 80 
                        -Protocol TCP 
                        -ExternalIPAddress 192.168.1.2 
                        -InternalIPAddress 192.168.137.10 

Here I get the error that some external IP is missing and that I shall add it with Add-NetNatExternal Address

So I gave it a try with

Add-NetNatExternalIPAddress -NatName "NAT" -IPAddress 192.168.1.2

Here I got the error

Element not found

Are there other ways for using a specific IP depending on the source IP in my VM?

标签: hyper-vnat

解决方案


推荐阅读