I'm not very familiar with windows routing commands.

Can you please help with the windows alternative for the following linux command?

ip r a xxx.xxx.xxx.xxx/32 src yyy.yyy.yyy.yyy  via yyy.yyy.yyy.1

where: xxx.xxx.xxx.xxx is the destination IP (e.g. another server). yyy.yyy.yyy.yyy is the source IP on the windows server. yyy.yyy.yyy.1 is the default gateway for the source IP.

Thank you!

LE: It seems that windows does not let you specify the source IP. You can only specify gateway and interface. If you have all the IPs on the same interface and belonging to the same subnet, then pretty much you are "attached to another object, by an inclined plane, wrapped helically around an axis" - (the big bang theory joke).

So to resolve my issue, I just chose another IP from different subnet and routed all the traffic towards xxx.xxx.xxx.xxx via the new IPs gateway. the command is:

route add xxx.xxx.xxx.xxx mask zzz.zzz.zzz.1 -p

Where zzz.zzz.zzz.1 is the gateway for the new IP from a different subnet.

  • On that particular windows server I have multiple IPs. The main IP is different from yyy.yyy.yyy.yyy. I need to send all outgoing traffic towards the IP xxx.xxx.xxx.xxx through the IP yyy.yyy.yyy.yyy instead of the main IP of the server.
    – Adimate90
    Oct 16, 2020 at 13:48
  • The route command should be able to do it, using the "if <interface>" parameter. If your situation is different, please explain.
    – harrymc
    Oct 16, 2020 at 14:10
  • The situation is slightly different in my case. Both IPs (main IP and secondary IP) are on the same interface (network adapter). So the interface doesn't help me too much in this case.
    – Adimate90
    Oct 16, 2020 at 14:23

1 Answer 1


First open your cmd as administartor. Then type:

route ADD destination_network MASK subnet_mask gateway_ip metric_cost

This is for adding route.

For deleting,type:

route delete destination_network

  • Thanks for the suggestion. Unfortunately this does not help me because I can't specify the source IP for the destination network. It's the same situation as described here: serverfault.com/questions/684180/… but this does not seem to work for me.
    – Adimate90
    Oct 16, 2020 at 14:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .