How to setup a static route in OSX Leopard

Posted: March 4th, 2008 | Author: David Schultz | Filed under: apple, coding, tech, troubleshooting |

I am in a situation at my office where i need a few static routes to reach external webservers. I had this working in 10.4 thanks to the tip over @ Macosxhints however after upgrading to Leopard my routes didn’t seem to get added to my routing table. I called Apple support this morning and they had no idea and actually said they don’t support this sort of thing either. Google searches came up dry however i figured out via a few terminal commands you can get it working manually. Here’s how. Pop open Terminal, and type:

su

You’ll then need to enter your root password. Strangely this didn’t work for me at first. If you have this problem too, open up Directory Utility (apps/utilities) and then click on ‘edit’ and ‘enable root user’.
Once you have root access, you can create your static routes, here is the command:

route add –net 192.168.5.0 10.0.1.5

192.168.5.0 is the network i’m trying to reach, via the gateway 10.0.1.5.

Update: Recently this stopped working for me, not sure if it was an OSX update or something with our internal network. In any case, this solved the problem for me:

sudo route add -net 192.168.5.0/24 10.0.1.5


5 Comments on “How to setup a static route in OSX Leopard”

  1. #1 Mark said at 6:40 am on March 21st, 2008:

    Hi David,
    Im glad I cam across your site, because I too am struggling with static routes on leopard.
    Having followed your instructions, I could not manage to find where to “click on edit”, hence was not successfully in enabling root user.
    Being a newbie to OSX, I have tried navigating to Directory Utility, using both Finder, and terminal. In both cases I did not find an “Edit” to click on.
    Can you help me with some more further information that may help a newbie out? It would be greatly appreciated.
    Thanks & regards,
    Mark

  2. #2 Joyce said at 5:14 pm on April 8th, 2008:

    Mark: When you go to Directory Utility, look up to the top menu bar. This is where you will find EDIT and a drop down menu. This is fairly consistent in almost all Mac applications that the Edit menu will be in the very top bar. When you click on edit, a menu of options will drop down. One of them will have the option to enable the root user. Do be careful when you are in root user, because it allows you to do things that can have very complicated ramifications. Best to “disable root user” after you have opened the static route that you need.
    The strategy described by David worked just great. Thanks!
    Joyce

  3. #3 David Schultz said at 9:56 am on April 9th, 2008:

    @Joyce

    Mark emailed about a week ago and mentioned he had success with the approach discussed below, i haven’t yet tried it myself but it looks the same as what i was using in 10.4 that broke with Leopard so your mileage may vary…
    http://discussions.apple.com/thread.jspa?messageID=5823180&tstart=2

  4. #4 Rocko said at 11:22 am on October 16th, 2008:

    Just like to point out, the above method of adding a route…is only temp. This is not a persistant route entry.

  5. #5 Eric Crist said at 3:19 pm on November 19th, 2008:

    I have a more complete how-to over at my website, you can view it at:
    http://www.secure-computing.net/wiki/index.php/Leopard_Static_Routes


Leave a Reply