1

On a Windows 2016 Server, I need to set a custom route, so that connections to a specific destination ip address always use a specific source ip. But while the route add command allows me to specify the interface, it does not allow me to specify a source IP.

The server has one network interface with multiple IP addresses, e.g. both 10.0.0.10 and 10.0.0.20 are bound to this network interface, and the server is reachable by either IP:

c:>ipconfig
Ethernet adapter myAdapter:
  IPv4 Address. . . . . : 10.0.0.10
  Subnet Mask . . . . . : 255.255.255.0
  IPv4 Address. . . . . : 10.0.0.20
  Subnet Mask . . . . . : 255.255.255.0
  Default Gateway . . . : 10.0.0.1

By default, all outgoing connections use 10.0.0.10 as the source IP.

I need a route, so that all connections to one specific remote address (10.123.123.123) always come from the second local ip (10.0.0.20), because the device at 10.123.123.123 is configured to only accept connections from 10.0.0.20, not from 10.0.0.10:

c:>telnet 10.123.123.123 111
   This tcp connection should use 10.0.0.20 as the origin IP

I can add a route with

route ADD 10.123.123.123 MASK 255.255.255.255 10.0.0.1 METRIC 1 IF 1

However this does not change the source IP address 10.0.0.20. Outgoing connections still originate from the IP 10.0.0.10.

How can I specify which IP address the route should use, when both IPs have the same interface number?

Only connections to the IP 10.123.123.123 should be affected by this route.
All other connections should continue to use the origin IP 10.0.0.10.

Since this is a complicated legacy system mess, I am looking for a solution with minimal risk of affecting other connections, and without changes to existing software.

Therefore I would prefer not to change the global metrics for this interface, or split up the interfaces, if at all possible. A specific route affecting only ip 10.123.123.123 would be ideal.

HugoRune
  • 209
  • 3
  • 8
  • Routes are generally only refer to the destination address and gateway, not the source address. You would need to perform `Network address translation (NAT)` to make the desired configuration work. In particular, you want to utilize `SNAT` where the source address of an IP packet is being replaced. Windows server pretends to be capable of `NAT` (to be activated via Role->Remote Access->Routing), but it cannot perform `SNAT` in the way you want it. – Kevin K. Jul 18 '18 at 13:07

0 Answers0