Configuring MPLS Rewrite Rules
You can apply a number of different rewrite rules to MPLS packets.
For more information about how to configure statements at the [edit class-of-service] hierarchy level, see the Junos OS Class of Service Configuration Guide.
The following sections describe how you can apply rewrite rules to MPLS packets:
Rewriting the EXP Bits of All Three Labels of an Outgoing Packet
In interprovider, carrier-of-carrier, and complex traffic engineering scenarios, it is sometimes necessary to push three labels on the next hop.
By default, on M Series routers except the M320, the top MPLS EXP label of an outgoing packet is not rewritten when you configure swap-push-push and triple-push operations. You can rewrite the EXP bits of all three labels of an outgoing packet, thereby maintaining the class of service (CoS) of an incoming MPLS or non-MPLS packet.
To push three labels on incoming MPLS packets, include the exp-swap-push-push default statement at the [edit class-of-service interfaces interface-name unit logical-unit-number rewrite-rules] hierarchy level:
To push three labels on incoming non-MPLS packets, include the exp-push-push-push default statement at the [edit class-of-service interfaces interface-name unit logical-unit-number rewrite-rules] hierarchy level:
For more information about how to configure statements at the [edit class-of-service] hierarchy level, see the Junos OS Class of Service Configuration Guide.
Rewriting MPLS and IPv4 Packet Headers
You can apply a rewrite rule to MPLS and IPv4 packet headers simultaneously. This allows you to initialize MPLS EXP and IP precedence bits at LSP ingress. You can configure different rewrite rules depending on whether the traffic is VPN or non-VPN.
To rewrite MPLS and IPv4 packet headers, include the protocol statement at the [edit class-of-service interfaces interface-name unit logical-unit-number rewrite-rules exp rewrite-rule-name] hierarchy level:
Use the protocol statement to specify the types of MPLS packets and packet headers to which to apply the rewrite rule. The MPLS packet can be a standard MPLS packet or an MPLS packet with an IPv4 payload. Specify the type of MPLS packet by using the following options:
- mpls-any—Applies the rewrite rule to MPLS packets and writes the code point value to MPLS headers.
- mpls-inet-both—Applies the rewrite rule to VPN MPLS packets with IPv4 payloads. Writes the code point value to the MPLS and IPv4 headers in T Series (except T4000 routers) and M320 routers. On M Series routers, except the M320, the mpls-inet-both option causes all ingress MPLS LSP packets with IPv4 payloads to be initialized with 000 code points for IP precedence and MPLS EXP values.
- mpls-inet-both-non-vpn—Applies the rewrite rule to any non-VPN MPLS packets with IPv4 payloads. Writes the code point value to the MPLS and IPv4 headers in T Series and M320 routers. On M Series routers, except the M320, the mpls-inet-both-non-vpn option causes all ingress MPLS LSP packets with IPv4 payloads to be initialized with 000 code points for IP precedence and MPLS EXP values.
For a detailed example on how to configure rewrite rules for MPLS and IPv4 packets and for more information about how to configure class of service, see the Junos OS Class of Service Configuration Guide.