Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?


exp (Rewrite rules)


Hierarchy Level


Apply an MPLS experimental (EXP) rewrite rule.

Starting in Junos OS 20.3R1, on segment routing LSPs, applying an EXP rewrite rule to the egress interface on the ingress (provider edge) router of a segment-routing network imposes the rewrite rule to all transport labels in the stack. As a result, you don't need to configure rewrite rules on every segment in the LSP.



Name of a rewrite-rules mapping configured at the [edit class-of-service rewrite-rules exp] hierarchy level.


The default mapping.

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. 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 interface-name unit logical-unit-number rewrite-rules exp rewrite-rule-name protocol] hierarchy level. The IP precedence rewrite rules explanation does not apply to ACX Series Universal Metro routers.

On interfaces configured on Modular Port Concentrators (MPCs) and Modular Interface Cards (MICs) on MX Series 5G Universal Routing Platforms and EX Series switches, we highly recommend that you configure the default option when you configure a behavior aggregate (BA) classifier that does not include a specific rewrite rule for MPLS packets. Doing so ensures that MPLS exp value is rewritten according to the BA classifier rules configured for forwarding or packet loss priority. This does not apply to ACX Series Universal Metro routers.


Specify one or more protocol matching criteria:

  • mpls-any—Apply to MPLS packets, write MPLS header only.

  • mpls-inet-both—Apply to IPv4 MPLS packets, write MPLS and IPv4 header.

  • mpls-inet-both-non-vpn—Apply to IPv4 MPLS packets, write MPLS and IPv4 header for only non VPN traffic.

Junos OS Evolved supports only the mpls-any option. Devices running Junos OS Evolved do not support different rewrite rules for VPN and non-VPN traffic.

Required Privilege Level

interface—To view this statement in the configuration.

interface-control—To add this statement to the configuration.

Release Information

Statement introduced before Junos OS Release 7.4.

Support for PTX platforms running Junos OS Evolved added with Junos OS Evolved Release 22.4.