有一臺網關服務器,須要配置電信聯通兩條線路,以保證電信和聯通用戶的訪問速度bash
rt_tables
文件echo 201 telnet-line >> /etc/iproute2/rt_tables
ip route add 222.171.246.0/24 dev eth0 src 222.171.246.150 table telecom-line ip route add default via 222.171.246.254 dev eth0 table telecom-line ip rule add from 222.171.246.150 table telecom-line ip rule add to 222.171.246.150 table telecom-line
至此所有配置以完成,訪問電信IP的用戶會自動從電信線路返回。其他的都會從聯通線路返回。服務器
測試沒有問題咱們能夠把以上IP加入啓動腳本里/etc/rc.local
測試
# routing policy for telecom line ip route add 222.171.246.0/27 dev eth0 src 222.171.246.150 table telecom-line ip route add default via 222.171.246.254 dev eth0 table telecom-line ip rule add from 222.171.246.150 table telecom-line ip rule add to 222.171.246.250 table telecom-line