Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 

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.

The default MPLS EXP rewrite rules are shown in Table 1.

Table 1: Default MPLS EXP Rewrite Rules

Forwarding Class

Loss Priority

MPLS EXP Rewrite Value

best-effort

low

000

best-effort

high

001

expedited-forwarding

low

010

expedited-forwarding

high

011

assured-forwarding

low

100

assured-forwarding

high

101

network-control

low

110

network-control

high

111

By default, IP precedence rewrite rules alter the first three bits on the type-of-service (ToS) byte while leaving the last three bits unchanged. This default behavior applies to rewrite rules you configure for MPLS packets with IPv4 payloads.

To override the default MPLS EXP rewrite table and rewrite MPLS and IPv4 packet headers simultaneously, 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:

The protocol statement defines the types of MPLS packets and packet headers to which the specified rewrite rule is applied. The MPLS packet can be a standard MPLS packet or an MPLS packet with an IPv4 payload. Specify the type of MPLS packet using the following options:

  • mpls—Applies the rewrite rule to MPLS packets and writes the CoS value to MPLS headers.

  • mpls-inet-both—Applies the rewrite rule to VPN MPLS packets with IPv4 payloads. On Juniper Networks M120 Multiservice Edge Routers, M320 Multiservice Edge Routers, and T Series Core Routers (except T4000 routers), writes the CoS value to the MPLS and IPv4 headers. On other M Series Multiservice Edge Router routers, causes all ingress MPLS LSP packets with IPv4 payloads to be initialized with 000 code points for the MPLS EXP value, and the configured rewrite code point for IP precedence.

  • mpls-inet-both-non-vpn—Applies the rewrite rule to non-VPN MPLS packets with IPv4 payloads. On Juniper Networks M120 Multiservice Edge Routers, M320 Multiservice Edge Routers, and T Series Core Routers, writes the CoS value to the MPLS and IPv4 headers. On other M Series Multiservice Edge Routers, causes all ingress MPLS LSP packets with IPv4 payloads to be initialized with 000 code points for the MPLS EXP value, and the configured rewrite code point for IP precedence.

On M120 routers, M320 routers with Enhanced-III FPCs, and MX Series routers, you can perform simultaneous DSCP and EXP rewrite by attaching independent DSCP or IPv4 precedence rewrite rules and EXP rewrite rules to the same core interface. Thus, you can rewrite both code points (DSCP and EXP) when the packet is received by the ingress provider edge (PE) router on the MPLS core.

An alternative to overwriting the default with a rewrite-rules mapping is to configure the default packet header rewrite mappings, as discussed in Applying Default Rewrite Rules.

By default, IP precedence rewrite rules alter the first three bits on the ToS byte while leaving the last three bits unchanged. This default behavior is not configurable. The default behavior applies to rules you configure by including the inet-precedence statement at the [edit class-of-service rewrite-rules] hierarchy level. The default behavior also applies to rewrite rules you configure for MPLS packets with IPv4 payloads. You configure these types of rewrite rules by including the mpls-inet-both or mpls-inet-both-non-vpn option at the [edit class-of-service interfaces interface-name unit logical-unit-number rewrite-rules exp rewrite-rule-name protocol] hierarchy level.

Example: Rewriting MPLS and IPv4 Packet Headers

On M320 and T Series routers, configure rewrite tables and apply them in various ways to achieve the following results:

  • For interface so-3/1/0, the three EXP rewrite tables are applied to packets, depending on the protocol of the payload:

    • IPv4 packets (VPN) that enter the LSPs on interface so-3/1/0 are initialized with values from rewrite table exp-inet-table. An identical 3-bit value is written into the IP precedence and MPLS EXP bit fields.

    • IPv4 packets (non-VPN) that enter the LSPs on interface so-3/1/0 are initialized with values from rewrite table rule-non-vpn. An identical 3-bit value is written into the IP precedence and MPLS EXP bit fields.

    • Non-IPv4 packets that enter the LSPs on interface so-3/1/0 are initialized with values from rewrite table rule1, and written into the MPLS EXP header field only. The statement exp rule1 has the same result as exp rule1 protocol mpls.

  • For interface so-3/1/0, IPv4 packets transmitted over a non-LSP layer are initialized with values from IP precedence rewrite table rule2.

  • For interface so-3/1/1, IPv4 packets that enter the LSPs are initialized with values from EXP rewrite table exp-inet-table. An identical 3-bit value is written into the IP precedence and MPLS EXP bit fields.

  • For interface so-3/1/1, MPLS packets other than IPv4 Layer 3 types are also initialized with values from table exp-inet-table. For VPN MPLS packets with IPv4 payloads, the CoS value is written to MPLS and IPv4 headers. For VPN MPLS packets without IPv4 payloads, the CoS value is written to MPLS headers only.

Example: Simultaneous DSCP and EXP Rewrite

On M120 routers, M320 routers with Enhanced-III FPCs, and MX Series routers, configure the simultaneous DSCP and EXP rewrite rules as shown below:

  1. Configure CoS.
  2. Configure the EXP rewrite rule on the interface.
  3. Configure the IPv4 rewrite rule on the interface.
  4. Configure the IPv4 rewrite rule on the interface and apply it to packets entering the MPLS tunnel.
  5. Verify the configuration by using the show interfaces command.

In the example above, there are two different IPv4 precedence rewrite rules: rule2 and rule3. rule2 affects the IPv4 to IPv4 traffic and rule3 affects the IPv4 to MPLS traffic.