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.
Devices running Junos OS Evolved do not support different rewrite rules for VPN and non-VPN traffic.
The default MPLS EXP rewrite rules are shown in Table 1.
Forwarding Class |
Loss Priority |
MPLS EXP Rewrite Value |
---|---|---|
|
|
000 |
|
|
001 |
|
|
010 |
|
|
011 |
|
|
100 |
|
|
101 |
|
|
110 |
|
|
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:
[edit class-of-service interfaces interface-name unit logical-unit-number rewrite-rules exp rewrite-rule-name] protocol protocol-types;
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-any
—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 with000
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 with000
code points for the MPLS EXP value, and the configured rewrite code point for IP precedence.
Junos OS Evolved supports only the
mpls-any
option.
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 tableexp-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 tablerule-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 tablerule1
, and written into the MPLS EXP header field only. The statementexp rule1
has the same result asexp 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 tablerule2
. -
For interface
so-3/1/1
, IPv4 packets that enter the LSPs are initialized with values from EXP rewrite tableexp-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 tableexp-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.[edit class-of-service] rewrite-rules { exp exp-inet-table { forwarding-class best-effort { loss-priority low code-point 000; loss-priority high code-point 001; } forwarding-class assured-forwarding { loss-priority low code-point 010; loss-priority high code-point 011; } forwarding-class expedited-forwarding { loss-priority low code-point 111; loss-priority high code-point 110; } forwarding-class network-control { loss-priority low code-point 100; loss-priority high code-point 101; } } exp rule1 { ... } inet-precedence rule2 { ... } } exp rule_non_vpn { ... } interfaces { so-3/1/0 { unit 0 { rewrite-rules { exp rule1; inet-precedence rule2; exp exp-inet-table protocol mpls-inet-both; # For all VPN traffic. exp rule_non_vpn protocol mpls-inet-both-non-vpn; # For all non-VPN # traffic. } } } so-3/1/1 { unit 0 { rewrite-rules { exp exp-inet-table protocol [mpls mpls-inet-both]; } } } }
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:
-
Configure CoS.
[edit] user@host# edit class-of-service
-
Configure the EXP rewrite rule on the interface.
[edit class-of-service] user@host# set interfaces ge-2/0/3 unit 0 rewrite-rule exp rule1
-
Configure the IPv4 rewrite rule on the interface.
[edit class-of-service] user@host# set interfaces ge-2/0/3 unit 0 rewrite-rule inet-precedence rule2
-
Configure the IPv4 rewrite rule on the interface and apply it to packets entering the MPLS tunnel.
[edit class-of-service] user@host# set interfaces ge-2/0/3 unit 0 rewrite-rule inet-precedence rule3 protocol mpls
-
Verify the configuration by using the
show interfaces
command.[edit class-of-service] user@host# show interfaces ge-2/0/3 unit 0 rewrite-rules { exp rule1; inet-precedence rule2; inet-precedence rule3 protocol mpls; }
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.