Quantcast
Channel: OS X - Static routes / non-standard default gateway for endpoints on *local subnet* - Super User
Viewing all articles
Browse latest Browse all 3

OS X - Static routes / non-standard default gateway for endpoints on *local subnet*

$
0
0

My question is: How can I reliably set up a static route in OS X, for 2 endpoints to pass via a gateway, where all machines are on the same subnet? I provide the context below:

For testing purposes, I need to be able to set up a specific route between 2 endpoints on the same local subnet - an OS X (10.9) MacBook and a Linux-based 'receiver'.

The behaviour needs to be such that the next hop for traffic leaving the MacBook will be a FreeBSD-based QoS machine and not the standard default gateway. The BSD machine may also sit on the same subnet, and performs SNAT to masquerade new traffic and re-translates upon return.

Simplified, my environment is similar to the following:

Local subnet = 10.160.0.0/16
MacBook = 10.160.2.100
Linux Receiver = 10.160.2.200
Default Gateway for standard devices = 10.160.0.1


Example configuration of the BSD gateway:

en0 10.160.2.160
en1 10.160.3.170
netmask 255.255.0.0
gateway 10.160.0.1


An example of the desired flow:

REQUEST: MacBook --> BSD --> DefaultGateway --> Receiver
RESPONSE: Receiver --> DefaultGateway --> BSD --> MacBook


I see 3 problems occurring:

  1. If I set the default gateway for en0 (the only active interface) onOS X to be the BSD machine on say 10.160.2.160, this works for awhile until this default route is automatically overwritten by OS Xto be the standard default of 10.160.0.1

  2. I am also running into issues when configuring static routes in OS Xusing:

    route add 10.160.2.200 10.160.2.160

    .. in this case one of 2 things happens - either the route works for a while displaying the netstat UGHS flags, and is then overwritten by OS X after which netstat includes the M flag to indicate that it was overwritten by a redirect..

  3. ..or the route does not work at all as there must be some other route taking precedence. Traceroute confirms this.


Netstat output after initial configuration:

jiosxserver:~ julianivory$ netstat -nrRouting tablesInternet:Destination        Gateway            Flags        Refs      Use   Netif Expiredefault            10.160.2.160       UGSc           17        0     en010.140.1.31        10.160.2.160       UGHS            0        0     en010.140.1.35        10.160.1.1         UGHS            0        0     en010.160/16          link#4             UCS             5        0     en010.160.0.1         0:14:22:20:1c:d9   UHLWIir        14        0     en0   119110.160.1.37        0:50:56:8a:87:e9   UHLWIi          0        0     en0   113810.160.2.160       8e:af:b2:47:7f:91  UHLWIir         4        0     en0   114410.160.3.75        127.0.0.1          UHS             0        0     lo010.160.3.79        a8:20:66:27:72:2e  UHLWIi          0        1     en0   118410.160.255.255     ff:ff:ff:ff:ff:ff  UHLWbI          0       44     en0127                127.0.0.1          UCS             0        0     lo0127.0.0.1          127.0.0.1          UH              9    20602     lo0169.254            link#4             UCS             0        0     en0

...and Traceroute output shows that the default route is not in use:

traceroute to 8.8.8.8 (8.8.8.8), 64 hops max, 52 byte packets 1  10.160.0.1 (10.160.0.1)  0.504 ms  0.237 ms  0.217 ms 2  192.168.2.1 (192.168.2.1)  1.065 ms  1.020 ms  0.973 ms 3  name-removed (xx.1xx.xxx.1)  14.250 ms  13.688 ms  14.046 ms 4  xxx.xxx.178.141 (xxx.xxx.178.141)  14.196 ms  14.121 ms  13.967 ms


...after some time, the default gateway will have 'automagically' been changed to 10.160.0.1...

Any thoughts or suggestions would be appreciated hugely.


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images