星期二, 三月 13, 2007

在路由器封BT方法大全

最近为了封BT,几乎把NBO的网络论坛找遍了,呵呵,实验了几种方法,得出几个结论(说实话,也就是把网上的方法总结小小一把),
第一是常用的封端口的方法:
呵呵,常用的命令如下:

1限速∶
access-list 102 permit tcp any any range 6881 6890
access-list 102 permit tcp any range 6881 6890 any
access-list 102 deny ip any any

rate-limit input access-group 102 712000 8000 8000 conform-action transmit exceed-action drop
rate-limit output access-group 102 712000 8000 8000 conform-action transmit exceed-action drop

2禁止∶
access-list 102 deny tcp any any range 6881 6890
access-list 102 deny tcp any range 6881 6890 any
access-list 102 permit ip any any

这种方法有其局限性,一是现在有的bt软件,再封锁后会自动改端口二是我仔细研究过好几个BT下载软件,它们现在的announce端口现在已经用8000、8080的说,如果连这个也封,那网络使用就有可能不正常(我这样做过,呵呵,后来N多人打电话找我,吓得我马上DEL掉了)

第二种方法:就是用NBAR (Network-Based Application Recognition)网络应用识别
NBAR是一种动态能在四到七层寻找协议的技术,它不但能做到普通ACL能做到那样控制静态的TCP UDP的报,也能做到控制一般ACLs不能做到动态的端口的那些协议(如BT)之类.
NBAR包含了一种叫做发现特征的协议(a Protocol Discovery feature ),用它可以轻易发现那些不能传输过程中的应用协议,它能端口上做到进出流量统计\流速统计,最重要的它还有一种叫做
An external Packet Description Language Module (PDLM)的文件用来扩展NBAR识别的协议。(具体我也翻译不出来,只看了个大概),
我就说说过程:
1到http://www.cisco.com/pcgi-bin/tablebuild.pl/pdlm 下载bittorrent.pdlm,(要CCO的)
2放到TFTP,然后用copy tftp disk2(大多数应该是flash)
拷到路由器中,
route7206#conf t
Enter configuration commands, one per line. End with CNTL/Z.
route7206(config)#ip nbar pdlm bittorrent.pdlm
route7206(config)#

!
ip nbar pdlm bittorrent.pdlm
!

1.) 创建一个 a class-map and policy map 并且把它应用到相应的端口:

route7206(config)#ip nbar
route7206(config)#ip nbar pd
route7206(config)#ip nbar pdlm bitt
route7206(config)#ip nbar pdlm bittorrent.pdlm
route7206(config)#class-map match-all bittorrent
route7206(config-cmap)#match proto
route7206(config-cmap)#match protocol bittorrent
route7206(config-cmap)#polic
route7206(config-cmap)#policy-map bittorrent-policy
route7206(config-pmap)#class bittorrent
route7206(config-pmap-c)#drop
route7206(config-pmap-c)#exit
route7206(config-pmap)#exit
route7206(config)#interface GigabitEthernet0/2
route7206(config-if)#servi
route7206(config-if)#service-policy input bi
route7206(config-if)#service-policy input bittoreent-policy
% policy map bittoreent-policy not configured
route7206(config-if)#service-policy input bittorrent-policy
route7206(config-if)#service-policy output bittorrent-policy


#show runn
得到关于BT的部分是
class-map match-all bittorrent
match protocol bittorrent
!
!
policy-map bittorrent-policy
class bittorrent
drop
!
interface GigabitEthernet0/2
description CONNECT INSIDE
ip address 192.168.168.1 255.255.255.252 secondary
ip address 192.168.21.1 255.255.255.0
ip nat inside
[B]service-policy input bittorrent-policy
service-policy output bittorrent-policy[/B]
duplex full
speed 1000
media-type rj45
no negotiation auto

我实验了一下,这样的话,BT就不能下载,呵呵
感觉目前这样的技术比较好,我正在实验去掉EMULE的方法,

没有评论: