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