基于网络的应用识别(NBARNetwork Based Application Recognition)实际上一个<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

分类引擎,它查看数据包,对数据包包含的信息进行分析。NBAR 使得路由器不仅要做转发

数据的工作,还要对数据包进行检查,这样会大大增加负载。NBAR 可以检查应用层的内容,

例如可以检查URL 是否有“.java”字样。NBAR 可以和许多QOS 配合使用。

NABR 的配置和CBWFQ 没什么差别,因为NBAR 实际上只是一个分类技术。我们这里将利

NBAR 来禁止BT edonkey 下载。如下:

R1(config)#class-map match-any BT

R1(config-cmap)#match protocol bittorrent

R1(config-cmap)#match protocol edonkey

//定义流量,匹配bittorrent edonkey

R1(config)#policy-map DENY-BT

R1(config-pmap)#class BT

R1(config-pmap-c)#drop

//定义策略,匹配bittorrent edonkey 的流量被丢弃

R1(config)#int s0/0/0

R1(config-if)#service-policy output DNEY-BT

【提示】在旧的IOS 中,class-map 模式下不能使用“match protocol bittorrent”等命

令,要先从Cisco 网站下载bittorrent.pdlm 等文件,上传到路由器上的FLASH 中,并使

用命令“ip nbar pdlm flash: bittorrent.pdlm”后,才能在class-map 模式下,使用“match

protocol bittorrent”命令。

【提示】NBAR 需要路由器启用CEF,默认时CEF 是开启的,如果没有开启,可以使用“ip cef

命令。

 

代码:

enable
config t
hostname R1
class-map bt
match protocol bittorrent
match protocol edonkey
exit
policy-map jinzhi
class bt
drop
exit
exit
int s1/0
ip add 192.168.3.1 255.255.255.0
service-policy output jinzhi
no shut
end
show running-config

 

 

R1#show running-config
Building configuration...

 

Current configuration : 1108 bytes
!
! Last configuration change at 17:16:08 UTC Sat Dec 12 2009
!
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R1
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
!
resource policy
!
ip cef     开启快速交换
class-map match-any bt   设置类
match protocol bittorrent
 match protocol edonkey
  policy-map jinzhi     设置类策略
 class bt
   drop
interface FastEthernet0/0
 no ip address
 shutdown
 duplex half
interface Serial1/0     把接口放置到策略下
 ip address 192.168.3.1 255.255.255.0
 serial restart-delay 0
 service-policy output jinzhi
interface Serial1/1
 no ip address
 shutdown
 serial restart-delay 0
interface Serial1/2
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial1/3
 no ip address
 shutdown
 serial restart-delay 0
!
interface FastEthernet2/0
 no ip address
 shutdown
 duplex half
!

no ip http server

no ip http secure-server

!
!
!
logging alarm informational
!
!
!
!
!
!
control-plane
!
!
!
!
!
!
gatekeeper
 shutdown
!
!
line con 0
 stopbits 1
line aux 0
line vty 0 4
!
!        
end
 
应用案例:使用思科的路由实现
禁止电驴和BT(  BT据说政策上给禁止了)
enable
config t
hostname R1
class-map bt
match protocol bittorrent
match protocol edonkey
exit
policy-map jinzhi
class bt
drop
exit
exit
int s1/0
ip add 192.168.3.1 255.255.255.0
service-policy output jinzhi
no shut
end
show running-config