Mac OS X 10.5.8 Server – How to save static route

ipmac-osxstatic-routes

I can use the command:

sudo route add 93.***.***.***/29 192.168.1.1

This adds the route that I want but its not persistant as in when I reboot the server the route needs to be re-added. There doesnt seem to be a static/persistant switch to save this route like there is under windows. How do I get the above route to stick after reboot?

Best Answer

After a bit of googling around, it looks like the only way to create a persistent route is through a startup script. I found a good tutorial at Secure Computing Networks.

Basically you need to create two files; a script for the route add and and paramaters file. Build out the files with these commands:

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

Add the script with your route in "StaticRoutes"

#!/bin/sh

##
# 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)
route add 93.***.***.***/29 192.168.1.1

}

StopService ()
{
return 0
}

RestartService ()
{
return 0
}

RunService "$1"

And the proper paramaters in StartupParamaters.plist:

{
Description = "Static Routes";
Provides = ("StaticRoutes");
Requires = ("Network");
OrderPreference = "None";
}
Related Topic