真・/etc/sysconfig/static-routes
今書かないとずーっと書かなそうなので今書いておく。
註:redhat系OSの話。FreeBSDなどは他を当たってください。
以前、static-routesの記事を書いた(/etc/sysconfig/static-routes - 目論見検討委員会)。
man static-routes
とかしても、static-routesのドキュメントがなかった。
会社で、隣の先輩にメッセで相談したら、Documentation for Red Hat Products - Red Hat Customer Portalというドキュメントがあることが判明し、
/etc/init.d/network
に、
# Add non interface-specific static-routes. if [ -f /etc/sysconfig/static-routes ]; then grep "^any" /etc/sysconfig/static-routes | while read ignore args ; do /sbin/route add -$args done fi
と書いてあった(CentOS 5.2)。
要は何なのか
- 強いて言えばstatic-routesのmanはrouteである
- static-routesに書く内容は、service network restartしたときにrouteコマンドに食わせて実行される
例えば
any net 192.168.0.0/16 gw 172.16.0.254
って書いたとき、service network restartを実行すると
route add -net 192.168.0.0/16 gw 172.16.0.254
が実行される。
セキュリティー上アレゲな場合で特定のIPを指定するときは、
any host 192.168.0.1 gw 172.16.0.254
って書いて、service network restartを実行すると
route add -host 192.168.0.1 gw 172.16.0.254
が実行される。
終わり。
余談
さっきのドキュメント(Documentation for Red Hat Products - Red Hat Customer Portal)を見るとすぐ分かるんだけど、static-routesの内容って
/etc/sysconfig/network-scripts/route-interface
に書くらしい。
自宅サーバになっているCentOS 5.2の/etc/init.d/networkには、そのファイル読み込むような設定なかったな。インクルードしているか、純正redhatだったら読み込む設定が書いてあるのかもしれない。