Monday, August 11, 2014

Adding static Routes in OSX

Just a quick correction to this blog entry:

http://blog.irrashai.com/blog/2009/03/how-to-add-static-route-in-mac-os-x/


Note: Edit the IP addresses listed below to match your network.

Create two files:  /Library/StartupItems/AddRoutes/AddRoutes
 
#!/bin/sh

# Set static routing tables

. /etc/rc.common

StartService ()
{
  ConsoleMessage "Adding Static Routing Table"
  route -n add -net 10.0.255.0/24 10.1.1.1
}

StopService ()
{
return 0
}

StopService ()
{
return 0
}

RestartService ()
{
return 0
}

RunService "$1"

 And: /Library/StartupItems/AddRoutes/StartupParameters.plist

{
Description = "Add static routing tables";
Provides = ("AddRoutes");
Requires = ("Network");
OrderPreference = "None";
}


Set everything as executable:
chmod 755 /Library/StartupItems/AddRoutes/*

Finally, reboot and check if your new routes "stuck":
netstat -rn