Rewriting Packet Header Information
As packets enter or exit a network, edge routers might be required to alter the class-of-service (CoS) settings of the packets. Rewrite rules set the value of the CoS bits within the packet's header. Each rewrite rule reads the current forwarding class and loss priority information associated with the packet, locates the chosen CoS value from a table, and writes this CoS value into the packet header.
In effect, the rewrite rule performs the opposite function of the behavior aggregate (BA) classifier used when the packet enters the router. As the packet leaves the routing platform, the final CoS action is generally the application of a rewrite rule.
You configure rewrite rules to alter CoS values in outgoing packets on the outbound interfaces of an edge router to meet the policies of a targeted peer. This allows the downstream router in a neighboring network to classify each packet into the appropriate service group.
In addition, you often need to rewrite a given marker (IP precedence, DSCP, IEEE 802.1P, or MPLS EXP settings) at the inbound interfaces of an edge router to accommodate BA classification by core devices.
Figure 13 shows a flow of packets through four routers. Router A rewrites the CoS bits in incoming packet to accommodate the BA classification performed by Routers B and C. Router D alters the CoS bits of the packets before transmitting them to the neighboring network.
![]()
To configure CoS rewrite rules, you define the rewrite rule and apply it to an interface. You include the following statements at the
[edit class-of-service]hierarchy level:class-of-service {interfaces {interface-name{unitlogical-unit-number{rewrite-rules {dscp (rewrite-name| default);dscp-ipv6 (rewrite-name| default);exp (rewrite-name| default)protocolprotocol-types;exp-push-push-push default;exp-swap-push-push default;frame-relay-de(rewrite-name| default);ieee-802.1(rewrite-name| default)vlan-tag(outer | outer-and-inner);inet-precedence (rewrite-name| default);}}}}rewrite-rules {(dscp | dscp-ipv6 | exp | frame-relay-de | ieee-802.1 | inet-precedence)rewrite-name{import (rewrite-name| default);forwarding-classclass-name{loss-prioritylevelcode-point (alias|bits);}}}}This chapter discusses the following topics:
- Applying a Default Rewrite Rule
- Configuring Rewrite Rules
- Bits Preserved, Cleared, and Rewritten
- Assigning the Rewrite-Rules Configuration to the Output Logical Interface
- Assigning the IEEE 802.1p Rewrite Rule to Dual VLAN Tags
- Rewriting EXP Bits on a Particular Node
- Rewriting MPLS and IPv4 Packet Headers
- Rewriting the EXP Bits of All Three Labels of an Outgoing Packet
- Rewriting IEEE 802.1p Packet Headers with MPLS EXP Value
- Rewriting Frame Relay Headers