blob: c9f3d5d9ad11f12d60146db8368f809603a56bad [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 Ranns75c276f2018-08-31 00:45:19 -070092#. mpls local-label 33 eos ip4-lookup-in-table X
93#. mpls local-label 33 [eos] via 10.10.10.10 GigEthernet0/0/0
94#. mpls local-label 33 [eos] via 10.10.10.10 GigEthernet0/0/0 out-labels 66
jdenisco0923a232018-08-29 13:19:43 -040095
Neale Ranns75c276f2018-08-31 00:45:19 -070096the latter is an example of an MPLS cross connect. Any description of
97a next-hop, recursive, non-recursive, labelled, non-labelled, etc,
98that is valid for an IP prefix, is also valid for an MPLS
99local-label. Note the use of the 'eos' keyword which indicates the
100programming is for the case when the label is end-of-stack. The last
101two operations can apply to both eos and non-eos packets, but the pop
102and IP lookup only to an eos packet.
jdenisco0923a232018-08-29 13:19:43 -0400103
jdenisco0923a232018-08-29 13:19:43 -0400104
Neale Ranns75c276f2018-08-31 00:45:19 -0700105MPLS VPN
106^^^^^^^^
jdenisco0923a232018-08-29 13:19:43 -0400107
Neale Ranns75c276f2018-08-31 00:45:19 -0700108To configure an MPLS VPN for a PE the follow example can be used.
jdenisco0923a232018-08-29 13:19:43 -0400109
Neale Ranns75c276f2018-08-31 00:45:19 -0700110Step 1; Configure routes to the iBGP peers - note these route MUST
111have out-going labels;
jdenisco0923a232018-08-29 13:19:43 -0400112
113.. code-block:: console
114
Neale Ranns75c276f2018-08-31 00:45:19 -0700115 $ ip route add 10.0.0.1/32 via 192.168.1.2 Eth0 out-labels 33
116 $ ip route add 10.0.0.2/32 via 192.168.2.2 Eth0 out-labels 34
jdenisco0923a232018-08-29 13:19:43 -0400117
Neale Ranns75c276f2018-08-31 00:45:19 -0700118Step 2; Configure the customer 'VRF'
jdenisco0923a232018-08-29 13:19:43 -0400119
Neale Ranns75c276f2018-08-31 00:45:19 -0700120.. code-block:: console
121
122 $ ip table add 2
123
124Step 3; add a route via the iBGP peer[s] with the MPLS label
125advertised by that peer
126
127.. code-block:: console
128
129 $ ip route add table 2 10.10.10.0/24 via 10.0.0.2 next-hop-table 0 out-label 122
130 $ ip route add table 2 10.10.10.0/24 via 10.0.0.1 next-hop-table 0 out-label 121
131
132Step 4; add a route via the eBGP peer
133
134.. code-block:: console
135
136 $ ip route add table 2 10.10.20.0/24 via 172.16.0.1 next-hop-table 2
137
138Step 5; depending on the label allocation scheme used, add routes to
139the MPLS FIB to accept incoming labelled packets:
140
141#. per-prefix label scheme - this command 'binds' the label to the same
142 forwarding as the IP route
143
144 .. code-block:: console
145
146 $ mpls local-label 99 10.10.20.0/24
147
148#. per-CE label scheme - this pops the incoming label and forwards via
149 the next-hop provided. Append config for 'out-labels' if so desired.
150
151 .. code-block:: console
152
153 $ mpls local-label 99 via 172.16.0.1 next-hop-table 2
154
155#. per-VRF label scheme
156
157 .. code-block:: console
158
159 $ mpls local-label 99 via ip4-lookup-in-table 2
160
161MPLS Tunnels
162^^^^^^^^^^^^
163
164MPLS tunnels are unidirectional and can impose a stack of labels. They
165are 'normal' interfaces and thus can be used, for example, as the
166target for IP routes and L2 cross-connects. To construct a tunnel:
167
168.. code-block:: console
169
170 $ mpls tunnel add via 10.10.10.10 GigEthernet0/0/0 out-labels 33 44 55
171
172and to then have that created tunnel to perform ECMP:
173
174.. code-block:: console
175
176 $ mpls tunnel add mpls-tunnel0 via 10.10.10.11 GigEthernet0/0/0 out-labels 66 77 88
177
178use
179
180.. code-block:: console
181
182 $ sh mpls tunnel [X]
183
184to see the monster you have created.
185
186An MPLS tunnel interface is an interface like any other and now ready
187for use with the usual set of interface commands, e.g.:
188
189.. code-block:: console
190
191 $ set interface state mpls-tunnel0 up
192 $ set interface ip address mpls-tunnel0 192.168.1.1/30
193 $ ip route 1.1.1.1/32 via mpls-tunnel0