Add a permanent static route to Mac OS X

As a reminder for myself, but likely useful for you! If you are in a situation where you'd like to add a static route to you Mac OS X machine, you could issue:

$ sudo route add

This commands tells the TCP/IP stack to sent traffic with the destination 10.*.*.* via But, this command is only active after issuing it and before the next reboot. To "save" this command, make it permanent, you can take these simple steps.
$ sudo mkdir /Library/StartupItems/AddRoute
# cd /Library/StartupItems/AddRoute
$ echo "{
        Description     = \"Add static routing tables\";
        Provides        = (\"AddRoutes\");
        Requires        = (\"Network\");
        OrderPreference = \"None\";
}" > StartupParameters.plist
$ echo "#!/bin/sh

# Set up static routing tables
# Roark Holz, Thursday, April 6, 2006

. /etc/rc.common

StartService ()
        ConsoleMessage "Adding Static Routing Tables"
sudo route add

StopService ()
        return 0

RestartService ()
        return 0

RunService "$1"" > AddRoutes
$ sudo chmod 755 AddRoutes

Now you should be prepared. After a reboot, the route will be visible. (netstat -rnf inet)


in Snow leopard Server 10.6.3

in Snow leopard Server 10.6.3 I need to write the StartupParameters.plist as follows:
Description = "Add static routing tables";
Provides = ("AddRoutes");
Requires = ("Network");
OrderPreference = "None";

also sudo chmod 755 StartupParameters.plist

- there is also an

- there is also an inconsistency between "AddRoute" and "AddRoutes"

doesn't work for several

doesn't work for several reasons.

- the first echo fails because regular user can't create file in directory owned by root

- the second echo fails for the same reason, plus also your attempt at nesting double quotes fails

- even after compensating for these problems, config fails on 10.4.11, simply doesn't work

thanks anyway

This didn't work for me, but

This didn't work for me, but I found something that did. This is just in case others are looking for a solution.

About Consultancy Articles Contact

References Red Hat Certified Architect By Robert de Bock Robert de Bock
Curriculum Vitae By Fred Clausen +31 6 14 39 58 72
By Nelson Manning [email protected]