4 Replies Latest reply: Feb 5, 2009 12:56 PM by Camelot
Rtaxerxes Level 1 Level 1 (5 points)
Hi,

I have been searching all over for an answer and not found anything that works yet.

I am using a USB modem to access internet on my macbook. I also am connected to a private WAN network. I connect via my ethernet port to a PC running Mikrotik RouterOS which is my gateway to the WAN.

The router IP is 192.168.0.2.
The WAN uses the IP range 172.19...
I have set my ethernet port a manual IP of 192.168.0.5 with 192.168.0.2 (the routerOS gateway) as the gateway.

If I connect one of these, the other does not work, I assume because whichever is connected first becomes the default route. I have tried changing the service order under advanced network preferences with no luck.

I also tried adding a route : route add -net 172.19.0.0 -interface eth0

Neither of these worked. Any ideas?

Thanks in advance.

Macbook, iMac, iPhone, Mac OS X (10.5.5)
  • Camelot Level 8 Level 8 (46,195 points)
    Your route statement is the right approach, just the wrong values.

    If you're using two interfaces you have to remember that you can only have one default route. In this case with the USB modem handling your internet connection you should NOT have a router address set for the ethernet interface. Instead you should add a static route for just the subnets that should go over that link.

    In this case you want to route 172.19.x.x addresses through 192.168.0.2, so you'd run:

    sudo route add -net 172.19 192.168.0.2


    That way your system will use the ethernet network for all 192.168.0.x traffic (since that's the LAN address of that interface). It'll send any traffic for 172.19.x.x over this interface (via 192.168.0.2) and all other traffic will use the USB interface.
  • Rtaxerxes Level 1 Level 1 (5 points)
    Thanks, I will try that as soon as I get home. Any idea on how to make it permanent so it survives a reboot?
  • Rtaxerxes Level 1 Level 1 (5 points)
    Thanks, that worked great. What do I need to do to get into the routing table permanently? Or what do I do to make the command survive a reboot?
  • Camelot Level 8 Level 8 (46,195 points)
    Any changes via the route command are transient and will go away when the machine reboots.

    You have several options for making the route persistent - have the OS run a script at startup that adds the route.

    Your best option would be to save your routes setup in a shell script (such as /usr/local/bin/addroutes) and add a launchd script to launch that at boot time, like:

    /usr/local/bin/addroutes

    #! /bin/sh

    /sbin/route add -net 172.19 192.168.0.2


    /Library/LaunchDaemons/local.customroutes.plist

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
      <key>Label</key>
      <string>local.customroutes</string>
      <key>ProgramArguments</key>
      <array>
        <string>/usr/local/bin/addroutes</string>
      </array>
      <key>RunAtLoad</key>
      <true/>
      <key>LaunchOnlyOnce</key>
      <true/>
    </dict>
    </plist>


    The first file, /usr/local/bin/addroutes has the commands to execute while the .plist file runs the script at boot time.