Cisco – rewrite DSCP (ToS) values
Rewriting DSCP (ToS) values is tested on Cisco switch 3750:
Ports Model SW Version SW Image ------ ------ ----------------- ------------ 52 WS-C3750G-48TS 12.2(25)SEE4 C3750-ADVIPSERVICESK
By default QoS configuration is disabled:
sw3750#sh mls qos QoS is disabled QoS ip packet dscp rewrite is enabled
So we need to enable QoS:
sw3750#conf t sw3750(config)#mls qos sw3750(config)#end sw3750#sh mls qos QoS is enabled QoS ip packet dscp rewrite is enabled
We need to create access list:
sw3750#conf t sw3750(config)#access-list 1 remark rewrite_dscp sw3750(config)#access-list 1 permit any sw3750#show access-lists 1 Standard IP access list 1 10 permit any
Now we’ll begin with real QoS, and use terms as “class map” and “policy map“. According Cisco’s official documentation:
A class map is a mechanism that you use to name a specific traffic flow (or class) and to isolate it from all other traffic. The class map defines the criteria used to match against a specific traffic flow to further classify it. The criteria can include matching the access group defined by the ACL or matching a specific list of DSCP or IP precedence values. If you have more than one type of traffic that you want to classify, you can create another class map and use a different name. After a packet is matched against the
class-map criteria, you further classify it through the use of a policy map.
A policy map specifies which traffic class to act on. Actions can include trusting the CoS, DSCP, or IP precedence values in the traffic class; setting a specific DSCP or IP precedence value in the traffic class; or specifying the traffic bandwidth limitations and the action to take when the traffic is out of profile. Before a policy map can be effective, you must attach it to a port.
sw3750(config)#class-map ? WORD class-map name match-all Logical-AND all matching statements under this classmap match-any Logical-OR all matching statements under this classmap sw3750(config)#class-map match-all class-map-dscp sw3750(config-cmap)#match access-group 1 sw3750#show class-map class-map-dscp Class Map match-all class-map-dscp (id 1) Match access-group 1
After creting class-map, we need policy map. In this policy map we’ll rewrite dscp value of packet: “set dscp af32″ , this is ToS 0×70
sw3750(config)#policy-map vlan101 sw3750(config-pmap)#class class-map-dscp sw3750(config-pmap-c)#set dscp af32 sw3750#sh policy-map vlan101 Policy Map vlan101 Class class-map-dscp set dscp af32
OK, we created calss map and policy map, and now we’ll aplly them to interface.
sw3750(config)#int vlan101 sw3750(config-if)#service-policy input vlan101 sw3750#sh ru int vlan101 interface Vlan101 no ip address service-policy input vlan101 end
On a trunk port apply next commands:
sw3750(config)#int gi1/0/4 sw3750(config-if)#mls qos vlan-based sw3750#sh ru int gi1/0/4 interface GigabitEthernet1/0/4 switchport trunk encapsulation dot1q switchport trunk allowed 101 switchport mode trunk mls qos vlan-based end
