Fix MRI project list
[docs.git] / docs / user-guide / bgpcep-guide / bgp / bgp-user-guide-bgp-peering.rst
1 .. _bgp-user-guide-bgp-peering:
2
3 BGP Peering
4 ===========
5 To exchange routing information between two BGP systems (peers), it is required to configure a peering on both BGP speakers first.
6 This mean that each BGP speaker has a white list of neighbors, representing remote peers, with which the peering is allowed.
7 The TCP connection is established between two peers and they exchange messages to open and confirm the connection parameters followed by routes exchange.
8
9 Here is a sample basic neighbor configuration:
10
11 **URL:** ``/restconf/config/openconfig-network-instance:network-instances/network-instance/global-bgp/openconfig-network-instance:protocols/protocol/openconfig-policy-types:BGP/bgp-example/bgp/neighbors``
12
13 **Method:** ``POST``
14
15 **Content-Type:** ``application/xml``
16
17 **Request Body:**
18
19 .. code-block:: xml
20    :linenos:
21    :emphasize-lines: 2,5,6,11,12,17,19
22
23    <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
24        <neighbor-address>192.0.2.1</neighbor-address>
25        <timers>
26            <config>
27                <hold-time>90</hold-time>
28                <connect-retry>10</connect-retry>
29            </config>
30        </timers>
31        <transport>
32            <config>
33                <remote-port>179</remote-port>
34                <passive-mode>false</passive-mode>
35                <!--<local-address>192.0.2.5</local-address>-->
36            </config>
37        </transport>
38        <config>
39            <peer-type>INTERNAL</peer-type>
40        </config>
41        <afi-safis>
42            ...
43        </afi-safis>
44    </neighbor>
45
46 @line 2: IP address of the remote BGP peer. Also serves as an unique identifier of a neighbor in a list of neighbors.
47
48 @line 5: Proposed number of seconds for value of the Hold Timer. Default value is **90**.
49
50 @line 6: Time interval in seconds between attempts to establish session with the peer. Effective in active mode only. Default value is **30**.
51
52 @line 11: Remote port number to which the local BGP is connecting. Effective in active mode only. Default value **179**.
53
54 @line 12: Wait for peers to issue requests to open a BGP session, rather than initiating sessions from the local router. Default value is **false**.
55
56 @line 13: Optional Local IP (either IPv4 or IPv6) address used to establish connections to the remote peer. Effective in active mode only.
57
58 @line 17: Explicitly designate the peer as internal or external. Default value is **INTERNAL**.
59
60 @line 19: Enable families.
61
62 -----
63
64 Once the remote peer is connected and it advertised routes to local BGP system, routes are stored in peer's RIBs.
65 The RIBs can be checked via REST:
66
67 **URL:** ``/restconf/operational/bgp-rib:bgp-rib/rib/bgp-example/peer/bgp:%2F%2F192.0.2.1``
68
69 **Method:** ``GET``
70
71 **Response Body:**
72
73 .. code-block:: xml
74    :linenos:
75    :emphasize-lines: 8,13,35,40,62,66
76
77    <peer xmlns="urn:opendaylight:params:xml:ns:yang:bgp-rib">
78        <peer-id>bgp://192.0.2.1</peer-id>
79        <supported-tables>
80            <afi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:ipv4-address-family</afi>
81            <safi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:unicast-subsequent-address-family</safi>
82        </supported-tables>
83        <peer-role>ibgp</peer-role>
84        <adj-rib-in>
85            <tables>
86                <afi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:ipv4-address-family</afi>
87                <safi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:unicast-subsequent-address-family</safi>
88                <ipv4-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
89                    <ipv4-route>
90                        <path-id>0</path-id>
91                        <prefix>10.0.0.10/32</prefix>
92                        <attributes>
93                            <as-path></as-path>
94                            <origin>
95                                <value>igp</value>
96                            </origin>
97                            <local-pref>
98                                <pref>100</pref>
99                            </local-pref>
100                            <ipv4-next-hop>
101                                <global>10.10.1.1</global>
102                            </ipv4-next-hop>
103                        </attributes>
104                    </ipv4-route>
105                </ipv4-routes>
106                <attributes>
107                    <uptodate>true</uptodate>
108                </attributes>
109            </tables>
110        </adj-rib-in>
111        <effective-rib-in>
112            <tables>
113                <afi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:ipv4-address-family</afi>
114                <safi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:unicast-subsequent-address-family</safi>
115                <ipv4-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
116                    <ipv4-route>
117                        <path-id>0</path-id>
118                        <prefix>10.0.0.10/32</prefix>
119                        <attributes>
120                            <as-path></as-path>
121                            <origin>
122                                <value>igp</value>
123                            </origin>
124                            <local-pref>
125                                <pref>100</pref>
126                            </local-pref>
127                            <ipv4-next-hop>
128                                <global>10.10.1.1</global>
129                            </ipv4-next-hop>
130                        </attributes>
131                    </ipv4-route>
132                </ipv4-routes>
133                <attributes>
134                    <uptodate>true</uptodate>
135                </attributes>
136            </tables>
137        </effective-rib-in>
138        <adj-rib-out>
139            <tables>
140                <afi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:ipv4-address-family</afi>
141                <safi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:unicast-subsequent-address-family</safi>
142                <ipv4-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet"></ipv4-routes>
143                <attributes></attributes>
144            </tables>
145        </adj-rib-out>
146    </peer>
147
148 @line 8: **Adj-RIB-In** - Per-peer RIB, which contains unprocessed routes that has been advertised to local BGP speaker by the remote peer.
149
150 @line 13: Here is the reported route with destination *10.0.0.10/32* in Adj-RIB-In.
151
152 @line 35: **Effective-RIB-In** - Per-peer RIB, which contains processed routes as a result of applying inbound policy to Adj-RIB-In routes.
153
154 @line 40: Here is the reported route with destination *10.0.0.10/32*, same as in Adj-RIB-In, as it was not touched by import policy.
155
156 @line 62: **Adj-RIB-Out** - Per-peer RIB, which contains routes for advertisement to the peer by means of the local speaker's UPDATE message.
157
158 @line 66: The peer's Adj-RIB-Out is empty as there are no routes to be advertise from local BGP speaker.
159
160 -----
161
162 Also the same route should appeared in Loc-RIB now:
163
164 **URL:** ``/restconf/operational/bgp-rib:bgp-rib/rib/bgp-example/loc-rib/tables/bgp-types:ipv4-address-family/bgp-types:unicast-subsequent-address-family/ipv4-routes``
165
166 **Method:** ``GET``
167
168 **Response Body:**
169
170 .. code-block:: xml
171    :linenos:
172    :emphasize-lines: 4,6,8,11,14
173
174    <ipv4-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
175        <ipv4-route>
176            <path-id>0</path-id>
177            <prefix>10.0.0.10/32</prefix>
178            <attributes>
179                <as-path></as-path>
180                <origin>
181                    <value>igp</value>
182                </origin>
183                <local-pref>
184                    <pref>100</pref>
185                </local-pref>
186                <ipv4-next-hop>
187                    <global>10.10.1.1</global>
188                </ipv4-next-hop>
189            </attributes>
190        </ipv4-route>
191    </ipv4-routes>
192
193 @line 4: **Destination** - IPv4 Prefix Address.
194
195 @line 6: **AS_PATH** - mandatory attribute, contains a list of the autonomous system numbers through that routing information has traversed.
196
197 @line 8: **ORIGIN** - mandatory attribute, indicates an origin of the route - **ibgp**, **egp**, **incomplete**.
198
199 @line 11: **LOCAL_PREF** - indicates a degree of preference for external routes, higher value is preferred.
200
201 @line 14: **NEXT_HOP** - mandatory attribute, defines IP address of the router that should be used as the next hop to the destination.
202
203 -----
204
205 There are much more attributes that may be carried along with the destination:
206
207 **BGP-4 Path Attributes**
208
209 * **MULTI_EXIT_DISC** (MED)
210    Optional attribute, to be used to discriminate among multiple exit/entry points on external links, lower number is preferred.
211
212    .. code-block:: xml
213
214       <multi-exit-disc>
215        <med>0</med>
216       </multi-exit-disc>
217
218
219 * **ATOMIC_AGGREGATE**
220    Indicates whether AS_SET was excluded from AS_PATH due to routes aggregation.
221
222    .. code-block:: xml
223
224       <atomic-aggregate/>
225
226 * **AGGREGATOR**
227    Optional attribute, contains AS number and IP address of a BGP speaker which performed routes aggregation.
228
229    .. code-block:: xml
230
231       <aggregator>
232           <as-number>65000</as-number>
233           <network-address>192.0.2.2</network-address>
234       </aggregator>
235
236 * **Unrecognised**
237    Optional attribute, used to store optional attributes, unrecognized by a local BGP speaker.
238
239    .. code-block:: xml
240
241       <unrecognized-attributes>
242           <partial>true</partial>
243           <transitive>true</transitive>
244           <type>101</type>
245           <value>0101010101010101</value>
246       </unrecognized-attributes>
247
248 **Route Reflector Attributes**
249
250 * **ORIGINATOR_ID**
251    Optional attribute, carries BGP Identifier of the originator of the route.
252
253    .. code-block:: xml
254
255       <originator-id>
256           <originator>41.41.41.41</originator>
257       </originator-id>
258
259 * **CLUSTER_LIST**
260    Optional attribute, contains a list of CLUSTER_ID values representing the path that the route has traversed.
261
262    .. code-block:: xml
263
264       <cluster-id>
265           <cluster>40.40.40.40</cluster>
266       </cluster-id>
267
268 * **Communities**
269    Optional attribute, may be used for policy routing.
270
271    .. code-block:: xml
272
273       <communities>
274           <as-number>65000</as-number>
275           <semantics>30740</semantics>
276       </communities>
277
278 **Extended Communities**
279
280 * **Route Target**
281    Identifies one or more routers that may receive a route.
282
283    .. code-block:: xml
284
285       <extended-communities>
286           <transitive>true</transitive>
287           <route-target-ipv4>
288               <global-administrator>192.0.2.2</global-administrator>
289               <local-administrator>123</local-administrator>
290           </route-target-ipv4>
291       </extended-communities>
292       <extended-communities>
293           <transitive>true</transitive>
294           <as-4-route-target-extended-community>
295                   <as-4-specific-common>
296                   <as-number>65000</as-number>
297                   <local-administrator>123</local-administrator>
298               </as-4-specific-common>
299           </as-4-route-target-extended-community>
300       </extended-communities>
301
302
303 * **Route Origin**
304    Identifies one or more routers that injected a route.
305
306    .. code-block:: xml
307
308       <extended-communities>
309           <transitive>true</transitive>
310           <route-origin-ipv4>
311               <global-administrator>192.0.2.2</global-administrator>
312               <local-administrator>123</local-administrator>
313           </route-origin-ipv4>
314       </extended-communities>
315       <extended-communities>
316           <transitive>true</transitive>
317           <as-4-route-origin-extended-community>
318               <as-4-specific-common>
319                   <as-number>65000</as-number>
320                   <local-administrator>123</local-administrator>
321               </as-4-origin-common>
322           </as-4-route-target-extended-community>
323       </extended-communities>
324
325
326 * **Link Bandwidth**
327    Carries the cost to reach external neighbor.
328
329    .. code-block:: xml
330
331       <extended-communities>
332           <transitive>true</transitive>
333           <link-bandwidth-extended-community>
334               <bandwidth>BH9CQAA=</bandwidth>
335           </link-bandwidth-extended-community>
336       </extended-communities>
337
338 * **AIGP**
339    Optional attribute, carries accumulated IGP metric.
340
341    .. code-block:: xml
342
343       <aigp>
344           <aigp-tlv>
345               <metric>120</metric>
346           </aigp-tlv>
347       </aigp>
348
349
350 .. note:: When the remote peer disconnects, it disappear from operational state of local speaker instance and advertised routes are removed too.
351
352 External peering configuration
353 ''''''''''''''''''''''''''''''
354 An example above provided configuration for internal peering only.
355 Following configuration sample is intended for external peering:
356
357 **URL:** ``/restconf/config/openconfig-network-instance:network-instances/network-instance/global-bgp/openconfig-network-instance:protocols/protocol/openconfig-policy-types:BGP/bgp-example/bgp/neighbors``
358
359 **Method:** ``POST``
360
361 **Content-Type:** ``application/xml``
362
363 **Request Body:**
364
365 .. code-block:: xml
366    :linenos:
367    :emphasize-lines: 5
368
369    <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
370        <neighbor-address>192.0.2.3</neighbor-address>
371        <config>
372            <peer-type>EXTERNAL</peer-type>
373            <peer-as>64999</peer-as>
374        </config>
375    </neighbor>
376
377 @line 5: AS number of the remote peer.
378
379 Local AS
380 ''''''''
381
382 .. figure:: ./images/local-as.png
383    :alt: BGP eBGP with Local AS setup.
384
385 The local-AS feature allows a router(eBGP) to appear to be a member of a second autonomous system (AS), in addition to its real AS.
386
387 In above figure, R3 is eBGP router with configured local-as of 62, and peer-as of 63.
388
389 In updates sent from R3 to R2, the AS_SEQUENCE in the AS_PATH attribute contains "62 63". And updates sent from R2 to R3, the AS_SEQUENCE in the AS_PATH attribute contains "62 65".
390
391 AS 62 will be prepended to updates that are sent to and received from R3.
392
393 Following configuration sample is intended for external peering with Local AS:
394
395 **URL:** ``/restconf/config/openconfig-network-instance:network-instances/network-instance/global-bgp/openconfig-network-instance:protocols/protocol/openconfig-policy-types:BGP/bgp-example/bgp/neighbors``
396
397 **Method:** ``POST``
398
399 **Content-Type:** ``application/xml``
400
401 **Request Body:**
402
403 .. code-block:: xml
404    :linenos:
405    :emphasize-lines: 5,6
406
407    <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
408        <neighbor-address>192.0.2.3</neighbor-address>
409        <config>
410            <peer-type>EXTERNAL</peer-type>
411            <peer-as>63</peer-as>
412            <local-as>62</local-as>
413        </config>
414    </neighbor>
415
416 @line 5: AS number of the remote peer.
417
418 @line 6: Local AS number of the remote peer.
419
420 Route reflector configuration
421 '''''''''''''''''''''''''''''
422 The local BGP speaker can be configured with a specific *cluster ID*.
423 Following example adds the cluster ID to the existing speaker instance:
424
425 **URL:** ``/restconf/config/openconfig-network-instance:network-instances/network-instance/global-bgp/openconfig-network-instance:protocols/protocol/openconfig-policy-types:BGP/bgp-example/bgp/global/config``
426
427 **Method:** ``PUT``
428
429 **Content-Type:** ``application/xml``
430
431 **Request Body:**
432
433 .. code-block:: xml
434    :linenos:
435    :emphasize-lines: 4
436
437    <config>
438        <router-id>192.0.2.2</router-id>
439        <as>65000</as>
440        <route-reflector-cluster-id>192.0.2.1</route-reflector-cluster-id>
441    </config>
442
443 @line 4: Route-reflector cluster id to use when local router is configured as a route reflector.
444    The *router-id* is used as a default value.
445
446 -----
447
448 Following configuration sample is intended for route reflector client peering:
449
450 **URL:** ``/restconf/config/openconfig-network-instance:network-instances/network-instance/global-bgp/openconfig-network-instance:protocols/protocol/openconfig-policy-types:BGP/bgp-example/bgp/neighbors``
451
452 **Method:** ``POST``
453
454 **Content-Type:** ``application/xml``
455
456 **Request Body:**
457
458 .. code-block:: xml
459    :linenos:
460    :emphasize-lines: 8
461
462    <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
463        <neighbor-address>192.0.2.4</neighbor-address>
464        <config>
465            <peer-type>INTERNAL</peer-type>
466        </config>
467        <route-reflector>
468            <config>
469                <route-reflector-client>true</route-reflector-client>
470            </config>
471        </route-reflector>
472    </neighbor>
473
474 @line 8: Configure the neighbor as a route reflector client. Default value is *false*.
475
476 Route reflector and Multiple Cluster IDs
477 ''''''''''''''''''''''''''''''''''''''''
478
479 An optional non-transitive attribute called CLUSTER_LIST is modified when a route reflector reflects a prefix. 
480 For loop prevention the route reflector adds its own cluster ID to, and discards any update containing router's own cluster ID. 
481 Using multiple cluster IDs allows updates to propagate to nodes that reside in a different cluster.
482
483
484 .. figure:: ./images/MultipleClustersIds.png
485    :alt: BGP RR Multiple Cluster IDs setup.
486
487 Following configuration sample is intended for route reflector client peering using specific cluster id:
488
489 **URL:** ``/restconf/config/openconfig-network-instance:network-instances/network-instance/global-bgp/openconfig-network-instance:protocols/protocol/openconfig-policy-types:BGP/bgp-example/bgp/neighbors``
490
491 **Method:** ``POST``
492
493 **Content-Type:** ``application/xml``
494
495 **Request Body:**
496
497 .. code-block:: xml
498    :linenos:
499    :emphasize-lines: 8,9
500
501    <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
502        <neighbor-address>192.0.2.4</neighbor-address>
503        <config>
504            <peer-type>INTERNAL</peer-type>
505        </config>
506        <route-reflector>
507            <config>
508                <route-reflector-client>true</route-reflector-client>
509                <route-reflector-cluster-id>192.0.2.4</route-reflector-cluster-id>
510            </config>
511        </route-reflector>
512    </neighbor>
513
514 @line 8: Configure the neighbor as a route reflector client. Default value is *false*.
515
516 @line 9: Route-reflector cluster id to use for this specific neighbor when local router is configured as a route reflector.
517
518 MD5 authentication configuration
519 ''''''''''''''''''''''''''''''''
520 The OpenDaylight BGP implementation is supporting TCP MD5 for authentication.
521 Sample configuration below shows how to set authentication password for a peer:
522
523 **URL:** ``/restconf/config/openconfig-network-instance:network-instances/network-instance/global-bgp/openconfig-network-instance:protocols/protocol/openconfig-policy-types:BGP/bgp-example/bgp/neighbors``
524
525 **Method:** ``POST``
526
527 **Content-Type:** ``application/xml``
528
529 **Request Body:**
530
531 .. code-block:: xml
532    :linenos:
533    :emphasize-lines: 4
534
535    <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
536        <neighbor-address>192.0.2.5</neighbor-address>
537        <config>
538            <auth-password>topsecret</auth-password>
539        </config>
540    </neighbor>
541
542 @line 4: Configures an MD5 authentication password for use with neighboring devices.
543
544 BGP Peer Group
545 ''''''''''''''
546
547 Allows the creation of a peer group configuration that applies to all peers configured as part of the group.
548
549 A sample peer group configuration follows:
550
551 **URL:** ``/restconf/config/openconfig-network-instance:network-instances/network-instance/global-bgp/openconfig-network-instance:protocols/protocol/openconfig-policy-types:BGP/bgp-example/bgp/peer-groups``
552
553 **Method:** ``POST``
554
555 **Content-Type:** ``application/xml``
556
557 **Request Body:**
558
559 .. code-block:: xml
560    :linenos:
561    :emphasize-lines: 2
562
563    <peer-group xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
564        <peer-group-name>internal-neighbor</peer-group-name>
565        <config>
566            <peer-type>INTERNAL</peer-type>
567            <peer-as>64496</peer-as>
568        </config>
569        <transport>
570            <config>
571                <remote-port>179</remote-port>
572                <passive-mode>true</passive-mode>
573            </config>
574        </transport>
575        <timers>
576            <config>
577                <hold-time>180</hold-time>
578                <connect-retry>10</connect-retry>
579            </config>
580        </timers>
581        <route-reflector>
582            <config>
583                <route-reflector-client>false</route-reflector-client>
584            </config>
585        </route-reflector>
586        <afi-safis>
587            <afi-safi>
588                <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV4-UNICAST</afi-safi-name>
589                <!--Advertise N Paths
590                <receive>true</receive>
591                <send-max>0</send-max>-->
592            </afi-safi>
593            <afi-safi>
594                <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV6-UNICAST</afi-safi-name>
595            </afi-safi>
596            <afi-safi>
597                <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV4-LABELLED-UNICAST</afi-safi-name>
598            </afi-safi>
599            <afi-safi>
600                <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV6-LABELLED-UNICAST</afi-safi-name>
601            </afi-safi>
602            <afi-safi>
603                <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:L3VPN-IPV4-UNICAST</afi-safi-name>
604            </afi-safi>
605            <afi-safi>
606                <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:L3VPN-IPV6-UNICAST</afi-safi-name>
607            </afi-safi>
608            <afi-safi>
609                <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:L2VPN-EVPN</afi-safi-name>
610            </afi-safi>
611            <afi-safi>
612                <afi-safi-name>LINKSTATE</afi-safi-name>
613            </afi-safi>
614            <afi-safi>
615                <afi-safi-name>IPV4-FLOW</afi-safi-name>
616            </afi-safi>
617            <afi-safi>
618                <afi-safi-name>IPV6-FLOW</afi-safi-name>
619            </afi-safi>
620            <afi-safi>
621                <afi-safi-name>IPV4-L3VPN-FLOW</afi-safi-name>
622            </afi-safi>
623            <afi-safi>
624                <afi-safi-name>IPV6-L3VPN-FLOW</afi-safi-name>
625            </afi-safi>
626        </afi-safis>
627    </peer-group>
628
629 @line 2: Peer Group Identifier.
630
631 -----
632
633 A sample basic neighbor configuration using a peer group follows:
634
635 **URL:** ``/restconf/config/openconfig-network-instance:network-instances/network-instance/global-bgp/openconfig-network-instance:protocols/protocol/openconfig-policy-types:BGP/bgp-example/bgp/neighbors``
636
637 **Method:** ``POST``
638
639 **Content-Type:** ``application/xml``
640
641 **Request Body:**
642
643 .. code-block:: xml
644    :linenos:
645    :emphasize-lines: 4
646
647    <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
648       <neighbor-address>192.0.2.1</neighbor-address>
649       <config>
650          <peer-group>/bgp/neighbors/neighbor/bgp/peer-groups/peer-group[peer-group-name="internal-neighbor"]</peer-group>
651       </config>
652    </neighbor>
653
654 @line 4: Peer group identifier.
655
656 .. note:: Existing neighbor configuration can be reconfigured (change configuration parameters) anytime.
657    As a result, established connection is dropped, peer instance is recreated with a new configuration settings and connection re-established.
658
659 .. note:: The BGP configuration is persisted on OpendDaylight shutdown and restored after the re-start.