linux 双线策略路由!!

bfz814 2010-04-09 11:32:32
网络环境

服务器(网关):
eth0 为LAN口,IP为 LAN_IP = 192.168.0.1
eth1 为第一个WAN口,接电信线路,IP为 CTC_IP,网关为 CTC_GW
eth2 为第二个WAN口,接网通线路,IP为 CNC_IP,网关为 CNC_GW

策略路由方式

为了方便,我们增加2个策略路由表,电信 => 100,网通 => 200,这样再添加规则时,就可以直接用自定义的名称来替代数字

echo "100 ctc" >> /etc/iproute2/rt_tables
echo "200 cnc" >> /etc/iproute2/rt_tables

1)设置默认路由(电信)
ip route replace default via 电信网关 dev eth1

2)对网通进行基于目的地址的策略路由
ip rule add to 网通路由表1 table cnc prio 100
ip rule add to 网通路由表2 table cnc prio 100
....

3)添加原路返回路由

ip route flush table ctc
ip route add default via 电信网关 dev eth1 src 电信IP table ctc
ip route add 192.168.0.0/24 dev eth0 scope link src 192.168.0.1 table ctc
ip rule add from 电信IP table ctc

ip route flush table cnc
ip route add default via 网通网关 dev eth2 src 网通IP table cnc
ip route add 192.168.0.0/24 dev eth0 scope link src 192.168.0.1 table ctc
ip rule add from 网通IP table cnc



请问:
ip route add default via 电信网关 dev eth1 src 电信IP table ctc
ip route add 192.168.0.0/24 dev eth0 scope link src 192.168.0.1 table ctc
ip rule add from 电信IP table ctc

这个句话有是意思? 它能起什么作用?
ip route add 192.168.0.0/24 dev eth0 scope link src 192.168.0.1 table ctc
...全文
249 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

19,612

社区成员

发帖
与我相关
我的任务
社区描述
系统使用、管理、维护问题。可以是Ubuntu, Fedora, Unix等等
社区管理员
  • 系统维护与使用区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧