service-policy [input|output] [policy]
Applies a QoS policy map to an interface for inbound or outbound traffic classification, marking, policing, shaping, or queuing.
service-policy [input|output] [policy]When to Use This Command
- Apply a policy to shape outbound traffic on a WAN interface to 10 Mbps.
- Apply a policy to police inbound traffic and drop packets exceeding a rate limit.
- Apply a policy to mark VoIP traffic with DSCP EF on an access port.
- Apply a policy to prioritize critical traffic over best-effort on a trunk interface.
Command Examples
Apply output shaping policy to a WAN interface
interface GigabitEthernet0/0
service-policy output SHAPE-10MRouter# show policy-map interface GigabitEthernet0/0
GigabitEthernet0/0
Service-policy output: SHAPE-10M
Class-map: class-default (match-any)
0 packets, 0 bytes
5 minute offered rate 0 bps, drop rate 0 bps
Match: any
queue limit 64 packets
(queue depth/total drops/no-buffer drops) 0/0/0
(pkts output/bytes output) 0/0
shape (average) cir 10000000, bc 40000, be 40000
target shape rate 10000000
Class-map: VOICE (match-any)
0 packets, 0 bytes
5 minute offered rate 0 bps, drop rate 0 bps
Match: ip dscp ef (46)
queue limit 40 packets
(queue depth/total drops/no-buffer drops) 0/0/0
(pkts output/bytes output) 0/0
shape (average) cir 1000000, bc 4000, be 4000
target shape rate 1000000The output shows two class-maps: 'class-default' (all traffic) and 'VOICE' (DSCP EF). For each class, it displays packet/byte counts, offered rate, drop rate, queue depth, and shaping parameters (CIR, Bc, Be). The 'target shape rate' is the actual enforced rate.
Apply input police policy to a LAN interface
interface GigabitEthernet0/1
service-policy input POLICE-10MRouter# show policy-map interface GigabitEthernet0/1
GigabitEthernet0/1
Service-policy input: POLICE-10M
Class-map: class-default (match-any)
100 packets, 12000 bytes
5 minute offered rate 50000 bps, drop rate 1000 bps
Match: any
police:
cir 10000000 bps, bc 312500 bytes
conformed 90 packets, 10800 bytes; actions:
transmit
exceeded 10 packets, 1200 bytes; actions:
drop
violated 0 packets, 0 bytes; actions:
drop
conformed 45000 bps, exceed 5000 bps, violate 0 bpsThe output shows the policer applied to all traffic. 'conformed' packets are within CIR and are transmitted; 'exceeded' packets exceed CIR but are within burst; 'violated' packets exceed both. Actions for each category are displayed. Rates in bps help verify if policing is working correctly.
Understanding the Output
The 'show policy-map interface' command displays per-class statistics for the applied policy. Key fields: 'Service-policy [input|output]: [policy-name]' indicates direction and policy name. Each class-map shows matched traffic (packets/bytes), offered rate (average input rate), drop rate (packets dropped). For shaping: 'shape (average) cir' shows configured CIR, and 'target shape rate' is the actual enforced rate. For policing: 'conformed', 'exceeded', 'violated' counts and actions (transmit/drop). 'conformed rate' and 'exceed rate' help verify if traffic is within limits. Queue depth indicates congestion. Good values: low drop rate, conformed rate close to CIR. Bad values: high drop rate, excessive exceeded packets, queue depth consistently high.
CCNA Exam Tips
Remember that 'service-policy' is applied in interface configuration mode, not global.
Know that 'input' and 'output' are the only direction keywords; you cannot apply a policy in both directions on the same interface with one command.
The exam may test that a policy map must be created with 'policy-map' before applying it with 'service-policy'.
Be aware that 'service-policy' can be used with both MQC (Modular QoS CLI) and legacy QoS; CCNA focuses on MQC.
Common Mistakes
Applying a policy without first creating the policy map and class maps, resulting in an error.
Using 'service-policy' in global configuration mode instead of interface configuration mode.
Forgetting to specify the direction (input or output), which causes the command to be rejected.
Applying a policy that references a class map that does not exist, leading to an incomplete configuration.
Related Commands
policy-map [name]
Creates or modifies a QoS policy-map that defines a set of class-maps and associated actions (e.g., bandwidth, priority, drop) to apply to traffic on Cisco IOS routers.
show class-map
Displays the configuration and match criteria of all class maps or a specific class map, used to verify QoS classification rules.
show policy-map interface
Displays the current QoS policy applied to an interface, including per-class statistics such as packets matched, bytes, and actions taken, used to verify and troubleshoot QoS configurations.
Practice for the CCNA 200-301
Test your knowledge with hundreds of CCNA practice questions covering all exam domains.
Practice CCNA Questions