码迷,mamicode.com
首页 > 系统相关 > 详细

linux配置双线策略

时间:2015-05-25 12:47:36      阅读:247      评论:0      收藏:0      [点我收藏+]

标签:

Round 1:由外部主动发起的连接可用以下方式配置

根据用户访问进来的路径设定动态路由 


原理:如果用户是通过电信IP地址访问过来的话,那么使用电信网关做路由,返回内容走电信网关;如果用户通过网通IP地址访问过来的话,那么使用网通网关做路由,返回内容走网通的网关,具体配置方法如下: 


服务器电信IP:
180.153.146.187,电信网关:180.153.146.177
服务器网通IP:112.65.250.202,网通网关:112.65.250.193 


1) 默认网关使用电信网关作为路由 


在Linux上面配置默认网关,如果是RedHat,应该是在/etc/sysconfig/network文件里面添加一行:GATEWAY114.80.162.33,如果是SuSE,应该是在/etc/sysconfig/network/routes里面添加一行:default 114.80.162.33 - - 或者可以直接使用YaST2来配置。 


2)添加路由表 


修改/etc/iproute2/rt_tables,添加内容: 


252 tel 电信路由表  


251 cnc 网通路由表  


3)添加规则




建立  route.sh
内容如下


ip route flush table tel
ip route add default via 180.153.146.177 dev eth0 src 180.153.146.187 table tel
ip rule add from 180.153.146.187 table tel


ip route flush table cnc
ip route add default via 112.65.250.193 dev eth1 src 112.65.250.202 table cnc
ip rule add from 112.65.250.202 table cnc


4)把刚刚配置的路由规则加入开机自启动  /etc/rc.d/rc.local


5)


配置检查:





ip route list table 251


ip rule list




Round 2:由内部主动发起的连接可用以下方式配置

原理:使用刷路由表的方式进行路由分发

附 截止与2014-3-3的联通路由表,最新路由表可从http://www.lbase.net/ISPIPInfo.aspx 网站获取

 

route add -net 110.16.0.0/14 gw 112.65.250.193 
route add -net 110.52.0.0/15 gw 112.65.250.193 
route add -net 110.6.0.0/15 gw 112.65.250.193 
route add -net 110.72.0.0/15 gw 112.65.250.193 
route add -net 111.160.0.0/13 gw 112.65.250.193 
route add -net 112.109.128.0/17 gw 112.65.250.193 
route add -net 112.111.0.0/16 gw 112.65.250.193 
route add -net 112.122.0.0/15 gw 112.65.250.193 
route add -net 112.132.0.0/16 gw 112.65.250.193 
route add -net 112.192.0.0/14 gw 112.65.250.193 
route add -net 112.224.0.0/11 gw 112.65.250.193 
route add -net 112.64.0.0/15 gw 112.65.250.193 
route add -net 112.80.0.0/13 gw 112.65.250.193 
route add -net 112.88.0.0/13 gw 112.65.250.193 
route add -net 112.96.0.0/15 gw 112.65.250.193 
route add -net 113.0.0.0/13 gw 112.65.250.193 
route add -net 113.194.0.0/15 gw 112.65.250.193 
route add -net 113.200.0.0/15 gw 112.65.250.193 
route add -net 113.204.0.0/14 gw 112.65.250.193 
route add -net 113.224.0.0/12 gw 112.65.250.193 
route add -net 113.56.0.0/15 gw 112.65.250.193 
route add -net 113.58.0.0/16 gw 112.65.250.193 
route add -net 113.59.0.0/17 gw 112.65.250.193 
route add -net 113.8.0.0/15 gw 112.65.250.193 
route add -net 114.240.0.0/12 gw 112.65.250.193 
route add -net 115.46.0.0/16 gw 112.65.250.193 
route add -net 115.48.0.0/12 gw 112.65.250.193 
route add -net 115.85.192.0/18 gw 112.65.250.193 
route add -net 116.112.0.0/14 gw 112.65.250.193 
route add -net 116.116.0.0/15 gw 112.65.250.193 
route add -net 116.2.0.0/15 gw 112.65.250.193 
route add -net 116.95.0.0/16 gw 112.65.250.193 
route add -net 117.8.0.0/13 gw 112.65.250.193 
route add -net 118.212.0.0/16 gw 112.65.250.193 
route add -net 118.72.0.0/13 gw 112.65.250.193 
route add -net 118.80.0.0/15 gw 112.65.250.193 
route add -net 119.108.0.0/15 gw 112.65.250.193 
route add -net 119.112.0.0/13 gw 112.65.250.193 
route add -net 119.162.0.0/15 gw 112.65.250.193 
route add -net 119.164.0.0/14 gw 112.65.250.193 
route add -net 119.176.0.0/12 gw 112.65.250.193 
route add -net 119.248.0.0/14 gw 112.65.250.193 
route add -net 119.36.0.0/16 gw 112.65.250.193 
route add -net 119.39.0.0/16 gw 112.65.250.193 
route add -net 119.4.0.0/14 gw 112.65.250.193 
route add -net 119.48.0.0/13 gw 112.65.250.193 
route add -net 119.62.0.0/16 gw 112.65.250.193 
route add -net 120.0.0.0/12 gw 112.65.250.193 
route add -net 120.80.0.0/13 gw 112.65.250.193 
route add -net 121.16.0.0/13 gw 112.65.250.193 
route add -net 121.24.0.0/14 gw 112.65.250.193 
route add -net 121.28.0.0/15 gw 112.65.250.193 
route add -net 121.30.0.0/16 gw 112.65.250.193 
route add -net 121.31.0.0/16 gw 112.65.250.193 
route add -net 122.136.0.0/13 gw 112.65.250.193 
route add -net 122.156.0.0/14 gw 112.65.250.193 
route add -net 122.192.0.0/14 gw 112.65.250.193 
route add -net 122.96.0.0/15 gw 112.65.250.193 
route add -net 123.112.0.0/12 gw 112.65.250.193 
route add -net 123.128.0.0/13 gw 112.65.250.193 
route add -net 123.138.0.0/15 gw 112.65.250.193 
route add -net 123.144.0.0/14 gw 112.65.250.193 
route add -net 123.148.0.0/16 gw 112.65.250.193 
route add -net 123.152.0.0/13 gw 112.65.250.193 
route add -net 123.188.0.0/14 gw 112.65.250.193 
route add -net 123.232.0.0/14 gw 112.65.250.193 
route add -net 123.4.0.0/14 gw 112.65.250.193 
route add -net 123.8.0.0/13 gw 112.65.250.193 
route add -net 124.128.0.0/13 gw 112.65.250.193 
route add -net 124.160.0.0/16 gw 112.65.250.193 
route add -net 124.161.0.0/16 gw 112.65.250.193 
route add -net 124.162.0.0/16 gw 112.65.250.193 
route add -net 124.163.0.0/16 gw 112.65.250.193 
route add -net 124.164.0.0/14 gw 112.65.250.193 
route add -net 124.64.0.0/15 gw 112.65.250.193 
route add -net 124.66.0.0/17 gw 112.65.250.193 
route add -net 124.67.0.0/16 gw 112.65.250.193 
route add -net 124.88.0.0/16 gw 112.65.250.193 
route add -net 124.89.0.0/17 gw 112.65.250.193 
route add -net 124.89.128.0/17 gw 112.65.250.193 
route add -net 124.90.0.0/15 gw 112.65.250.193 
route add -net 124.92.0.0/14 gw 112.65.250.193 
route add -net 125.211.0.0/16 gw 112.65.250.193 
route add -net 125.32.0.0/16 gw 112.65.250.193 
route add -net 125.33.0.0/16 gw 112.65.250.193 
route add -net 125.34.0.0/16 gw 112.65.250.193 
route add -net 125.35.0.0/17 gw 112.65.250.193 
route add -net 125.35.128.0/17 gw 112.65.250.193 
route add -net 125.36.0.0/14 gw 112.65.250.193 
route add -net 125.40.0.0/13 gw 112.65.250.193 
route add -net 175.42.0.0/15 gw 112.65.250.193 
route add -net 202.102.128.0/21 gw 112.65.250.193 
route add -net 202.102.136.0/21 gw 112.65.250.193 
route add -net 202.102.144.0/20 gw 112.65.250.193 
route add -net 202.102.224.0/21 gw 112.65.250.193 
route add -net 202.102.232.0/21 gw 112.65.250.193 
route add -net 202.102.240.0/20 gw 112.65.250.193 
route add -net 202.106.0.0/16 gw 112.65.250.193 
route add -net 202.107.0.0/17 gw 112.65.250.193 
route add -net 202.108.0.0/16 gw 112.65.250.193 
route add -net 202.110.0.0/18 gw 112.65.250.193 
route add -net 202.110.192.0/18 gw 112.65.250.193 
route add -net 202.110.64.0/18 gw 112.65.250.193 
route add -net 202.111.128.0/19 gw 112.65.250.193 
route add -net 202.130.224.0/19 gw 112.65.250.193 
route add -net 202.38.143.0/24 gw 112.65.250.193 
route add -net 202.96.0.0/18 gw 112.65.250.193 
route add -net 202.96.64.0/21 gw 112.65.250.193 
route add -net 202.96.72.0/21 gw 112.65.250.193 
route add -net 202.96.80.0/20 gw 112.65.250.193 
route add -net 202.97.128.0/18 gw 112.65.250.193 
route add -net 202.97.192.0/19 gw 112.65.250.193 
route add -net 202.97.224.0/21 gw 112.65.250.193 
route add -net 202.97.232.0/21 gw 112.65.250.193 
route add -net 202.97.240.0/20 gw 112.65.250.193 
route add -net 202.98.0.0/21 gw 112.65.250.193 
route add -net 202.98.8.0/21 gw 112.65.250.193 
route add -net 202.99.0.0/18 gw 112.65.250.193 
route add -net 202.99.112.0/20 gw 112.65.250.193 
route add -net 202.99.128.0/19 gw 112.65.250.193 
route add -net 202.99.160.0/21 gw 112.65.250.193 
route add -net 202.99.168.0/21 gw 112.65.250.193 
route add -net 202.99.176.0/20 gw 112.65.250.193 
route add -net 202.99.192.0/21 gw 112.65.250.193 
route add -net 202.99.200.0/21 gw 112.65.250.193 
route add -net 202.99.208.0/20 gw 112.65.250.193 
route add -net 202.99.224.0/21 gw 112.65.250.193 
route add -net 202.99.232.0/21 gw 112.65.250.193 
route add -net 202.99.240.0/20 gw 112.65.250.193 
route add -net 202.99.64.0/19 gw 112.65.250.193 
route add -net 202.99.96.0/21 gw 112.65.250.193 
route add -net 203.93.192.0/18 gw 112.65.250.193 
route add -net 203.93.64.0/18 gw 112.65.250.193 
route add -net 203.93.8.0/24 gw 112.65.250.193 
route add -net 210.13.0.0/18 gw 112.65.250.193 
route add -net 210.13.128.0/17 gw 112.65.250.193 
route add -net 210.13.64.0/18 gw 112.65.250.193 
route add -net 210.14.160.0/19 gw 112.65.250.193 
route add -net 210.14.192.0/19 gw 112.65.250.193 
route add -net 210.15.128.0/18 gw 112.65.250.193 
route add -net 210.15.32.0/19 gw 112.65.250.193 
route add -net 210.15.96.0/19 gw 112.65.250.193 
route add -net 210.21.0.0/17 gw 112.65.250.193 
route add -net 210.51.0.0/16 gw 112.65.250.193 
route add -net 210.52.128.0/17 gw 112.65.250.193 
route add -net 210.53.0.0/17 gw 112.65.250.193 
route add -net 210.53.128.0/17 gw 112.65.250.193 
route add -net 210.74.128.0/19 gw 112.65.250.193 
route add -net 210.74.96.0/19 gw 112.65.250.193 
route add -net 210.78.0.0/19 gw 112.65.250.193 
route add -net 210.78.160.0/19 gw 112.65.250.193 
route add -net 210.78.192.0/18 gw 112.65.250.193 
route add -net 210.82.0.0/15 gw 112.65.250.193 
route add -net 211.144.0.0/15 gw 112.65.250.193 
route add -net 211.90.0.0/15 gw 112.65.250.193 
route add -net 211.92.0.0/15 gw 112.65.250.193 
route add -net 211.94.0.0/15 gw 112.65.250.193 
route add -net 211.96.0.0/15 gw 112.65.250.193 
route add -net 218.10.0.0/16 gw 112.65.250.193 
route add -net 218.104.0.0/17 gw 112.65.250.193 
route add -net 218.104.128.0/19 gw 112.65.250.193 
route add -net 218.104.160.0/19 gw 112.65.250.193 
route add -net 218.104.192.0/21 gw 112.65.250.193 
route add -net 218.104.200.0/21 gw 112.65.250.193 
route add -net 218.104.208.0/20 gw 112.65.250.193 
route add -net 218.104.224.0/19 gw 112.65.250.193 
route add -net 218.105.0.0/16 gw 112.65.250.193 
route add -net 218.106.0.0/15 gw 112.65.250.193 
route add -net 218.11.0.0/16 gw 112.65.250.193 
route add -net 218.12.0.0/16 gw 112.65.250.193 
route add -net 218.21.128.0/17 gw 112.65.250.193 
route add -net 218.24.0.0/15 gw 112.65.250.193 
route add -net 218.26.0.0/16 gw 112.65.250.193 
route add -net 218.27.0.0/16 gw 112.65.250.193 
route add -net 218.28.0.0/15 gw 112.65.250.193 
route add -net 218.56.0.0/14 gw 112.65.250.193 
route add -net 218.60.0.0/15 gw 112.65.250.193 
route add -net 218.67.128.0/17 gw 112.65.250.193 
route add -net 218.68.0.0/15 gw 112.65.250.193 
route add -net 218.7.0.0/16 gw 112.65.250.193 
route add -net 218.8.0.0/15 gw 112.65.250.193 
route add -net 219.154.0.0/15 gw 112.65.250.193 
route add -net 219.156.0.0/15 gw 112.65.250.193 
route add -net 219.158.0.0/17 gw 112.65.250.193 
route add -net 219.158.128.0/17 gw 112.65.250.193 
route add -net 219.159.0.0/18 gw 112.65.250.193 
route add -net 220.192.0.0/15 gw 112.65.250.193 
route add -net 220.194.0.0/15 gw 112.65.250.193 
route add -net 220.196.0.0/14 gw 112.65.250.193 
route add -net 220.200.0.0/13 gw 112.65.250.193 
route add -net 220.248.0.0/14 gw 112.65.250.193 
route add -net 220.252.0.0/16 gw 112.65.250.193 
route add -net 221.0.0.0/15 gw 112.65.250.193 
route add -net 221.10.0.0/16 gw 112.65.250.193 
route add -net 221.11.0.0/17 gw 112.65.250.193 
route add -net 221.11.128.0/18 gw 112.65.250.193 
route add -net 221.11.192.0/19 gw 112.65.250.193 
route add -net 221.11.224.0/19 gw 112.65.250.193 
route add -net 221.12.0.0/17 gw 112.65.250.193 
route add -net 221.12.128.0/18 gw 112.65.250.193 
route add -net 221.13.0.0/18 gw 112.65.250.193 
route add -net 221.13.128.0/17 gw 112.65.250.193 
route add -net 221.13.64.0/19 gw 112.65.250.193 
route add -net 221.13.96.0/19 gw 112.65.250.193 
route add -net 221.14.0.0/15 gw 112.65.250.193 
route add -net 221.192.0.0/15 gw 112.65.250.193 
route add -net 221.194.0.0/16 gw 112.65.250.193 
route add -net 221.195.0.0/16 gw 112.65.250.193 
route add -net 221.196.0.0/15 gw 112.65.250.193 
route add -net 221.198.0.0/16 gw 112.65.250.193 
route add -net 221.199.0.0/19 gw 112.65.250.193 
route add -net 221.199.128.0/18 gw 112.65.250.193 
route add -net 221.199.192.0/20 gw 112.65.250.193 
route add -net 221.199.224.0/19 gw 112.65.250.193 
route add -net 221.199.32.0/20 gw 112.65.250.193 
route add -net 221.199.48.0/20 gw 112.65.250.193 
route add -net 221.199.64.0/18 gw 112.65.250.193 
route add -net 221.2.0.0/16 gw 112.65.250.193 
route add -net 221.200.0.0/14 gw 112.65.250.193 
route add -net 221.204.0.0/15 gw 112.65.250.193 
route add -net 221.206.0.0/16 gw 112.65.250.193 
route add -net 221.207.0.0/18 gw 112.65.250.193 
route add -net 221.207.128.0/17 gw 112.65.250.193 
route add -net 221.207.64.0/18 gw 112.65.250.193 
route add -net 221.208.0.0/14 gw 112.65.250.193 
route add -net 221.212.0.0/16 gw 112.65.250.193 
route add -net 221.213.0.0/16 gw 112.65.250.193 
route add -net 221.214.0.0/15 gw 112.65.250.193 
route add -net 221.216.0.0/13 gw 112.65.250.193 
route add -net 221.3.0.0/17 gw 112.65.250.193 
route add -net 221.3.128.0/17 gw 112.65.250.193 
route add -net 221.4.0.0/16 gw 112.65.250.193 
route add -net 221.5.0.0/17 gw 112.65.250.193 
route add -net 221.5.128.0/17 gw 112.65.250.193 
route add -net 221.6.0.0/16 gw 112.65.250.193 
route add -net 221.7.0.0/19 gw 112.65.250.193 
route add -net 221.7.128.0/17 gw 112.65.250.193 
route add -net 221.7.32.0/19 gw 112.65.250.193 
route add -net 221.7.64.0/19 gw 112.65.250.193 
route add -net 221.7.96.0/19 gw 112.65.250.193 
route add -net 221.8.0.0/15 gw 112.65.250.193 
route add -net 222.128.0.0/14 gw 112.65.250.193 
route add -net 222.132.0.0/14 gw 112.65.250.193 
route add -net 222.136.0.0/13 gw 112.65.250.193 
route add -net 222.160.0.0/15 gw 112.65.250.193 
route add -net 222.162.0.0/16 gw 112.65.250.193 
route add -net 222.163.0.0/19 gw 112.65.250.193 
route add -net 222.163.128.0/17 gw 112.65.250.193 
route add -net 222.163.32.0/19 gw 112.65.250.193 
route add -net 222.163.64.0/18 gw 112.65.250.193 
route add -net 27.36.0.0/14 gw 112.65.250.193 
route add -net 58.144.0.0/16 gw 112.65.250.193 
route add -net 58.16.0.0/16 gw 112.65.250.193 
route add -net 58.17.0.0/17 gw 112.65.250.193 
route add -net 58.17.128.0/17 gw 112.65.250.193 
route add -net 58.18.0.0/16 gw 112.65.250.193 
route add -net 58.19.0.0/16 gw 112.65.250.193 
route add -net 58.20.0.0/16 gw 112.65.250.193 
route add -net 58.21.0.0/16 gw 112.65.250.193 
route add -net 58.22.0.0/15 gw 112.65.250.193 
route add -net 58.240.0.0/15 gw 112.65.250.193 
route add -net 58.242.0.0/15 gw 112.65.250.193 
route add -net 58.244.0.0/15 gw 112.65.250.193 
route add -net 58.246.0.0/15 gw 112.65.250.193 
route add -net 58.248.0.0/13 gw 112.65.250.193 
route add -net 60.0.0.0/13 gw 112.65.250.193 
route add -net 60.10.0.0/16 gw 112.65.250.193 
route add -net 60.11.0.0/16 gw 112.65.250.193 
route add -net 60.12.0.0/16 gw 112.65.250.193 
route add -net 60.13.0.0/18 gw 112.65.250.193 
route add -net 60.13.128.0/17 gw 112.65.250.193 
route add -net 60.13.64.0/18 gw 112.65.250.193 
route add -net 60.14.0.0/15 gw 112.65.250.193 
route add -net 60.16.0.0/13 gw 112.65.250.193 
route add -net 60.208.0.0/13 gw 112.65.250.193 
route add -net 60.216.0.0/15 gw 112.65.250.193 
route add -net 60.218.0.0/15 gw 112.65.250.193 
route add -net 60.220.0.0/14 gw 112.65.250.193 
route add -net 60.24.0.0/14 gw 112.65.250.193 
route add -net 60.28.0.0/15 gw 112.65.250.193 
route add -net 60.30.0.0/16 gw 112.65.250.193 
route add -net 60.31.0.0/16 gw 112.65.250.193 
route add -net 60.8.0.0/15 gw 112.65.250.193 
route add -net 61.133.0.0/17 gw 112.65.250.193 
route add -net 61.134.128.0/18 gw 112.65.250.193 
route add -net 61.134.192.0/18 gw 112.65.250.193 
route add -net 61.134.96.0/19 gw 112.65.250.193 
route add -net 61.135.0.0/16 gw 112.65.250.193 
route add -net 61.136.64.0/18 gw 112.65.250.193 
route add -net 61.137.128.0/17 gw 112.65.250.193 
route add -net 61.138.0.0/18 gw 112.65.250.193 
route add -net 61.138.128.0/18 gw 112.65.250.193 
route add -net 61.138.64.0/18 gw 112.65.250.193 
route add -net 61.139.128.0/18 gw 112.65.250.193 
route add -net 61.148.0.0/15 gw 112.65.250.193 
route add -net 61.156.0.0/16 gw 112.65.250.193 
route add -net 61.158.0.0/17 gw 112.65.250.193 
route add -net 61.158.128.0/17 gw 112.65.250.193 
route add -net 61.159.0.0/18 gw 112.65.250.193 
route add -net 61.161.0.0/18 gw 112.65.250.193 
route add -net 61.161.128.0/17 gw 112.65.250.193 
route add -net 61.162.0.0/16 gw 112.65.250.193 
route add -net 61.163.0.0/16 gw 112.65.250.193 
route add -net 61.167.0.0/16 gw 112.65.250.193 
route add -net 61.168.0.0/16 gw 112.65.250.193 
route add -net 61.176.0.0/16 gw 112.65.250.193 
route add -net 61.179.0.0/16 gw 112.65.250.193 
route add -net 61.180.128.0/17 gw 112.65.250.193 
route add -net 61.181.0.0/16 gw 112.65.250.193 
route add -net 61.182.0.0/16 gw 112.65.250.193 
route add -net 61.189.0.0/17 gw 112.65.250.193 
route add -net 61.240.0.0/14 gw 112.65.250.193 
route add -net 61.48.0.0/14 gw 112.65.250.193 
route add -net 61.52.0.0/15 gw 112.65.250.193 
route add -net 61.54.0.0/16 gw 112.65.250.193 
route add -net 61.55.0.0/16 gw 112.65.250.193

linux配置双线策略

标签:

原文地址:http://www.cnblogs.com/quyanan/p/4527511.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!