If I am adding static route on some of the MAC clients which have MAC OSX 10.4, it runs properly but when the machine is rebooted, the static route does not remains. What can I do to keep it at static route?
If I am adding static route on some of the MAC clients which have MAC OSX 10.4, it runs properly but when the machine is rebooted, the static route does not remains. What can I do to keep it at static route?
The problem with adding static routes in CLI on Mac OS X is that it is volatile and will disappear on reboot. To solve that problem you have to add the command in some sort of script and run it on start up. Here we run into the next problem, adding static routes doesn't work if the link isn't up on the network card.
I have solved that problem with a Startup Item written specifically for each situation with the criterias given at that time. That might not be the best solution for you but it has always worked for me. I have used it in 10.3.x and 10.4.x. There might be other better ways to solv the problem.
To add a static route e.g.:
To avoid having to do this everytime you reboot:Code:sudo route -nv add -net 192.168 -interface en0
- replace the startup section with the comand above:Code:cd /System/Library/StartupItems sudo cp -R NetworkExtensions NetworkLocal cd NetworkLocal sudo mv NetworkExtensions NetworkLocal sudo vi NetworkLocal
-- edit it to getCode:#!/bin/sh ## # Load network kernel modules ## . /etc/rc.common StartService () { ConsoleMessage "Loading Network Local" route -nv add -net 192.168 -interface en0 } StopService () { return 0 } RestartService () { return 0 } RunService "$1" sudo vi StartupParameters.plist
-- edit it to get:Code:{ Description = "Network Local"; Provides = ("NetworkLocal"); Requires = ("Network"); OrderPreference = "None"; } cd Resources/English.lproj sudo vi Localizable.strings
You could also edit the Network startup file and add the single line but that could get replaced if system is upgraded.Code:(?xml version="1.0" encoding="UTF-8"?) (!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd") (plist version="0.9") (dict> (key>Loading Network Local(/key) (string>Loading Network Local(/string) (/dict) (/plist)
Courtesy: MacOSX Forums
You'll need to switch to root to have appropriate permissions;
sudo route add 192.168.2.0/24 192.168.1.1
where 192.168.2.0 is the subnet you want to add the route to, 24 is the 24 bit subnet mask and 192.168.1.1 is the gateway.
Bookmarks