class
To define a traffic classification match criteria for the specified class-map name, use the class command in policy-map configuration mode. Use the no form of this command to delete an existing class map.
class {class-map-name | class-default}
no class {class-map-name | class-default}
Syntax Description
class-map-name |
Assigns a name to the class map. |
class-default |
Refers to a system default class that matches unclassified packets. |
Command Default
No policy map class-maps are defined.
Command Modes
Policy-map configuration
Command History
Release |
Modification |
---|---|
Cisco IOS Release 15.0(2)EX |
This command was introduced. |
Usage Guidelines
Before using the class command, you must use the policy-map global configuration command to identify the policy map and enter policy-map configuration mode. After specifying a policy map, you can configure a policy for new classes or modify a policy for any existing classes in that policy map. You attach the policy map to a port by using the service-policy interface configuration command.
After entering the class command, you enter policy-map class configuration mode. These configuration commands are available:
- exit—Exits policy-map class configuration mode and returns to policy-map configuration mode.
- no—Returns a command to its default setting.
- police—Defines a policer or aggregate policer for the classified traffic. The policer specifies the bandwidth limitations and the action to take when the limits are exceeded. For more information, see police and police aggregate.
- set—Specifies a value to be assigned to the classified traffic. For more information, see set.
- trust—Defines a trust state for traffic classified with the class or the class-map command. For more information, see trust.
To return to policy-map configuration mode, use the exit command. To return to privileged EXEC mode, use the end command.
The class command performs the same function as the class-map global configuration command. Use the class command when a new classification, which is not shared with any other ports, is needed. Use the class-map command when the map is shared among many ports.
You can configure a default class by using the class class-default policy-map configuration command. Unclassified traffic (traffic that does not meet the match criteria specified in the traffic classes) is treated as default traffic.
Examples
This example shows how to configure a default traffic class to a policy map:
Switch# configure terminal
Switch(config)# class-map cm-3
Switch(config-cmap)# match ip dscp 30
Switch(config-cmap)# match protocol ipv6
Switch(config-cmap)# exit
Switch(config)# class-map cm-4
Switch(config-cmap)# match ip dscp 40
Switch(config-cmap)# match protocol ip
Switch(config-cmap)# exit
Switch(config)# policy-map pm3
Switch(config-pmap)# class class-default
Switch(config-pmap-c)# set dscp 10
Switch(config-pmap-c)# exit
Switch(config-pmap)# class cm-3
Switch(config-pmap-c) set dscp 4
Switch(config-pmap-c)# exit
Switch(config-pmap)# class cm-4
Switch(config-pmap-c)# trust cos
Switch(config-pmap-c)# exit
Switch(config-pmap)# exit
You can verify your settings by entering the show policy-map privileged EXEC command.
This example shows how the default traffic class is automatically placed at the end of policy-map pm3 even though class-default was configured first:
Switch# show policy-map pm3
Policy Map pm3
Class cm-3
set dscp 4
Class cm-4
trust cos
Class class-default
set dscp 10
Switch#