Route reflector cluster id doc
[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 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".
388
389 AS 62 will be prepended to updates that are sent to and received from R3.
390
391 Following configuration sample is intended for external peering with Local AS:
392
393 **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``
394
395 **Method:** ``POST``
396
397 **Content-Type:** ``application/xml``
398
399 **Request Body:**
400
401 .. code-block:: xml
402    :linenos:
403    :emphasize-lines: 5,6
404
405    <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
406        <neighbor-address>192.0.2.3</neighbor-address>
407        <config>
408            <peer-type>EXTERNAL</peer-type>
409            <peer-as>64999</peer-as>
410            <local-as>65100</local-as>
411        </config>
412    </neighbor>
413
414 @line 5: AS number of the remote peer.
415
416 @line 6: Local AS number of the remote peer.
417
418 Route reflector configuration
419 '''''''''''''''''''''''''''''
420 The local BGP speaker can be configured with a specific *cluster ID*.
421 Following example adds the cluster ID to the existing speaker instance:
422
423 **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``
424
425 **Method:** ``PUT``
426
427 **Content-Type:** ``application/xml``
428
429 **Request Body:**
430
431 .. code-block:: xml
432    :linenos:
433    :emphasize-lines: 4
434
435    <config>
436        <router-id>192.0.2.2</router-id>
437        <as>65000</as>
438        <route-reflector-cluster-id>192.0.2.1</route-reflector-cluster-id>
439    </config>
440
441 @line 4: Route-reflector cluster id to use when local router is configured as a route reflector.
442    The *router-id* is used as a default value.
443
444 -----
445
446 Following configuration sample is intended for route reflector client peering:
447
448 **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``
449
450 **Method:** ``POST``
451
452 **Content-Type:** ``application/xml``
453
454 **Request Body:**
455
456 .. code-block:: xml
457    :linenos:
458    :emphasize-lines: 8
459
460    <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
461        <neighbor-address>192.0.2.4</neighbor-address>
462        <config>
463            <peer-type>INTERNAL</peer-type>
464        </config>
465        <route-reflector>
466            <config>
467                <route-reflector-client>true</route-reflector-client>
468            </config>
469        </route-reflector>
470    </neighbor>
471
472 @line 8: Configure the neighbor as a route reflector client. Default value is *false*.
473
474 Route reflector and Multiple Cluster IDs
475 ''''''''''''''''''''''''''''''''''''''''
476
477 An optional non-transitive attribute called CLUSTER_LIST is modified when a route reflector reflects a prefix. 
478 For loop prevention the route reflector adds its own cluster ID to, and discards any update containing router's own cluster ID. 
479 Using multiple cluster IDs allows updates to propagate to nodes that reside in a different cluster.
480
481
482 .. figure:: ./images/MultipleClustersIds.png
483    :alt: BGP RR Multiple Cluster IDs setup.
484
485 Following configuration sample is intended for route reflector client peering using specific cluster id:
486
487 **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``
488
489 **Method:** ``POST``
490
491 **Content-Type:** ``application/xml``
492
493 **Request Body:**
494
495 .. code-block:: xml
496    :linenos:
497    :emphasize-lines: 8,9
498
499    <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
500        <neighbor-address>192.0.2.4</neighbor-address>
501        <config>
502            <peer-type>INTERNAL</peer-type>
503        </config>
504        <route-reflector>
505            <config>
506                <route-reflector-client>true</route-reflector-client>
507                <route-reflector-cluster-id>192.0.2.4</route-reflector-cluster-id>
508            </config>
509        </route-reflector>
510    </neighbor>
511
512 @line 8: Configure the neighbor as a route reflector client. Default value is *false*.
513
514 @line 9: Route-reflector cluster id to use for this specific neighbor when local router is configured as a route reflector.
515
516 MD5 authentication configuration
517 ''''''''''''''''''''''''''''''''
518 The OpenDaylight BGP implementation is supporting TCP MD5 for authentication.
519 Sample configuration below shows how to set authentication password for a peer:
520
521 **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``
522
523 **Method:** ``POST``
524
525 **Content-Type:** ``application/xml``
526
527 **Request Body:**
528
529 .. code-block:: xml
530    :linenos:
531    :emphasize-lines: 4
532
533    <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
534        <neighbor-address>192.0.2.5</neighbor-address>
535        <config>
536            <auth-password>topsecret</auth-password>
537        </config>
538    </neighbor>
539
540 @line 4: Configures an MD5 authentication password for use with neighboring devices.
541
542 BGP Peer Group
543 ''''''''''''''
544
545 Allows the creation of a peer group configuration that applies to all peers configured as part of the group.
546
547 A sample peer group configuration follows:
548
549 **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``
550
551 **Method:** ``POST``
552
553 **Content-Type:** ``application/xml``
554
555 **Request Body:**
556
557 .. code-block:: xml
558    :linenos:
559    :emphasize-lines: 2
560
561    <peer-group xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
562        <peer-group-name>internal-neighbor</peer-group-name>
563        <config>
564            <peer-type>INTERNAL</peer-type>
565            <peer-as>64496</peer-as>
566        </config>
567        <transport>
568            <config>
569                <remote-port>179</remote-port>
570                <passive-mode>true</passive-mode>
571            </config>
572        </transport>
573        <timers>
574            <config>
575                <hold-time>180</hold-time>
576                <connect-retry>10</connect-retry>
577            </config>
578        </timers>
579        <route-reflector>
580            <config>
581                <route-reflector-client>false</route-reflector-client>
582            </config>
583        </route-reflector>
584        <afi-safis>
585            <afi-safi>
586                <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV4-UNICAST</afi-safi-name>
587                <!--Advertise N Paths
588                <receive>true</receive>
589                <send-max>0</send-max>-->
590            </afi-safi>
591            <afi-safi>
592                <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV6-UNICAST</afi-safi-name>
593            </afi-safi>
594            <afi-safi>
595                <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV4-LABELLED-UNICAST</afi-safi-name>
596            </afi-safi>
597            <afi-safi>
598                <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV6-LABELLED-UNICAST</afi-safi-name>
599            </afi-safi>
600            <afi-safi>
601                <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:L3VPN-IPV4-UNICAST</afi-safi-name>
602            </afi-safi>
603            <afi-safi>
604                <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:L3VPN-IPV6-UNICAST</afi-safi-name>
605            </afi-safi>
606            <afi-safi>
607                <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:L2VPN-EVPN</afi-safi-name>
608            </afi-safi>
609            <afi-safi>
610                <afi-safi-name>LINKSTATE</afi-safi-name>
611            </afi-safi>
612            <afi-safi>
613                <afi-safi-name>IPV4-FLOW</afi-safi-name>
614            </afi-safi>
615            <afi-safi>
616                <afi-safi-name>IPV6-FLOW</afi-safi-name>
617            </afi-safi>
618            <afi-safi>
619                <afi-safi-name>IPV4-L3VPN-FLOW</afi-safi-name>
620            </afi-safi>
621            <afi-safi>
622                <afi-safi-name>IPV6-L3VPN-FLOW</afi-safi-name>
623            </afi-safi>
624        </afi-safis>
625    </peer-group>
626
627 @line 2: Peer Group Identifier.
628
629 -----
630
631 A sample basic neighbor configuration using a peer group follows:
632
633 **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``
634
635 **Method:** ``POST``
636
637 **Content-Type:** ``application/xml``
638
639 **Request Body:**
640
641 .. code-block:: xml
642    :linenos:
643    :emphasize-lines: 4
644
645    <neighbor>
646       <neighbor-address>192.0.2.1</neighbor-address>
647       <config>
648          <peer-group>/bgp/neighbors/neighbor/bgp/peer-groups/peer-group[peer-group-name="internal-neighbor"]</peer-group>
649       </config>
650    </neighbor>
651
652 @line 4: Peer group identifier.
653
654 .. note:: Existing neighbor configuration can be reconfigured (change configuration parameters) anytime.
655    As a result, established connection is dropped, peer instance is recreated with a new configuration settings and connection re-established.
656
657 .. note:: The BGP configuration is persisted on OpendDaylight shutdown and restored after the re-start.