歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> Linux資訊 >> 更多Linux >> rh8下加入靜態路由

rh8下加入靜態路由

日期:2017/2/27 9:22:22   编辑:更多Linux
  根據rh8.0的文檔,設置static routes需要在 /etc/sysconfig下面建立一個文件static-routes,其內容格式可以查看rh上面的文檔, 我試了一下,好像不通, 所以查看了一下腳本,可以看到在/etc/rc.d/init.d/network中和route有關的腳本為: if [ -f /etc/sysconfig/static-routes ]; then grep "^any" /etc/sysconfig/static-routes while read ignore args ; do /sbin/route add -$args done fi 分析其意思,只有指定NIC為any的route才能夠被執行. 所以把和具體NIC綁定的route放到這個文件裡面不被系統起動時所加載的. 考查文件/etc/sysconfig/network-scripts/ifup-route 該文件在起動某個nic時被執行,來加載route,該文件會讀取文件/etc/sysconfig/networking/devices/$1.route的內容來加載和該nic相關的route信息,比如,如果要啟動的nic為eth0,則系統讀取文件/etc/sysconfig/networking/devices/eth0.route 分析ifup-routes的內容,可知eth0.route的文件格式為 ADDRESS1=x.x.x.x NETMASK1=x.x.x.x GATEWAY1=x.x.x.x ADDRESS2=x.x.x.x NETMASK2=x.x.x.x GATEWAY2=x.x.x.x ..... 數字1,2, ...為route的index 我利用這個分析試了一下,好像是可以運行的.




Copyright © Linux教程網 All Rights Reserved