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 on provider edge (PE) routers only. On transit routers (P), we do not alter the inner IPv4 headers and payloads while setting EXP bits in the outer MPLS header.
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 CoS value to the MPLS and IPv4 headers of VPN packets on provider edge (PE) routers. On core routers, this option rewrites only the MPLS header and does not rewrite CoS bits in the inner IPv4 payload. -
mpls-inet-both-non-vpn
—Applies the rewrite rule to non-VPN MPLS packets with IPv4 payloads. Applies the CoS value to the MPLS and IPv4 headers of non-VPN packets on provider edge (PE) routers. On core routers, this option rewrites only the MPLS header and does not rewrite CoS bits in the inner IPv4 payload.
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.
On 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
Configure rewrite tables and apply them in various ways to achieve the following results:
-
For interface
et-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
et-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 if this router acts as a provider edge router only. For a transit router, the 3-bit value is written to MPLS EXP bits only. -
IPv4 packets (non-VPN) that enter the LSPs on interface
et-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 if this router acts as a provider edge router only. For a transit router, the 3-bit value is written to MPLS EXP bits only. -
Non-IPv4 packets that enter the LSPs on interface
et-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
et-3/1/0
, IPv4 packets transmitted over a non-LSP layer are initialized with values from IP precedence rewrite tablerule2
. -
For interface
et-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 if this router acts as a provider edge router only. For a transit router, the 3-bit value is written to MPLS EXP bits only. -
For interface
et-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. Note that IPv4 headers are rewritten only when the router acts as a provider edge router.[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 { et-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. } } } et-3/1/1 { unit 0 { rewrite-rules { exp exp-inet-table protocol [mpls mpls-inet-both]; } } } }
Example: Simultaneous DSCP and EXP Rewrite
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.