Score:0

Route Nat Network Internal Ip out through a Single External Ip

us flag

I have setup a Nat Network on my Hyper-V host as described by Microsoft here: Setup a Nat Network

It works great, other than, my host has 5 external Ip Addresses. Therefore, when it routes outbound through the internal gateway (192.168.0.1) out an external address, it seemingly picks any external address randomly as we can see here:

enter image description here

Certain services require the dns to resolve to the outbound ip that it's coming from and so this has become an issue in the midst of a production environment.

I'm hoping for any solution to solve this whether it be on the host, guest or in the Nat Network settings, etc.

I was thinking I could maybe remove the external Ips (Remove-NetNatExternalAddress) that are not needed (as they exist in the Nat Network) seen here:

ExternalAddressID : 0
NatName           : NATNetwork
IPAddress         : 8.94.243.210
PortStart         : 49668
PortEnd           : 49677
Active            : True

ExternalAddressID : 1
NatName           : NATNetwork
IPAddress         : 8.94.243.210
PortStart         : 56271
PortEnd           : 56280
Active            : True

ExternalAddressID : 2
NatName           : NATNetwork
IPAddress         : 8.94.243.211
PortStart         : 49678
PortEnd           : 49687
Active            : True

ExternalAddressID : 3
NatName           : NATNetwork
IPAddress         : 8.94.243.211
PortStart         : 56281
PortEnd           : 56290
Active            : True

ExternalAddressID : 1000000
NatName           : NATNetwork
IPAddress         : 0.0.0.0
PortStart         : 0
PortEnd           : 65535
Active            : True

etc...

However, the tools seem very limited and often lead me to errors, (especially when using Add-NetNatStaticMapping). It also seems as though that 0.0.0.0 mapping might cause the same issues, but not sure if I'm understanding it all correctly. Or maybe remove that too?

As a last resort, I was thinking I could remove all the external Ips, except one, then remove and add the Nat Network again (or maybe remove the Nat Network first, then remove the four Ips). Since it seems to add all the external Ips (NetNatExternalAddress) in the Nat Network setup, it therefore would only have one Ip to setup as a NetNatExternalAddress? Then add the other four external Ips back after all that is working ok on one Ip.

However, that seems drastic since I have production services running on all five ips (and the machine is remote and basically not accessible). I'm not sure it would work either (i.e. maybe it would dynamically add the other four Ips back).

Anyone done this or have any ideas? Any help is greatly appreciated.

UPDATE: I removed one of the lesser used Ip addresses and the NetNatExternalAddresses reflect that (it gets removed in NetNat too)...and then are added back when you add the Ip address back to the server. So, my last resort option won't fix the issue.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.