LINUX设置策略路由

回复 收藏
1)添加路由表

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

252 tel   #电信路由表
251 cnc   #网通路由表


2)vi /etc/iproute.sh
#!/bin/sh
ip route flush table tel
ip route add default via 61.7.69.65(IP网关) dev eth0 src 61.7.69.105(ip地址) table tel
ip rule add from 61.7.69.105(ip地址) table tel

ip route flush table cnc
ip route add default via 21.6.167.1 dev eth1 src 21.6.167.51(ip地址) table cnc
ip rule add from 21.6.167.51(ip地址) table cnc

注意:括号里的只是一个提示,实际操作的时候记得去掉。

3 vi /etc/wtiproute.sh
#把附件路由表里的内容复制进来,但是一定要记得 gw后面的网关一定要改写成你所在网络环境的联通网关。

4)chmod 775 /etc/iproute.sh
5)chmod 775 /etc/wtiproute.sh

6)/etc/iproute.sh
v
7)/etc/wtiproute.sh

8))修改vi /etc/sysctl.conf文件,

#net.ipv4.conf.default.rp_filter=1
#net.ipv4.conf.all.rp_filter=1

改为
net.ipv4.conf.default.rp_filter=0
net.ipv4.conf.all.rp_filter=0

备注:如果前面有#要记得去掉,如果前面没有#,直接修改,保存即可


9)vi /etc/rc.local
/etc/iproute.sh
/etc/wtiproute.sh


10)验证
route
或路由
traceroute 210.52.223.1

2016-01-23 11:50 举报
已邀请:
0

kevin_tao

赞同来自:

看视频,windows上的大概是懂了,但是这里的不太懂这些文件的作用。。。感觉没有思科基础其实都不太好理解

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: