找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 10324|回复: 11

[iptables] 让iptables直接支持多isp接入和端口复制

[复制链接]
发表于 2005-2-23 19:21:18 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×
要想linux支持策略路由,通常的做法是用iptalbes中的MARK命令给特定的数据包打上标记,然后用iproute包中ip这个工具指定有标记的数据包通过指定的路由表。今天下午仔细看了下iptables的帮助文件,发现了一个很重要的netfilter功能包.名字叫ROUTE.它包含在patch-o-matic 补丁中,给内核打上这个补丁后,就可以在iptalbes的命令中直接支持策略路由.而且还有一个很重要的功能.我的理解就是端口镜像吧.就是可以将一张网卡上的特定目的地址特定端口的数据包做个副本copy到另一张网卡上.这个功能可能在网吧用得上。因为GA都要在网吧安装网络监控系统如(任子行)等。必须接在集线器上,任子行才能进行监控。由于任子行是通过将网卡设置为混杂模式进行监控,那样的话会大幅降低网络速度。如果将通过ROUTE 复制所需要的数据给任子行,就不需要集线器了,同时也可以提高网络效率。
routeros
 楼主| 发表于 2005-2-23 19:23:18 | 显示全部楼层
QUOTE
This option adds a `ROUTE' target, which enables you to setup unusual  routes. For example, the ROUTE lets you route a received packet through   an interface or towards a host, even if the regular destination of the   packet is the router itself. The ROUTE target is also able to change the   incoming interface of a packet.  The target can be or not a final target. It has to be used inside the   mangle table.  ROUTE target options:  --oif   ifname    Send the packet out using `ifname' network interface.  --iif   ifname    Change the packet's incoming interface to `ifname'.  --gw    ip        Route the packet via this gateway.  --continue        Route the packet and continue traversing the rules.  --tee             Route a copy of the packet, but continue traversing                    the rules with the original packet, undisturbed.  Note that --iif, --continue, and --tee, are mutually exclusive.  Examples :  # To force all outgoing icmp packet to go through the eth1 interface   # (final target) :  iptables -A POSTROUTING -t mangle -p icmp -j ROUTE --oif eth1   # To tunnel outgoing http packets and continue traversing the rules :  iptables -A POSTROUTING -t mangle -p tcp --dport 80 -j ROUTE --oif tunl1 --continue   # To forward all ssh packets to gateway w.x.y.z, and continue traversing  # the rules :  iptables -A POSTROUTING -t mangle -p tcp --dport 22 -j ROUTE --gw w.x.y.z --continue   # To change the incoming network interface from eth0 to eth1 for all icmp  # packets (final target) :  iptables -A PREROUTING -t mangle -p icmp -i eth0 -j ROUTE --iif eth1  # To copy (duplicate) all traffic from and to a local ECHO server  # to a second box (nonfinal target)  iptables -A PREROUTING -t mangle -p tcp --dport 7 -j ROUTE --gw 1.2.3.4 --tee  iptables -A POSTROUTING -t mangle -p tcp --sport 7 -j ROUTE --gw 1.2.3.4 --tee
routeros
回复

使用道具 举报

 楼主| 发表于 2005-2-24 08:48:57 | 显示全部楼层
ROUTE target options:  --oif   ifname    通过`ifname' 网络界面发送数据包  --iif   ifname    改变包进入的网络界面到`ifname'.  --gw    ip        通过这个网关来路由这个包  --continue        路由这个包并继续穿越后面的规则  --tee             Route a copy of the packet, but continue traversing                    the rules with the original packet, undisturbed.  注意 --iif, --continue, and --tee, 是互相排斥的。  例子:   iptables -A POSTROUTING -t mangle -p icmp -j ROUTE --oif eth1 强制所有的流出icmp包通过eth1界面    iptables -A POSTROUTING -t mangle -p tcp --dport 80 -j ROUTE --oif tunl1 --continue 强制流出的http包通过tunl1并继续后面的规则   iptables -A POSTROUTING -t mangle -p tcp --dport 22 -j ROUTE --gw w.x.y.z --continue 转发所有的ssh包到网关w.x.y.z,同时穿越规则  iptables -A PREROUTING -t mangle -p icmp -i eth0 -j ROUTE --iif eth1改变进入网络界面eth0所有的icmp包到eth1上  iptables -A PREROUTING -t mangle -p tcp --dport 7 -j ROUTE --gw 1.2.3.4 --tee  iptables -A POSTROUTING -t mangle -p tcp --sport 7 -j ROUTE --gw 1.2.3.4 --tee复制(镜像)特定源和目的地址的流量到本地的一个ECHO 服务器
routeros
回复

使用道具 举报

发表于 2005-2-24 11:40:09 | 显示全部楼层
天~~,就需要这东西呢。gated成了商业软件,连华为都买了它的许可。我都不知道用什么做了。谢谢老大。包在哪儿下?
routeros
回复

使用道具 举报

 楼主| 发表于 2005-2-24 12:21:00 | 显示全部楼层
http://ftp.netfilter.org/pub/patch-o-matic...0050223.tar.bz2
routeros
回复

使用道具 举报

发表于 2005-2-24 15:19:55 | 显示全部楼层
thanks~一直没怎么看这个站点。
routeros
回复

使用道具 举报

发表于 2005-2-25 15:28:50 | 显示全部楼层
patch-o里还有n多好东东!iplimit限制同一ip连接数量,iprate限制速率,这下可以不用TC了!还有n多,我都记不清了,但我没在Fedora core3成功编译核心  哪天有空了在Redhat AS4再来试试.
routeros
回复

使用道具 举报

发表于 2005-2-26 00:00:30 | 显示全部楼层
没有看懂,呵呵,:说笑。。。好东西收藏。。。顺便做到 IPCOP 里去,编译内核我不怎么会,还是请老大做做哈。
routeros
回复

使用道具 举报

发表于 2005-2-26 13:08:21 | 显示全部楼层
老大。。。这句话不太明白。。

QUOTE
and continue traversing the rules
字面的意思是继续通过(穿越)规则。到底是继续应用后面的规则还是略过后面的规则?我感觉应该是继续应用后面的规则。
routeros
回复

使用道具 举报

发表于 2006-3-6 09:57:00 | 显示全部楼层
不知是用来干什么的
顶了再说
routeros
回复

使用道具 举报

发表于 2006-3-6 10:08:50 | 显示全部楼层

回复 #1 想得太美 的帖子

我现在正在编译ROUTE模块,也是这样想的.估计两个一个钟头后就可以得到该模块了.
准本建立文件夹   http://219.223.96.9/wuhuashan 名字为" 测试开发区 ",提供给做试验的朋友下载.
感谢提供资料.
routeros
回复

使用道具 举报

发表于 2006-3-6 10:39:43 | 显示全部楼层

回复 #11 aijun 的帖子

已经编译出来了,爱好者可以做试验,仅供参考.
routeros
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|小黑屋|软路由 ( 渝ICP备15001194号-1|渝公网安备 50011602500124号 )

GMT+8, 2024-5-2 07:49 , Processed in 0.064715 second(s), 4 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表