I have a server running Windows Server 2012 R2, with one physical NIC and some Hyper-V VMs. The host has 3 external IP addresses. I've configured a Hyper-V switch on the host, assigned this a a static IP on the host, and connected a VM to this switch as well.
I'd like to be able to configure NAT on the host so that I can assign 2 of the 3 external IP addresses to have their traffic sent to the Hyper-V switch, and have the VM attached to this switch receive this traffic.
The external IPs in this senario are:
NOTE: The actual IPs assigned are not in the same subnet. They were purchased at seperate times as single IPs.
10.1.1.1 is the primary IP address for the server. 10.1.2.1 and 10.1.3.1 are additional IP addresses I have purchased and assigned to the same NIC as 10.1.1.1.
The IP address on the host, assigned to the NIC connected to the Hyper-V switch is:
On the VM, the IP address assigned to the NIC connected to the Hyper-V switch is:
I'm familiar with getting a setup like this running in Linux, but have never done this on Windows. I would normally accomplish this by setting up a virtual adapter, eth0:1, and assigning it the IP address 10.1.2.1 to it. Then apply the following iptables rules:
-A FORWARD -i eth0:1 10.1.2.1 -m state --state NEW -j ACCEPT -A PREROUTING --destination 10.1.2.1 -j DNAT --to-destination 192.168.1.1 -A POSTROUTING -s 192.168.1.0/24 -j SNAT --to 10.1.2.1
I've followed a guide from Dell for setting up a Windows Server 2012 R2 machine as a router - found here: http://www.dell.com/support/article/us/en/19/how10169/configuring-windows-server-2012-r2-as-a-router?lang=en
After setting that up, traffic to 10.1.2.1 is indeed being NAT'd and sent on to 192.168.1.1, and my VM can see the traffic. Great! The problem is that traffic from 10.1.3.1 isn't being sent to 192.168.1.1.
I was expecting something in Windows where you can say: "Anything coming in on IP x.x.x.x, use NAT and send on to y.y.y.y. Anything coming out of y.y.y.y, use SNAT and send on to x.x.x.x".
I've read the technet article on using netsh to configure routing and manage nat (https://technet.microsoft.com/en-us/library/cc754535(v=ws.10).aspx) - but so far I haven't found a way to add a single external IP to the pool.
I feel as though this should be a simple task, but I haven't been able to get it set up. I'd like to add additional external IP address to the host, and NAT them on to the Hyper-V switch, but I'm stuck!
How can I get the host configured to perform NAT on selected external IPs?
EDIT: Appleoddity's answer raised an issue I forgot to bring up - this machine is in a datacenter that I don't have access to, and the provider can't add additional NICs. I also cannot make the Hyper-V switch external, as when I tried this the host was booted from the network. After a call to the provider, I learned that they don't allow this behavior.