« These drums are addictive - literally | Main | Rick Astley would never... »
Tuesday
Mar042008

How to setup a static route in OSX Leopard

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




Reader Comments (6)

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

March 21, 2008 | Unregistered CommenterMark

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

April 8, 2008 | Unregistered CommenterJoyce

@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

April 9, 2008 | Unregistered CommenterDavid Schultz

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

October 16, 2008 | Unregistered CommenterRocko

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

November 19, 2008 | Unregistered CommenterEric Crist

Also, there is no reason you need to enable root user for this, simply use sudo instead. It is the recommended course of action to accomplish the same thing for a single command. And yeah this is only temporary, but is good for inside openvpn scripts and such. ;)

January 11, 2009 | Unregistered CommenterAndrew Farley

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>