jdenisco | 0923a23 | 2018-08-29 13:19:43 -0400 | [diff] [blame] | 1 | .. _mplsfib: |
| 2 | |
| 3 | MPLS FIB |
Neale Ranns | 75c276f | 2018-08-31 00:45:19 -0700 | [diff] [blame^] | 4 | -------- |
jdenisco | 0923a23 | 2018-08-29 13:19:43 -0400 | [diff] [blame] | 5 | |
Neale Ranns | 75c276f | 2018-08-31 00:45:19 -0700 | [diff] [blame^] | 6 | Implementation |
| 7 | ^^^^^^^^^^^^^^^ |
| 8 | |
| 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. |
| 14 | |
| 15 | Basics |
| 16 | ^^^^^^ |
| 17 | |
| 18 | MPLS is not enabled by default. There are two steps to get |
| 19 | started. First, create the default MPLS FIB: |
jdenisco | 0923a23 | 2018-08-29 13:19:43 -0400 | [diff] [blame] | 20 | |
| 21 | .. code-block:: console |
| 22 | |
Neale Ranns | 75c276f | 2018-08-31 00:45:19 -0700 | [diff] [blame^] | 23 | $ mpls table add 0 |
jdenisco | 0923a23 | 2018-08-29 13:19:43 -0400 | [diff] [blame] | 24 | |
Neale Ranns | 75c276f | 2018-08-31 00:45:19 -0700 | [diff] [blame^] | 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... |
| 31 | |
| 32 | Secondly, for *each* interface on which you wish to *receive* MPLS |
| 33 | packets, that interface must be MPLS 'enabled' |
jdenisco | 0923a23 | 2018-08-29 13:19:43 -0400 | [diff] [blame] | 34 | |
| 35 | .. code-block:: console |
| 36 | |
Neale Ranns | 75c276f | 2018-08-31 00:45:19 -0700 | [diff] [blame^] | 37 | $ set interface mpls GigEthernet0/0/0 enable |
jdenisco | 0923a23 | 2018-08-29 13:19:43 -0400 | [diff] [blame] | 38 | |
Neale Ranns | 75c276f | 2018-08-31 00:45:19 -0700 | [diff] [blame^] | 39 | there is no equivalent enable for transmit, all that is required is to |
| 40 | use an interface as an egress path. |
jdenisco | 0923a23 | 2018-08-29 13:19:43 -0400 | [diff] [blame] | 41 | |
Neale Ranns | 75c276f | 2018-08-31 00:45:19 -0700 | [diff] [blame^] | 42 | Entries in the MPLS FIB can be displayed with: |
| 43 | |
| 44 | .. code-block:: console |
| 45 | |
| 46 | $ sh mpls fib [table X] [label] |
| 47 | |
| 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: |
| 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 | |
| 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; |
| 63 | |
| 64 | .. code-block:: console |
| 65 | |
| 66 | $ ip route add 2.2.2.0/24 via 1.1.1.1 out-labels 34 |
| 67 | |
| 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. |
| 70 | |
| 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; |
jdenisco | 0923a23 | 2018-08-29 13:19:43 -0400 | [diff] [blame] | 73 | |
| 74 | .. code-block:: console |
| 75 | |
| 76 | $ mpls local-label 99 2.2.2.0/24 |
| 77 | |
Neale Ranns | 75c276f | 2018-08-31 00:45:19 -0700 | [diff] [blame^] | 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 |
| 84 | actions are: |
jdenisco | 0923a23 | 2018-08-29 13:19:43 -0400 | [diff] [blame] | 85 | |
| 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 | |
| 90 | These can be programmed respectively by: |
| 91 | |
Neale Ranns | 75c276f | 2018-08-31 00:45:19 -0700 | [diff] [blame^] | 92 | #. 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 |
jdenisco | 0923a23 | 2018-08-29 13:19:43 -0400 | [diff] [blame] | 95 | |
Neale Ranns | 75c276f | 2018-08-31 00:45:19 -0700 | [diff] [blame^] | 96 | the latter is an example of an MPLS cross connect. Any description of |
| 97 | a next-hop, recursive, non-recursive, labelled, non-labelled, etc, |
| 98 | that is valid for an IP prefix, is also valid for an MPLS |
| 99 | local-label. Note the use of the 'eos' keyword which indicates the |
| 100 | programming is for the case when the label is end-of-stack. The last |
| 101 | two operations can apply to both eos and non-eos packets, but the pop |
| 102 | and IP lookup only to an eos packet. |
jdenisco | 0923a23 | 2018-08-29 13:19:43 -0400 | [diff] [blame] | 103 | |
jdenisco | 0923a23 | 2018-08-29 13:19:43 -0400 | [diff] [blame] | 104 | |
Neale Ranns | 75c276f | 2018-08-31 00:45:19 -0700 | [diff] [blame^] | 105 | MPLS VPN |
| 106 | ^^^^^^^^ |
jdenisco | 0923a23 | 2018-08-29 13:19:43 -0400 | [diff] [blame] | 107 | |
Neale Ranns | 75c276f | 2018-08-31 00:45:19 -0700 | [diff] [blame^] | 108 | To configure an MPLS VPN for a PE the follow example can be used. |
jdenisco | 0923a23 | 2018-08-29 13:19:43 -0400 | [diff] [blame] | 109 | |
Neale Ranns | 75c276f | 2018-08-31 00:45:19 -0700 | [diff] [blame^] | 110 | Step 1; Configure routes to the iBGP peers - note these route MUST |
| 111 | have out-going labels; |
jdenisco | 0923a23 | 2018-08-29 13:19:43 -0400 | [diff] [blame] | 112 | |
| 113 | .. code-block:: console |
| 114 | |
Neale Ranns | 75c276f | 2018-08-31 00:45:19 -0700 | [diff] [blame^] | 115 | $ 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 |
jdenisco | 0923a23 | 2018-08-29 13:19:43 -0400 | [diff] [blame] | 117 | |
Neale Ranns | 75c276f | 2018-08-31 00:45:19 -0700 | [diff] [blame^] | 118 | Step 2; Configure the customer 'VRF' |
jdenisco | 0923a23 | 2018-08-29 13:19:43 -0400 | [diff] [blame] | 119 | |
Neale Ranns | 75c276f | 2018-08-31 00:45:19 -0700 | [diff] [blame^] | 120 | .. code-block:: console |
| 121 | |
| 122 | $ ip table add 2 |
| 123 | |
| 124 | Step 3; add a route via the iBGP peer[s] with the MPLS label |
| 125 | advertised 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 | |
| 132 | Step 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 | |
| 138 | Step 5; depending on the label allocation scheme used, add routes to |
| 139 | the 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 | |
| 161 | MPLS Tunnels |
| 162 | ^^^^^^^^^^^^ |
| 163 | |
| 164 | MPLS tunnels are unidirectional and can impose a stack of labels. They |
| 165 | are 'normal' interfaces and thus can be used, for example, as the |
| 166 | target 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 | |
| 172 | and 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 | |
| 178 | use |
| 179 | |
| 180 | .. code-block:: console |
| 181 | |
| 182 | $ sh mpls tunnel [X] |
| 183 | |
| 184 | to see the monster you have created. |
| 185 | |
| 186 | An MPLS tunnel interface is an interface like any other and now ready |
| 187 | for 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 |