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 10.0.0.0/8 192.168.1.1$ 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 10.0.0.0/8 192.168.200.15
}
StopService ()
{
return 0
}
RestartService ()
{
return 0
}
RunService "$1"" > AddRoutes
$ sudo chmod 755 AddRoutesNow you should be prepared. After a reboot, the route will be visible. (netstat -rnf inet)
Comments
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.
http://chimac.net/2010/04/27/how-to-add-a-static-route-permanently-in-snow-leopard-or-10-6/