Total Pageviews

Saturday, 29 September 2018

如何在mac上添加静态路由?

This is how I added a static route on some Xserves.
Simple solution: route -n add 10.0.0.0/8 10.16.3.254
Permanent solution: Add a startup item (to avoid doing the above command every reboot)
cd /System/Library/StartupItems
mkdir AddRoutes
cd AddRoutes
Create a file called AddRoutes (note: same as the folder name)
vi AddRoutes
——————
#!/bin/sh
# Set static routing tables
. /etc/rc.common
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
}
StopService ()
{
return 0
}
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
from http://web.archive.org/web/20180305182650/http://blog.irrashai.com/blog/2009/03/how-to-add-static-route-in-mac-os-x/
参考:
https://www.chimac.net/2010/04/27/how-to-add-a-static-route-permanently-in-snow-leopard-or-10-6/
http://www.hanynet.com/routesplit/index.html
https://blog.csdn.net/john2xy/article/details/21339451
https://blog.csdn.net/zh778/article/details/79401106
https://blog.csdn.net/zhuo212/article/details/47336063

No comments:

Post a Comment