Add persistent static routes on OS X Yosemite
スクリプト作成
新規ファイル
/usr/local/bin/static-routes.sh
vim /usr/local/bin/static-routes.sh
こんな内容を記述
#!/bin/bash
sudo route -n add -net 10.1.0.0 172.17.8.101
実行可に。
chmod +x /usr/local/bin/static-routes.sh
LaunchAgentsにスクリプトを登録
sudo vim ~/Library/LaunchAgents/com.docker.scripts.routes.static.plist
sudo vim ~/Library/LaunchAgents/com.docker.scripts.routes.static.plist
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd> < plist version = "1.0" > < dict > < key >Label</ key > < string >com.docker.scripts.routes.static</ string > < key >Program</ key > < string >/usr/local/bin/static-routes.sh</ string > < key >ServiceDescription</ key > < string >Persist static routes workarround</ string > < key >RunAtLoad</ key > < true /> < key >KeepAlive</ key > < true /> < key >StandardErrorPath</ key > < string >/dev/null</ string > < key >StandardOutPath</ key > < string >/dev/null</ string > </ dict > </ plist > |
有効化
launchctl load ~/Library/LaunchAgents/com.docker.scripts.routes.static.plist