I have the following scenario:
Both computers are on the same LAN segment; no default gateway is specified in either case.
To get these two computers to communicate with each other, I've added two static routes, like so:
route add 203.0.113.9 mask 255.255.255.255 198.51.100.8
However, I would prefer to add the static routes by specifying a network interface, instead of by specifying a gateway IP address.
This is possible with Linux by using a command such as:
ip route add 203.0.113.9 dev eth0
and similarly in FreeBSD:
route add 203.0.113.9/32 -iface fxp0 -cloning
However, I'm at a loss of how to do this with Windows. Ideally I want to do something like:
route add 203.0.113.9 mask 255.255.255.255 if 2
but that merely prints out the usage for the
route command, which tells me that I'm doing it wrong. I've also tried to use
netsh, which tells me:
> netsh routing ip add persistentroute 203.0.113.9 255.255.255.255 "Local Area Connection" Specify the next-hop for non point-to-point interfaces.
Any thoughts or suggestions?
Update: When I originally posted this question, I was using Windows XP. But I neglected to mention that.
I'll leave Grizly's original answer, as it is correct for my original question. But if you're using a newer version of Windows than XP/2003, give one of the other answers a try.