blob: 6b14732214b9dbd4b5b5ae74851efc69c79a738d [file] [log] [blame]
jdenisco0923a232018-08-29 13:19:43 -04001.. _mplsfib:
2
3MPLS FIB
Neale Ranns75c276f2018-08-31 00:45:19 -07004--------
jdenisco0923a232018-08-29 13:19:43 -04005
Neale Ranns75c276f2018-08-31 00:45:19 -07006Implementation
7^^^^^^^^^^^^^^^
8
9The MPLS FIB is implemented using exactly the same data structures as
10the IP FIB. The only difference is the implementation of the
11table. Whereas for IPv4 this is an mtrie and for IPv6 a hash table,
12for MPLS it is a flat array indexed by a 21 bit key (label & EOS
13bit). This implementation is chosen to favour packet forwarding speed.
14
15Basics
16^^^^^^
17
18MPLS is not enabled by default. There are two steps to get
19started. First, create the default MPLS FIB:
jdenisco0923a232018-08-29 13:19:43 -040020
21.. code-block:: console
22
Neale Ranns75c276f2018-08-31 00:45:19 -070023 $ mpls table add 0
jdenisco0923a232018-08-29 13:19:43 -040024
Neale Ranns75c276f2018-08-31 00:45:19 -070025With '0' being the magic number for the 'default' table (just like it
26is for IPv[46]). One can create other MPLS tables, but, unlike IP
27tables, one cannot 'bind' non-default MPLS tables to interfaces, in
28other words all MPLS packets received on an interface will always
29result in a lookup in the default table. One has to be more inventive
30to use the non-default tables...
31
32Secondly, for *each* interface on which you wish to *receive* MPLS
33packets, that interface must be MPLS 'enabled'
jdenisco0923a232018-08-29 13:19:43 -040034
35.. code-block:: console
36
Neale Ranns75c276f2018-08-31 00:45:19 -070037 $ set interface mpls GigEthernet0/0/0 enable
jdenisco0923a232018-08-29 13:19:43 -040038
Neale Ranns75c276f2018-08-31 00:45:19 -070039there is no equivalent enable for transmit, all that is required is to
40use an interface as an egress path.
jdenisco0923a232018-08-29 13:19:43 -040041
Neale Ranns75c276f2018-08-31 00:45:19 -070042Entries in the MPLS FIB can be displayed with:
43
44.. code-block:: console
45
46 $ sh mpls fib [table X] [label]
47
48There is a tight coupling between IP and MPLS forwarding. MPLS
49forwarding equivalence classes (FECs) are often an IP prefix that is
50to say that traffic matching a given IP prefix is routed into a MPLS
51label switch path (LSP). It is thus necessary to be able to associated
52a given prefix/route with an [out-going] MPLS label that will be
53imposed when the packet is forwarded. This is configured as:
54
55.. code-block:: console
56
57 $ ip route add 1.1.1.1/32 via 10.10.10.10 GigEthernet0/0/0 out-labels 33
58
59packets matching 1.1.1.1/32 will be forwarded out GigEthernet0/0/0 and have
60MPLS label 33 imposed. More than one out-going label can be
61specified. Out-going MPLS labels can be applied to recursive and
62non-recursive routes, e.g;
63
64.. code-block:: console
65
66 $ ip route add 2.2.2.0/24 via 1.1.1.1 out-labels 34
67
68packets matching 2.2.2.0/24 will thus have two MPLS labels imposed; 34
69and 33. This is the realisation of, e,g, an MPLS BGP VPNv4.
70
71To associate/allocate a local-label for a prefix, and thus have
72packets to that local-label forwarded equivalently to the prefix do;
jdenisco0923a232018-08-29 13:19:43 -040073
74.. code-block:: console
75
76 $ mpls local-label 99 2.2.2.0/24
77
Neale Ranns75c276f2018-08-31 00:45:19 -070078In the API this action is called a bind’.
79The router receiving the MPLS encapsulated packets needs to be
80programmed with actions associated which each label value this is
81the role of the MPLS FIB. The MPLS FIB Is a table, whose key is the
82MPLS label value and end-of-stack (EOS) bit, which stores the action
83to perform on packets with matching encapsulation. Currently supported
84actions are:
jdenisco0923a232018-08-29 13:19:43 -040085
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.
89
90These can be programmed respectively by:
91
Neale Ranns995ff062018-12-06 08:36:55 -080092.. code-block:: console
93
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
jdenisco0923a232018-08-29 13:19:43 -040097
Neale Ranns75c276f2018-08-31 00:45:19 -070098the latter is an example of an MPLS cross connect. Any description of
99a next-hop, recursive, non-recursive, labelled, non-labelled, etc,
100that is valid for an IP prefix, is also valid for an MPLS
101local-label. Note the use of the 'eos' keyword which indicates the
102programming is for the case when the label is end-of-stack. The last
103two operations can apply to both eos and non-eos packets, but the pop
104and IP lookup only to an eos packet.
jdenisco0923a232018-08-29 13:19:43 -0400105
jdenisco0923a232018-08-29 13:19:43 -0400106
Neale Ranns75c276f2018-08-31 00:45:19 -0700107MPLS VPN
108^^^^^^^^
jdenisco0923a232018-08-29 13:19:43 -0400109
Neale Ranns75c276f2018-08-31 00:45:19 -0700110To configure an MPLS VPN for a PE the follow example can be used.
jdenisco0923a232018-08-29 13:19:43 -0400111
Neale Ranns75c276f2018-08-31 00:45:19 -0700112Step 1; Configure routes to the iBGP peers - note these route MUST
113have out-going labels;
jdenisco0923a232018-08-29 13:19:43 -0400114
115.. code-block:: console
116
Neale Ranns75c276f2018-08-31 00:45:19 -0700117 $ 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
jdenisco0923a232018-08-29 13:19:43 -0400119
Neale Ranns75c276f2018-08-31 00:45:19 -0700120Step 2; Configure the customer 'VRF'
jdenisco0923a232018-08-29 13:19:43 -0400121
Neale Ranns75c276f2018-08-31 00:45:19 -0700122.. code-block:: console
123
124 $ ip table add 2
125
126Step 3; add a route via the iBGP peer[s] with the MPLS label
127advertised by that peer
128
129.. code-block:: console
130
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
133
134Step 4; add a route via the eBGP peer
135
136.. code-block:: console
137
138 $ ip route add table 2 10.10.20.0/24 via 172.16.0.1 next-hop-table 2
139
140Step 5; depending on the label allocation scheme used, add routes to
141the MPLS FIB to accept incoming labelled packets:
142
143#. per-prefix label scheme - this command 'binds' the label to the same
144 forwarding as the IP route
145
146 .. code-block:: console
147
148 $ mpls local-label 99 10.10.20.0/24
149
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.
152
153 .. code-block:: console
154
155 $ mpls local-label 99 via 172.16.0.1 next-hop-table 2
156
157#. per-VRF label scheme
158
159 .. code-block:: console
160
161 $ mpls local-label 99 via ip4-lookup-in-table 2
162
163MPLS Tunnels
164^^^^^^^^^^^^
165
166MPLS tunnels are unidirectional and can impose a stack of labels. They
167are 'normal' interfaces and thus can be used, for example, as the
168target for IP routes and L2 cross-connects. To construct a tunnel:
169
170.. code-block:: console
171
172 $ mpls tunnel add via 10.10.10.10 GigEthernet0/0/0 out-labels 33 44 55
173
174and to then have that created tunnel to perform ECMP:
175
176.. code-block:: console
177
178 $ mpls tunnel add mpls-tunnel0 via 10.10.10.11 GigEthernet0/0/0 out-labels 66 77 88
179
180use
181
182.. code-block:: console
183
184 $ sh mpls tunnel [X]
185
186to see the monster you have created.
187
188An MPLS tunnel interface is an interface like any other and now ready
189for use with the usual set of interface commands, e.g.:
190
191.. code-block:: console
192
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