使用策略图限制思科路由器的带宽不起作用

使用策略图限制思科路由器的带宽不起作用

我在使用类映射和策略映射限制 GNS3 中 ubuntu PC 的带宽时遇到了问题。这是我在 GNS3 中的拓扑:

             -----------cisco-3725-router----------->Internet
            |
            |
            |
            |      
            |
         Switch
            |
          |   |
       |         |
    |               |
UBUNTU-PC         XP-PC

R1 是 cisco 3725 路由器,带有 c3725-adventerprisek9-mz.124-25d.bin 映像,这是我的配置:

!

!
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
!
memory-size iomem 5
no ip icmp rate-limit unreachable
ip cef
ip tcp synwait-time 5
!
!
no ip domain lookup
!
!
class-map match-all UBUNTU_DW
 match access-group name UBUNTU_DW
class-map match-all UBUNTU_UP
 match access-group name UBUNTU_UP
!
!
policy-map UP
 class UBUNTU_UP
  police cir 32000 bc 4000 be 4000
    conform-action transmit 
    exceed-action drop 
    violate-action drop 
policy-map DW
 class UBUNTU_DW
  police cir 32000 bc 4000 be 4000
    conform-action transmit 
    exceed-action drop 
    violate-action drop 
!
!
interface FastEthernet0/0
 ip address 10.0.0.254 255.255.255.0
 ip nat inside
 ip virtual-reassembly
 duplex auto
 speed auto
!
interface Serial0/0
 no ip address
 shutdown
 clock rate 2000000
!
interface FastEthernet0/1
 ip address 216.65.200.143 255.255.255.0
 ip nat outside
 ip virtual-reassembly
 duplex auto
 speed auto
 service-policy input DW
 service-policy output UP
!
interface FastEthernet1/0
 no ip address
 shutdown
 duplex auto
 speed auto
!
interface Serial2/0
 no ip address
 shutdown
 serial restart-delay 0
 no dce-terminal-timing-enable
!
interface Serial2/1
 no ip address
 shutdown
 serial restart-delay 0
 no dce-terminal-timing-enable
!
interface Serial2/2
 no ip address
 shutdown
 serial restart-delay 0
 no dce-terminal-timing-enable
!
interface Serial2/3
 no ip address
 shutdown
 serial restart-delay 0
 no dce-terminal-timing-enable
!
ip route 0.0.0.0 0.0.0.0 216.65.200.3
!
ip flow-top-talkers
 top 10
 sort-by bytes
!
no ip http server
no ip http secure-server
ip nat inside source list 1 interface FastEthernet0/1 overload
!
ip access-list extended UBUNTU_DW
 permit ip any host 10.0.0.51
ip access-list extended UBUNTU_UP
 permit ip host 10.0.0.51 any
!
access-list 1 permit 10.0.0.0 0.0.0.255
no cdp log mismatch duplex
!
!
control-plane
!
!
line con 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
line aux 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
line vty 0 4
 login
!
!
end

问题是 ubuntu 的 32kbps 限制不起作用。

R1#sh policy-map interface fastEthernet 0/1
 FastEthernet0/1

  Service-policy input: DW

    Class-map: UBUNTU_DW (match-all)
      0 packets, 0 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: access-group name UBUNTU_DW
      police:
          cir 32000 bps, bc 4000 bytes, be 4000 bytes
        conformed 0 packets, 0 bytes; actions:
          transmit
        exceeded 0 packets, 0 bytes; actions:
          drop
        violated 0 packets, 0 bytes; actions:
          drop
        conformed 0 bps, exceed 0 bps, violate 0 bps

    Class-map: class-default (match-any)
      905 packets, 812409 bytes
      5 minute offered rate 27000 bps, drop rate 0 bps
      Match: any

  Service-policy output: UP

    Class-map: UBUNTU_UP (match-all)
      0 packets, 0 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: access-group name UBUNTU_UP
      police:
          cir 32000 bps, bc 4000 bytes, be 4000 bytes
        conformed 0 packets, 0 bytes; actions:
          transmit
        exceeded 0 packets, 0 bytes; actions:
          drop
        violated 0 packets, 0 bytes; actions:
          drop
        conformed 0 bps, exceed 0 bps, violate 0 bps

    Class-map: class-default (match-any)
      979 packets, 154180 bytes
      5 minute offered rate 7000 bps, drop rate 0 bps
      Match: any

是否有任何错误配置?我该如何应用此策略?

答案1

遗憾的是,我认为 NAT 发生在监管之前;因此所有流量都显示为 NAT 地址,而不是您在 ACL / 类映射中指定的内部地址。

一个想法是使用 DSCP 值标记与 Ubuntu 服务器匹配的 FA0/0 上的传入流量。然后根据该 DSCP 值进行监管。这将解决您的出站问题。

对于下游,我不太清楚为什么缺少该策略。我再次怀疑是 NAT 问题,尽管操作顺序似乎表明它不应该是一个因素。 http://www.cisco.com/c/en/us/support/docs/ip/network-address-translation-nat/6209-5.html

如果下游也存在 NAT 问题,那么您可以在 fa0/0 上使用出站监管器,并达到同样的抑制流量的效果。

答案2

正如 Jason 所说,NAT 似乎确实开始发挥作用。我的建议是尝试在 f0/0 上使用服务策略并更改方向。

这应该在 NAT 发生之前/之后生效,这应该可以排除 NAT 问题。

interface FastEthernet0/1
 .
 .
 service-policy output DW
 service-policy input UP

希望这可以帮助!

相关内容