Control plane policing and device hardening

Most packets pass through a router without touching its CPU; routing protocol packets, SSH, SNMP, pings to the box and DHCP do not, and a flood of them can starve the processes that keep the network up. Control plane policing is a QoS policy applied to the control plane: it sorts that traffic into classes and polices each to a rate learned from a baseline.

In Daveth Pro (Network)8 min video · lab: Protect the box

By , founder of Daveth · Updated

Opening frame of the video walkthrough of Control plane policing and device hardening

Watch this lesson

8 min · Video walkthrough

In Daveth Pro (Network)

The full 8 min walkthrough is in Daveth Pro (Network). See what the plan opens

Upcoming practical lab

Lab E13: Protect the box

What the lab covers

What this page answers

What is control plane policing (CoPP)?

A QoS policy applied to traffic to or from the router's control plane CPU, to limit known traffic to a given rate and protect the CPU from unexpected extreme rates. Its sole purpose is protecting the CPU, the control plane. Read it in “4.1 Why the CPU needs a door policy”

Which CoPP class does unexpected control traffic fall into?

class-default: anything the policy's classes do not name, including traffic that matches a class only in one direction, such as a DHCP client request when the class matches server-to-client. Read it in “4.1 Why the CPU needs a door policy”

4.1 Why the CPU needs a door policy

The guide's CoPP policy is on R1, an OSPF router on an ordinary Ethernet segment with a DR. The DR acknowledges R1's LSA updates. Which CoPP class polices those acknowledgments? Keep that for section 4.2.

Most packets pass through a router without the CPU touching them. The ones that don't (routing protocol packets, SSH and SNMP to the box, pings to its addresses, DHCP) go to the control plane, and a flood of them can starve the processes that keep the network up. A CoPP policy "is a QoS policy that is applied to traffic to or sourced by the router's control plane CPU", used "to limit known traffic to a given rate while protecting the CPU from unexpected extreme rates". The quiz puts it plainly: CoPP was "created with the sole purpose of protecting the CPU or control plane". It works like a nightclub door with a guest list and a capacity for each group: regulars, staff and suppliers each get their own door count, so a crowd of strangers can't push the staff out. (That's the design; section 4.3 shows how much of it a policy that's still baselining actually enforces.)

Typical CoPP policies are input only; CoPP supports output too, but outbound policies "are not commonly used". In a planned policy, traffic is sorted by type (management, routing protocols, known addresses) and each class is limited to its own rate. That's a bit like the lanes at airport security: crew, families and everyone else queue separately, so one lane's rush doesn't close the others.

CoPP is the CPU's bodyguard, and like any good bodyguard it spends most of its day checking names against a list and waving people through.

You can't police what you haven't named. The guide finds the traffic from protocol documentation or by capturing it with Embedded Packet Capture, then writes an ACL per group (Example 26-33) and a class map per ACL (Example 26-34). The ACLs are deliberately open, any to any: they classify, they don't filter, and access control is left to other tools. Consider it your guest list sorted by door, not a ban list.

ClassIts ACL matches (Example 26-33)
CLASS-CoPP-ICMPecho, echo-reply, TTL exceeded, unreachable; UDP 33434-33463 with TTL 1 (traceroute)
CLASS-CoPP-IPsecESP, GRE, ISAKMP (UDP 500 to 500), NAT-T (UDP 4500)
CLASS-CoPP-InitializeDHCP server to client (UDP 67 to 68)
CLASS-CoPP-ManagementNTP from port 123, SNMP to 161, SSH to 22 and established SSH from 22
CLASS-CoPP-RoutingBGP from port 179 (established), EIGRP to 224.0.0.10, OSPF to 224.0.0.5 and .6, PIM to 224.0.0.13, IGMP

Read the Routing line closely. The guide's NOTE: it "does not classify unicast routing protocol packets such as unicast PIM, unicast OSPF, and unicast EIGRP". So the answer to section 4.1's question is class-default. That isn't an exotic setup: EIGRP "uses multicast packets where possible and unicast packets when necessary", OSPF "uses multicast where possible", and on an ordinary broadcast segment "The DR sends a unicast acknowledgment". The guide's own NOTE adds that the policy "needs to be tweaked based on the routing protocols in use". And the BGP line matches TCP from port 179 only; packets a peer sends to R1's port 179 match none of the ACLs either. The same one-way reading applies elsewhere: Initialize matches DHCP from server to client only, so a client's request to a router acting as DHCP server (port 68 to 67) is class-default, and Management's NTP line matches source port 123, so a client querying R1 from another port isn't matched. It's like a guest list that has your name but only under the back door: come in the front and you're a stranger.

Anything no class matches goes to class-default, which "contains any unknown traffic". Every ACL in Example 26-33 is IPv4, so under the guide's router policy OSPFv3, BGP over IPv6 and neighbor discovery all land there too. A dual-stack router running a policy like this needs IPv6 classes of its own; how a CoPP class map matches an IPv6 ACL isn't in the sources read, so check your platform's CoPP documentation before writing one. (A Catalyst 9300 places IPv6 control traffic in the same fixed system classes as IPv4: section 4.3.)

Under the guide's policy, unicast OSPF is the routing protocol that turned up in a suit and still got sent to the cheap seats with the port scanners.

Each class gets a policer:

policy-map POLICY-CoPP
 class CLASS-CoPP-ICMP
  police 8000 conform-action transmit exceed-action transmit violate-action drop
 class CLASS-CoPP-Routing
  police 64000 conform-action transmit exceed-action transmit violate-action transmit
 class class-default
  police 8000 conform-action transmit exceed-action transmit violate-action drop
control-plane
 service-policy input POLICY-CoPP

(IPsec 64000 and Management 32000 transmit on violate; Initialize 8000 drops, like ICMP, in Example 26-35.) A police with conform, exceed and violate actions is a three-colour policer: Example 26-37 shows a cir in bits per second and a bc and be in bytes for each class. RFC 2697's single-rate meter works the same way: tokens arrive at the CIR and fill the committed bucket (CBS) first; only the overflow fills the excess bucket (EBS); a packet is green if the committed bucket holds enough, yellow if only the excess bucket does, and red otherwise. The guide ties the two together: "Single-rate three-color policer algorithms are based on RFC 2697". RFC 2697 counts its CIR in bytes per second; Cisco's cir is in bits per second. It's like a rain barrel that overflows into a second barrel: you draw from the first while it has water, then from the second, and when both are dry you go without.

The rates are the hard part: "finding the correct rate without impacting network stability is not a simple task". So the guide sets violate to transmit for the vital classes until a baseline is known, and adjusts over time; ICMP and DHCP drop, "as it should have low packet rates". A policer with violate-action transmit is like a bouncer who counts the people over capacity but still lets them in: you learn how big Friday night really is before you start turning anyone away. The catch: while Routing, IPsec and Management transmit on conform, exceed and violate, they're counters, not limits, and the ACLs are open, so anything sent from port 179 with the right flags rides in the Routing class unlimited. The guide's own policer section adds that when conform and exceed do the same thing, "the single-rate two-color policer is recommended to keep things simpler". class-default gets a small rate on purpose. "Under normal conditions, nothing should exist within the class default", but a minimal rate "permits discovery of new or unknown traffic that would have otherwise been denied". The policy then goes on the control plane: control-plane, then service-policy {input | output} name.

Predict before D1: a port scan hits R1, and a moment later five unicast OSPF packets arrive. Both land in class-default. Which are dropped?

D1

Network drawing: CLASS-CoPP-ICMP, cir 8000 · violate drop, no packets, CLASS-CoPP-IPsec, cir 64000 · violate transmit, CLASS-CoPP-Initialize, CLASS-CoPP-Management, cir 32000 · violate transmit, CLASS-CoPP-Routing, cir 64000 · violate transmit · 2/1/57, class-default
The BGP update burst lands in CLASS-CoPP-Routing: 2 conform, 1 exceed, 57 violate, and violate-action transmit lets them through: counted, not dropped.

The OSPF packets. The scan drained class-default's buckets first, so the OSPF packets arrive red and are dropped: they share the class's 8000 bps with whatever else nobody named. On their own, a few OSPF unicasts fit easily; a flooding burst is what overruns it alone. In the BGP burst, Routing violates heavily but transmits, so its counters climb and nothing is lost, until its violate-action is set to drop.

The guide's example is a router's policy, built from nothing. A Catalyst 9300 on 17.9 works the other way round: it ships with one policy, system-cpp-policy, applied with service-policy input system-cpp-policy under control-plane, and "The system-cpp-policy policy-map and the system-defined classes cannot be modified or deleted". You can't add a class of your own ("the creation of user-defined class-maps is not supported" since 16.8.1a), only the police action is allowed, and rates are "configured only in packets per second (pps)", not the guide's bits per second; the switch rounds whatever you set "to the nearest multiple of 200". If the policy is missing at first power-up, the switch creates and installs it. The switch is much like a furnished flat with the furniture bolted down: you can turn each room's dimmer, which lights several lamps at once, but you can't bring in a new lamp.

So on the switch you don't write the classification: the system classes already place OSPF, OSPFv3, BGP, EIGRP, EIGRPv6, PIMv6, DHCPv6 and "IPv6 control" in routing-control, at a default 5400 pps, and ARP and "IPv6 neighbor advertisement and neighbor solicitation" in forus, with Telnet, ping and SNMP. IPv4 and IPv6 share those classes; there are no IPv6-only ones. Where traffic the table doesn't list lands (router advertisements, NTP, a switch acting as DHCP server) isn't in the sources read (unconfirmed). What's left to you is the rate, with police rate <n> pps under the class in system-cpp-policy. Two of the chapter's warnings echo the router policy's problems in section 4.2, where everything unnamed shared class-default: several protocols share one policer, so "A protocol with a large number of CPU-bound packets may impact other protocols in the same class", and removing a class's policer is discouraged because it "affects the overall system health in case of high traffic towards the CPU". And show run doesn't show classes left at their defaults, so a short configuration doesn't mean no CoPP. The defaults work like a building's fire doors: you won't find them in the tenant's inventory, but they're there and they close whether you listed them or not.

On a Catalyst 9300 (17.9)ProvesDoesn't prove
show policy-map control-plane lists system-cpp-policythe system policy is attachedthat its rates suit your network: they may be untouched defaults
no class system-cpp-police-... lines under policy-map system-cpp-policy in show runevery class is at its default rate (the course's reading of K1)that CoPP is off: use show policy-map control-plane
a class's drops risingthat class's shared policer is overrunwhich protocol in the class caused it

Example 26-37's Routing class logs 86 violations and transmits all 86, which is CoPP's way of saying "I've written your names down" rather than "you're not coming in".

show policy-map control-plane input shows each class with its packets and bytes, its match, the police cir, bc and be, and conformed, exceeded and violated counts with their actions. Each class reads like a line on a bank statement: what came in, what fitted the budget, and what went over it.

In Example 26-37, CLASS-CoPP-Routing saw 92 packets: 5 conformed, 1 exceeded and 86 violated, all transmitted. The guide reads that as traffic that "has exceeded the configured rate". Look at the rate line, though: "5 minute offered rate 4000 bps" against a cir of 64000 bps, and the violated bytes work out at 118938 / 86 = 1383 bytes a packet. With bc and be at 2000 bytes each, a third back-to-back packet of that size finds both buckets short. So the counters point at bursts bigger than bc plus be, not at an average above the CIR. And class-default's counters don't add up: 56 packets, 20464 bytes, but only 5 packets conformed and none exceeded or violated. What you can safely say is that unknown traffic is present and none of it was dropped. Its next step is EPC again, with the ACLs turned from permit to deny to catch what's unexpected. class-default here works like a lost-property box: everything in it is something nobody labelled, and a full box means go and find out whose it is.

OutputProvesDoesn't prove
a class's packet count risingpackets matched that classthat they're the protocol you meant: the ACL decides, not the class name
violated packets with action transmitpackets arrived when neither bucket held enough tokens, and none were droppedthat the average rate exceeds the CIR: compare the offered rate line; a burst beyond bc + be does it too
"5 minute offered rate"the class's recent averageits bursts
violated packets with action dropthat many packets were droppedwhich protocol lost them: capture to find out
packets in class-defaultsome traffic matched no classwhat it is, or whether it matters
zero packets in a classnothing matched it in the counter's windowthat the ACL is right: nothing may have been sent