Alastair’s Place

Software development, Cocoa, Objective-C, life. Stuff like that.

Staticroute

Static routes on OS X Server

As any OS X sysadmin is painfully aware, it’s difficult to configure static routes on OS X 10.6 and higher (both Server and non-Server versions), because the only safe (if unsupported) mechanism by which one could do this previously was removed.

Anyway, I needed some static routes configured on some of our servers, so I knocked up a bit of software to maintain them automatically, in spite of System Configuration.

To use it, install the package. This should install a Launch Daemon that starts the staticrouted server process (you can check this with ps or top; if it isn’t running, it probably means I got the installer slightly wrong, but you should be able to start it using launchctl as usual).

To create static routes, you use the staticroute program (which you’ll find in /usr/local/sbin). e.g.

1
2
$ staticroute add 10.128.4.0/24 "Main Network Interface"
$ staticroute delete 10.192.0.0/16 "Other Interface"

You can also see the list of configured static routes with

1
$ staticroute list

and a list of interface names with

1
$ staticroute list-interfaces

Configured static routes survive a restart, and will automatically be added and removed as network interfaces go up and down.

There are also man pages; these are installed in /usr/local/share/man/man8, so you might want to add /usr/local/share/man to your MANPATH if it isn’t already there.

The source code is in the mercurial repository.