I'm on a mac and trying to route a particular address though a specific gateway on my wifi connection.
I'm using:
route add -host 54.81.143.201 192.168.15.1
Sometimes this will work, other times it wont. What I found is that the interface it chooses is different every time. It needs ot be en0
to work
netstat -nr
output when it doesn't work:
54.81.143.201 192.168.15.1 UGHS 1 89 en5
This is when it does work: (note en0)
54.81.143.201 192.168.15.1 UGHS 0 1 en
Why am I doing this? Because our company has a proxy that HipChat doesn't work on. So I'm routing hipchat traffic through an open wifi network while still being on my works ethernet.
EDIT:
I also tried adding the entry using just the interface
route add -host 54.81.143.201 -interface en0
54.81.143.201 78:31:c1:c7:52:74 UHS 0 2 en0
HipChat fails to connect.
EDIT 2: Someone asked for my whole routing table, here it is today. Note that 54.81.143.201 is now bound to en3 and not en0
Internet:
Destination Gateway Flags Refs Use Netif Expire
default 10.7.90.1 UGSc 31 6 en3
10.7.90/24 link#4 UCS 4 0 en3
10.7.90.1 0:23:ac:3d:db:c2 UHLWIir 16 0 en3 1200
10.7.90.44 40:6c:8f:19:4a:bb UHLWI 0 3 en3 946
10.7.90.63 127.0.0.1 UHS 0 0 lo0
54.81.143.201 192.168.15.1 UGHS 0 0 en3
127 127.0.0.1 UCS 0 0 lo0
127.0.0.1 127.0.0.1 UH 3 209 lo0
169.254 link#4 UCS 1 0 en3
169.254.255.255 0:23:ac:3d:db:c2 UHLSW 0 0 en3
en3
is clearly correct. 192.168.15.1 isn't reachable through any other interface. The only way to reach 192.168.15.1 in that routing table is through the default route, right? (Bluntly, it sounds like you have no idea what you are doing. You seem to be surprised that the system is not doing the impossible.)