Welcome 微信登录

首页 / 操作系统 / Linux / Linux 使用 ip route , ip rule , iptables 配置策略路由

公司内网要求192.168.0.100以内的使用 10.0.0.1 网关上网(电信),其他IP使用 20.0.0.1 (网通)上网。首先要在网关服务器上添加一个默认路由,当然这个指向是绝大多数的IP的出口网关。ip route add default gw 20.0.0.1之后通过 ip route 添加一个路由表ip route add table 3 via 10.0.0.1 dev ethX (ethx是10.0.0.1所在的网卡,3 是路由表的编号)之后添加 ip  rule 规则ip rule add fwmark 3  table 3 (fwmark 3是标记,table 3 是路由表3 上边。 意思就是凡事标记了 3 的数据使用table3 路由表)之后使用iptables给相应的数据打上标记iptables -A PREROUTING -t mangle -i eth0 -s 192.168.0.1 -192.168.0.100 -j MARK --set-mark 3因为mangle的处理是优先于 nat 和fiter表的,所以相依数据包到达之后先打上标记,之后在通过ip rule规则,对应的数据包使用相应的路由表进行路由,最后读取路由表信息,将数据包送出网关。Linux Route 的一般用法Linux下的串口系列---struct termios结构体相关资讯      Linux Iptables  iptables路由 
  • Linux pptpd 的 iptables 包过滤设  (09/29/2014 09:12:19)
  • Linux用iptables实现网站访问重定  (08/17/2013 14:08:37)
  • 关于Linux下的iptables 的浅析命令  (03/27/2013 14:44:28)
  • Linux iptables的简单用法  (11/26/2013 16:31:17)
  • Linux下为iptables增加layer7补丁(  (08/10/2013 16:36:28)
  • Linux的iptables脚本说明  (12/24/2007 13:23:57)
本文评论 查看全部评论 (0)
表情: 姓名: 字数
版权所有©石家庄振强科技有限公司2024 冀ICP备08103738号-5 网站地图