发新话题
打印

[原创] 利用nbar+pdlm禁止BT

本主题由 hefei 于 2008-2-4 19:55 审核通过

利用nbar+pdlm禁止BT

通过 TFTP 服务器将 bittorrent.pdlm 拷贝到路由中。利用

ip nbar pdlm bittorrent.pdlm

命令将 NBAR 中的 BT 功能启动。

再创建一个 class-map 和 policy map 并且把它应用到相应的路由器的接口上。一般是 连接 Internet (Chinanet ) 的接口是 FastEthernet 或 10M 的以太网接口。在路由器上您可以看见如下的配置 :

class-map match-all bittorrent

match protocol bittorrent

!

!

policy-map bittorrent-policy

class bittorrent

drop

!

interface FastEthernet0/

description neibujiekou

ip address 192.168.0.1 255.255.255.0

ip nat inside

service-policy input bittorrent-policy

service-policy output bittorrent-policy cisco router 用NABR 封阻 BT 流量.

由于BT的出现,互连网上流量排第一位的已经不是80 http,而是BT , KAZAA2,和EDONKEY,而且进入和流出的流量已经几乎相等.BT等下载软件占用了大量出口带宽,带宽就是成本,就是金钱,对此ISP们非常头痛.

控制BT流量,在网络层无非就是封端口.没有其他办法,由于BT的端口变化比较大,如果用ACL封端口则比较费力,又占用路由器CPU资源.但在cisco路由器上可以用pdlm软件及NBAR可以很方便的封阻BT流量.针对不同的流量,三个pdlm软件分别是 eDonkey.pdlm,fasttrack.pdlm,kazaa2.pdlm.

经过测试,效果非常理想.

须注意的是:如果想要指定BT的带宽,会给路由器带来很大的负载 我用是72 GE 负载在99%--100%.所以干脆直接封了比较好.

配置之前,建议先将上面所说的三个软件上传到路由器的flash卡里.

-rw- 3471 Nov 25 2004 21:40:26 eDonkey.pdlm

-rw- 1822 Nov 29 2004 00:41:52 fasttrack.pdlm

-rw- 1712 Nov 29 2004 19:59:50 kazaa2.pdlm



下面是关于用NBAR 封BT的相关配置.

.......

ip nbar pdlm kazaa2.pdlm

ip nbar pdlm bittorrent.pdlm

ip nbar pdlm eDonkey.pdlm

!

.......

class-map match-any bit

match protocol kazaa2

match protocol bittorrent

match protocol edonkey

!

.........

policy-map limit-bit

class bit

drop

!

interface GigabitEthernet0/2



service-policy input limit-bit

service-policy output limit-bit这是一人基于PDLM封BT的实例,







show run

Building configuration...



Current configuration : 2677 bytes

!

! Last configuration change at 12:05:49 UTC Tue Mar 8 2005

! NVRAM config last updated at 12:05:59 UTC Tue Mar 8 2005

!

version 12.3

service timestamps debug datetime msec

service timestamps log datetime msec

no service password-encryption

!

hostname Router

!

boot-start-marker

boot-end-marker

!

!

no network-clock-participate slot 1

no network-clock-participate wic 0

no aaa new-model

ip subnet-zero

ip cef

!

ip nbar pdlm bittorrent.pdlm

!

!

no ftp-server write-enable

!

!

!

class-map match-all bittorrent

match protocol bittorrent

!

!

policy-map bittorrent-policy

class bittorrent

drop

!

!

!

interface FastEthernet0/0

ip address A.B.C.D 255.255.255.252

ip nat outside

service-policy input bittorrent-policy

service-policy output bittorrent-policy

duplex auto限制P2P总结:



目的:



1:防止外部攻击

2:过滤已知蠕虫和病毒

3:过滤已知P2P应用

4:限制未知病毒、蠕虫、攻击和p2p应用



防止外部攻击:采用硬件防火墙或IOS防火墙版本,效果是只能允许内部发起的连接,防止典型的DDoS攻击。



防止已知病毒、蠕虫:内网接口输入方向应用ACL,效果是大大减少了NAT转换量,减小路由器CPU和内存的资源消耗。



过滤已知p2p应用:采用NBAR和PDLM结合,效果是过滤掉已知p2p应用。p2p协议很多,配置如下:



class-map match-any p2p

description any p2p

match protocol bittorrent

match protocol gnutella

match protocol kazaa2

match protocol edonkey

match protocol fasttrack

match protocol napster

match protocol novadigm

match protocol pcanywhere

match protocol cuseeme

match protocol mgcp

match protocol winmx

match protocol skinny

match protocol sip

match protocol sap-pgm

match protocol sap-app

match protocol sap-msg



policy-map limit-d

class p2p

drop



interface Ethernet0/0

...

service-policy input limit-d

!

interface Ethernet0/1

...

service-policy output limit-d



注意:



1. 使用“show ip nbar port-map”命令查看当前IOS支持的协议,一般要求IOS 12.2(13)T以上,

2.下载以上这些pdlm文件到路由器上,使用“dir”命令检查是否已有

3. 使用如下的命令加载pdlm文件:



ip nbar pdlm flash:bittorrent.pdlm

ip nbar pdlm flash:eDonkey.pdlm

ip nbar pdlm flash:mgcp.pdlm

ip nbar pdlm flash:WinMX.pdlm

ip nbar pdlm flash:skinny.pdlm

ip nbar pdlm flash:sip.pdlm

ip nbar pdlm flash:sap-pgm.pdlm

ip nbar pdlm flash:sap-app.pdlm

ip nbar pdlm flash:sap-msg.pdlm



因为在IOS 12.2(13)T内已经内置了fasttrack等p2p支持。所以就不用以上的加载命令了。



注意,以上只能过滤掉已知的p2p,无法阻止未知的或变态的p2p应用。



限制未知的病毒、蠕虫、p2p应用:通常来说,由于TCP/UDP的低端端口主要被已知或著名的应用程序占用,多数蠕虫、病毒和p2p因为要动态产生目的端口,所以这些应用的包目的端口一般较大,例如,多数从3000~65535,所以为了不错杀一千,折中的方法是限速。例如:

class-map match-all d3000

match access-group name d3000

class-map match-all s3000

match access-group name s3000



policy-map limit-s

class p2p

drop

class s3000

police cir 200000 bc 1000 be 1000

conform-action drop

exceed-action drop

violate-action drop



policy-map limit-d

class p2p

drop

class d3000

police cir 200000 bc 1000 be 1000

conform-action drop

exceed-action drop

violate-action drop



ip access-list extended s3000

permit tcp any gt 3000 any

permit udp any gt 3000 any



ip access-list extended d3000

permit tcp any any gt 3000

permit udp any any gt 3000



应用于内网口和外网口,如何应用,略,自己动脑子。



具体限速多大可根据自己的网速调整。



此外,Cisco IOS 12.3T还提供了一种非常实用的特性:



按IP地址限制最大连接数:命令是:

ip nat translation max-entries {number | all-vrf number | host ip-address number | list listname

number | vrf name number}

此特性非常有用,可利用此特性限制每个IP的最大连接数,配合速率限制。应该很容易照顾多数人的利益。



只是注意:IOS 12.3T有平台限制,例如,Cisco 2610xm、3745等等。而且该软件较大,要注意你的路由器内存和flash容量是否够用。



以上特性,我就不给出完整配置文件了,各位可自己试试。路由上限制/禁止BT下载的设置∶



限速∶

access-list 130 remark bt

access-list 130 permit tcp any any range 6881 6890

access-list 130 permit tcp any range 6881 6890 any



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

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



禁止∶

access-list 130 deny tcp any any range 6881 6890 access-list 130 deny tcp any range 6881 6890 any



ip access-group 130 in / out

不过有的bt软件,再封锁后会自动改端口</!-></!->

TOP

测试过,只可以block标准的BT端口。

TOP

发新话题