Understanding CoS Rewrite Rules
As packets enter or exit a network, edge switches 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 associated with the packet, locates the chosen CoS value from a table, and writes this CoS value into the packet header. Rewrite rules must be assigned to an interface for rewrites to be activated. Only tagged Layer 3 interfaces and tagged routed VLAN interfaces (RVIs) rewrite packets by using the default IEEE 802.1p rewrite rule. Multiple rewrite rules of different types can be applied to a single interface.
![]() |
Note: On the Juniper Networks EX8200 Ethernet Switches , rewrite rules can be bound to only Layer 3 interfaces and RVIs. Rewrites on these interfaces are not a default behavior, and only one rewrite rule of each type can be bound to any interface in the system |
In effect, the rewrite rule performs the opposite function of the behavior aggregate (BA) classifier used when the packet enters the switch. As the packet leaves the switch, 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 switch to meet the policies of a targeted peer. This allows the downstream switch in a neighboring network to classify each packet into the appropriate service group.
![]() |
Note: When an IP precedence rewrite rule is active, bits 3,4, and 5 of the ToS byte are always reset to zero when code points are rewritten. |
Default Rewrite Rule
If you want to enable a rewrite rule on an interface, you can either create your own rule and enable it on the interface or enable a default rewrite rule. See Defining CoS Rewrite Rules (CLI Procedure).
Table 1 shows the default rewrite-rule mappings. These are based on the default bit definitions of Differentiated Services code point (DSCP), IEEE 802.1p, and IP precedence values and the default forwarding classes.
When the CoS values of a packet match the forwarding-class and packet-loss-priority (PLP) values, the switch rewrites markings on the packet based on the rewrite table.
Table 1: Default Packet Header Rewrite Mappings