Difference between revisions of "Leopard Static Routes"

From Secure Computing Wiki
Jump to: navigation, search
m (Reverted edits by Esubiguxoc (talk) to last revision by Ecrist)
(One intermediate revision by one other user not shown)
(No difference)

Latest revision as of 16:42, 26 November 2010

I found a little how-to over at OSXFAQ on how to do a proper static route on OS X Leopard, which will persist through reboots. Please, go over there and read it, if you'd like. I've got a couple minor changes to make it a bit clearer as to what it does:

To add a static route you need to issue a command like:

sudo route -nv add -net 192.168/16 -interface en0

To avoid having to do this everytime you reboot your system, we need to build a custom startup script. The Apple/OS X way to do this, is to put a script in /System/Library/StartupItems. Let's build the framework first:

# cd /System/Library/StartupItems
# sudo mkdir StaticRoutes
# sudo chmod 0755 ./StaticRoutes
# cd StaticRoutes
# touch StaticRoutes && touch StartupParameters.plist
# chmod 0644 ./* && chmod o+x StaticRoutes

This gets you a directory called StaticRoutes, which contains two files, StaticRoutes and StartupParameters.plist. We've also configured the proper permissions on these files.

Fill these two new files with the following text, respectively.



# Load local static routes

. /etc/rc.common

StartService ()
ConsoleMessage "Loading Static Routes"

## Enter static routes here, one line at a time as follows:
# route add <destination_network> <next_hop>  (man route for syntax)


StopService ()
return 0

RestartService ()
return 0

RunService "$1"


Description = "Static Routes";
Provides = ("StaticRoutes");
Requires = ("Network");
OrderPreference = "None";