Cisco(config)#ip access-list extended BOSS
Cisco(config-ext-nacl)#permit ip host 192.168.1.8 any
Cisco(config-ext-nacl)#permit ip host 192.168.1.18 any
Cisco(config-ext-nacl)#permit ip host 192.168.1.38 any
Cisco(config-ext-nacl)#permit ip host 192.168.1.48 any
Cisco(config-ext-nacl)#permit ip host 192.168.1.58 any
Cisco(config-ext-nacl)#permit ip host 192.168.1.68 any
Cisco(config-ext-nacl)#end
Cisco#config t
Cisco(config)#ip access-list extended COMMON
Cisco(config-ext-nacl)#deny ip host 192.168.1.8 any
Cisco(config-ext-nacl)#deny ip host 192.168.1.18 any
Cisco(config-ext-nacl)#deny ip host 192.168.1.38 any
Cisco(config-ext-nacl)#deny ip host 192.168.1.48 any
Cisco(config-ext-nacl)#deny ip host 192.168.1.58 any
Cisco(config-ext-nacl)#deny ip host 192.168.1.68 any
Cisco(config-ext-nacl)#permit ip 192.168.0.0 0.0.255.255 any
Cisco(config-ext-nacl)#end
Cisco#config t
Cisco(config)#route-map QoS permit 10
Cisco(config-route-map)#match ip address BOSS
Cisco(config-route-map)#set ip precedence ?
<0-7> Precedence value
critical Set critical precedence (5)
flash Set flash precedence (3)
flash-override Set flash override precedence (4)
immediate Set immediate precedence (2)
internet Set internetwork control precedence (6)
network Set network control precedence (7)
priority Set priority precedence (1)
routine Set routine precedence (0)
<cr>
Cisco(config-route-map)#set ip precedence critical
Cisco(config-route-map)#exit
Cisco(config)#route-map QoS permit 20
Cisco(config-route-map)#match ip address COMMON
Cisco(config-route-map)#set ip precedence priority
Cisco(config-route-map)#exit
Cisco(config)#class-map match-any NORMAL
Cisco(config-cmap)#match ip precedence 0 1 2
Cisco(config-cmap)#class-map match-any PREMIUM
Cisco(config-cmap)#match ip precedence 0 1 2
Cisco(config-cmap)#exit
Cisco(config)#policy-map QoS_OUTPUT
Cisco(config-pmap)#class PREMIUM
Cisco(config-pmap-c)#bandwidth 2048
Cisco(config-pmap-c)#police 2048000 bc 19200 38400
Cisco(config-pmap-c-police)#conform-action transmit
Cisco(config-pmap-c-police)#exceed-action transmit
Cisco(config-pmap-c-police)#class NORMAL
Cisco(config-pmap-c)#bandwidth 512
Cisco(config-pmap-c)#police cir 51000 bc 1200 be 1200
Cisco(config-pmap-c-police)#conform-action transmit
Cisco(config-pmap-c-police)#exceed-action drop
Cisco(config-pmap-c-police)#end
Cisco#config t
Cisco(config)#interface G 0/0
Cisco(config-if)#ip nat inside
Cisco(config-if)#ip policy route-map QoS
Cisco(config)#interface G 0/1
Cisco(config-if)#ip nat outside
Cisco(config-if)#service-policy output QoS_OUTPUT
marking:
1.定义class-map.
class-map [match-all/match-any] {map-name}
默认不打的话是match-all
2.定义匹配命令match
match access-group {NO}
match input-interface {interface}
match class-map {map-name} class-map嵌套
match source-address {mac-address} 源mac地址
match destination-address {mac-address} 目的mac地址
match vlan {vlan-ID}
match ip dscp {DSCP}
match ip precedencc {precedence}
match protocol {protocol} 基于NBAR
Router(config) class-map FOO
Router(config-cmap)#match ?
access-group Access group
any Any packets
class-map Class map
cos IEEE 802.1Q/ISL class of service/user priority values
destination-address Destination address
input-interface Select an input interface to match
ip IP specific values
mpls Multi Protocol Label Switching specific values
not Negate this match result
protocol Protocol
qos-group Qos-group
source-address Source address
3.设置policy-map
policy-map {policy-name}
4.调用class-map
class-map {map-name}
5.设置标记
set ip dscp {DSCP}
set ip precedence {PRECEDENCE}
set cos {COS}
priority {Kbps|percent PERCENT} [bc] 定义优先级流量的带宽以及突发流量
bandwidth {Kbps|percent PERCENT} 定义保留带宽
random-detect 启用WRED
police {CIR BC BE} conform-action {action} exceed-action {action} [violated-action {action}] 使用令牌桶限速
queue-limit {PACKETS} 定义队列中数据报的最大个数
service-policy {policy-name} 调用其它的策略进行嵌套
shape {average|peak} {CIR [BC] [BE]} 整形
drop
6.在接口模式下调用policy-map
service-policy [input|ouput] {POLICY-NAME}
察看命令:
show policy-map [policy-name]
show policy-map interface [INTERFACE]
show class-map [class-name]
show ip nbar pdlm
show ip nbar port-map 显示NBAR使用的协议到端口的映射
NBAR应用:
使用限制:
1.快速以太网信道
2.隧道接口或加密的接口
3.SVI(交换虚拟接口)
4.拨号接口
5.多链路PPP(MLP)
使用前先要敲命令:ip cef
class-map {name}
match protocol ...
ip nbar pdlm flash://bittorrent.pdlm 加载bittorrent.pdlm 到路由器闪存里(事先要把pdlm复制到flash中)
match procotol http url "*.jpeg|*.jpg" (匹配url中带有jpeg和jpg的连接)
match procotol http url "*.gif" (匹配url中有gif的连接)