mac os添加靜態路由

How-To: Add Static Route in Mac OS X

And because i feel lucky today, (0n a Friday the 13th, that looks kind of odd), here’s another how-to. This is how I added a static route on some Xserves. ide

Simple solution: route -n add 10.0.0.0/8 10.16.3.254 ui

Permanent solution: Add a startup item (to avoid doing the above command every reboot) spa

cd /System/Library/StartupItems
mkdir AddRoutes
cd AddRoutes ip

Create a file called AddRoutes (note: same as the folder name)
vi AddRoutes it

——————
#!/bin/sh io

# Set static routing tables table

. /etc/rc.common route

StartService ()
{
if [ 「${ADDROUTES:=-NO-}」 = 「-YES-」 ]; then
ConsoleMessage 「Adding Static Routing Table」
sudo route -nv add 10.0.0.0/8 10.16.3.254
fi
} file

StopService ()
{
return 0
} command

StopService ()
{
return 0
}

RestartService ()
{
return 0
}

RunService 「$1″
——————

Then create a file StartupParameters.plist
——————
{
Description = 「Add static routing tables」;
Provides = (」AddRoutes」);
Requires = (」Network」);
OrderPreference = 「None」;
}
—————-

Then change permissions:
chmod 755 AddRoutes StartupParameters.plist

Reboot your computer. Verify with netstat -nr

相關文章
相關標籤/搜索