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