9 The MPLS FIB is implemented using exactly the same data structures as
10 the IP FIB. The only difference is the implementation of the
11 table. Whereas for IPv4 this is an mtrie and for IPv6 a hash table,
12 for MPLS it is a flat array indexed by a 21 bit key (label & EOS
13 bit). This implementation is chosen to favour packet forwarding speed.
18 MPLS is not enabled by default. There are two steps to get
19 started. First, create the default MPLS FIB:
21 .. code-block:: console
25 With '0' being the magic number for the 'default' table (just like it
26 is for IPv[46]). One can create other MPLS tables, but, unlike IP
27 tables, one cannot 'bind' non-default MPLS tables to interfaces, in
28 other words all MPLS packets received on an interface will always
29 result in a lookup in the default table. One has to be more inventive
30 to use the non-default tables...
32 Secondly, for *each* interface on which you wish to *receive* MPLS
33 packets, that interface must be MPLS 'enabled'
35 .. code-block:: console
37 $ set interface mpls GigEthernet0/0/0 enable
39 there is no equivalent enable for transmit, all that is required is to
40 use an interface as an egress path.
42 Entries in the MPLS FIB can be displayed with:
44 .. code-block:: console
46 $ sh mpls fib [table X] [label]
48 There is a tight coupling between IP and MPLS forwarding. MPLS
49 forwarding equivalence classes (FECs) are often an IP prefix – that is
50 to say that traffic matching a given IP prefix is routed into a MPLS
51 label switch path (LSP). It is thus necessary to be able to associated
52 a given prefix/route with an [out-going] MPLS label that will be
53 imposed when the packet is forwarded. This is configured as:
55 .. code-block:: console
57 $ ip route add 1.1.1.1/32 via 10.10.10.10 GigEthernet0/0/0 out-labels 33
59 packets matching 1.1.1.1/32 will be forwarded out GigEthernet0/0/0 and have
60 MPLS label 33 imposed. More than one out-going label can be
61 specified. Out-going MPLS labels can be applied to recursive and
62 non-recursive routes, e.g;
64 .. code-block:: console
66 $ ip route add 2.2.2.0/24 via 1.1.1.1 out-labels 34
68 packets matching 2.2.2.0/24 will thus have two MPLS labels imposed; 34
69 and 33. This is the realisation of, e,g, an MPLS BGP VPNv4.
71 To associate/allocate a local-label for a prefix, and thus have
72 packets to that local-label forwarded equivalently to the prefix do;
74 .. code-block:: console
76 $ mpls local-label 99 2.2.2.0/24
78 In the API this action is called a ‘bind’.
79 The router receiving the MPLS encapsulated packets needs to be
80 programmed with actions associated which each label value – this is
81 the role of the MPLS FIB. The MPLS FIB Is a table, whose key is the
82 MPLS label value and end-of-stack (EOS) bit, which stores the action
83 to perform on packets with matching encapsulation. Currently supported
86 #. Pop the label and perform an IPv[46] lookup in a specified table
87 #. Pop the label and forward via a specified next-hop (this is penultimate-hop-pop, PHP)
88 #. Swap the label and forward via a specified next-hop.
90 These can be programmed respectively by:
92 .. code-block:: console
94 $ mpls local-label 33 eos ip4-lookup-in-table X
95 $ mpls local-label 33 [eos] via 10.10.10.10 GigEthernet0/0/0
96 $ mpls local-label 33 [eos] via 10.10.10.10 GigEthernet0/0/0 out-labels 66
98 the latter is an example of an MPLS cross connect. Any description of
99 a next-hop, recursive, non-recursive, labelled, non-labelled, etc,
100 that is valid for an IP prefix, is also valid for an MPLS
101 local-label. Note the use of the 'eos' keyword which indicates the
102 programming is for the case when the label is end-of-stack. The last
103 two operations can apply to both eos and non-eos packets, but the pop
104 and IP lookup only to an eos packet.
110 To configure an MPLS VPN for a PE the follow example can be used.
112 Step 1; Configure routes to the iBGP peers - note these route MUST
113 have out-going labels;
115 .. code-block:: console
117 $ ip route add 10.0.0.1/32 via 192.168.1.2 Eth0 out-labels 33
118 $ ip route add 10.0.0.2/32 via 192.168.2.2 Eth0 out-labels 34
120 Step 2; Configure the customer 'VRF'
122 .. code-block:: console
126 Step 3; add a route via the iBGP peer[s] with the MPLS label
127 advertised by that peer
129 .. code-block:: console
131 $ ip route add table 2 10.10.10.0/24 via 10.0.0.2 next-hop-table 0 out-label 122
132 $ ip route add table 2 10.10.10.0/24 via 10.0.0.1 next-hop-table 0 out-label 121
134 Step 4; add a route via the eBGP peer
136 .. code-block:: console
138 $ ip route add table 2 10.10.20.0/24 via 172.16.0.1 next-hop-table 2
140 Step 5; depending on the label allocation scheme used, add routes to
141 the MPLS FIB to accept incoming labelled packets:
143 #. per-prefix label scheme - this command 'binds' the label to the same
144 forwarding as the IP route
146 .. code-block:: console
148 $ mpls local-label 99 10.10.20.0/24
150 #. per-CE label scheme - this pops the incoming label and forwards via
151 the next-hop provided. Append config for 'out-labels' if so desired.
153 .. code-block:: console
155 $ mpls local-label 99 via 172.16.0.1 next-hop-table 2
157 #. per-VRF label scheme
159 .. code-block:: console
161 $ mpls local-label 99 via ip4-lookup-in-table 2
166 MPLS tunnels are unidirectional and can impose a stack of labels. They
167 are 'normal' interfaces and thus can be used, for example, as the
168 target for IP routes and L2 cross-connects. To construct a tunnel:
170 .. code-block:: console
172 $ mpls tunnel add via 10.10.10.10 GigEthernet0/0/0 out-labels 33 44 55
174 and to then have that created tunnel to perform ECMP:
176 .. code-block:: console
178 $ mpls tunnel add mpls-tunnel0 via 10.10.10.11 GigEthernet0/0/0 out-labels 66 77 88
182 .. code-block:: console
186 to see the monster you have created.
188 An MPLS tunnel interface is an interface like any other and now ready
189 for use with the usual set of interface commands, e.g.:
191 .. code-block:: console
193 $ set interface state mpls-tunnel0 up
194 $ set interface ip address mpls-tunnel0 192.168.1.1/30
195 $ ip route 1.1.1.1/32 via mpls-tunnel0