Add and run some linters via tox and pre-commit
[bgpcep.git] / docs / 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 .. tabs::
16
17    .. tab:: XML
18
19       **Content-Type:** ``application/xml``
20
21       **Request Body:**
22
23       .. code-block:: xml
24          :linenos:
25          :emphasize-lines: 2,5,6,11,12,17,19
26
27          <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
28              <neighbor-address>192.0.2.1</neighbor-address>
29              <timers>
30                  <config>
31                      <hold-time>90</hold-time>
32                      <connect-retry>10</connect-retry>
33                  </config>
34              </timers>
35              <transport>
36                  <config>
37                      <remote-port>179</remote-port>
38                      <passive-mode>false</passive-mode>
39                      <!--<local-address>192.0.2.5</local-address>-->
40                  </config>
41              </transport>
42              <config>
43                  <peer-type>INTERNAL</peer-type>
44              </config>
45              <afi-safis>
46                  ...
47              </afi-safis>
48          </neighbor>
49
50       @line 2: IP address of the remote BGP peer. Also serves as an unique identifier of a neighbor in a list of neighbors.
51
52       @line 5: Proposed number of seconds for value of the Hold Timer. Default value is **90**.
53
54       @line 6: Time interval in seconds between attempts to establish session with the peer. Effective in active mode only. Default value is **30**.
55
56       @line 11: Remote port number to which the local BGP is connecting. Effective in active mode only. Default value **179**.
57
58       @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**.
59
60       @line 13: Optional Local IP (either IPv4 or IPv6) address used to establish connections to the remote peer. Effective in active mode only.
61
62       @line 17: Explicitly designate the peer as internal or external. Default value is **INTERNAL**.
63
64       @line 19: Enable families.
65
66    .. tab:: JSON
67
68       **Content-Type:** ``application/json``
69
70       **Request Body:**
71
72       .. code-block:: json
73          :linenos:
74          :emphasize-lines: 4,7,8,13,14,18,20
75
76          {
77              "neighbor": [
78                  {
79                      "neighbor-address": "192.0.2.1",
80                      "timers": {
81                          "config": {
82                              "hold-time": 90,
83                              "connect-retry": 10
84                          }
85                      },
86                      "transport": {
87                          "config": {
88                              "remote-port": 179,
89                              "passive-mode": "false"
90                          }
91                      },
92                      "config": {
93                          "peer-type": "INTERNAL"
94                      }
95                      "afi-safis": "..."
96                  }
97              ]
98          }
99
100       @line 4: IP address of the remote BGP peer. Also serves as an unique identifier of a neighbor in a list of neighbors.
101
102       @line 7: Proposed number of seconds for value of the Hold Timer. Default value is **90**.
103
104       @line 8: Time interval in seconds between attempts to establish session with the peer. Effective in active mode only. Default value is **30**.
105
106       @line 13: Remote port number to which the local BGP is connecting. Effective in active mode only. Default value **179**.
107
108       @line 14: Wait for peers to issue requests to open a BGP session, rather than initiating sessions from the local router. Default value is **false**.
109
110       @line 18: Explicitly designate the peer as internal or external. Default value is **INTERNAL**.
111
112       @line 20: Enable families.
113
114 -----
115
116 Once the remote peer is connected and it advertised routes to local BGP system, routes are stored in peer's RIBs.
117 The RIBs can be checked via REST:
118
119 **URL:** ``/restconf/operational/bgp-rib:bgp-rib/rib/bgp-example/peer/bgp:%2F%2F192.0.2.1``
120
121 **RFC8040 URL:** ``/rests/data/bgp-rib:bgp-rib/rib=bgp-example/peer=bgp%3A%2F%2F192.0.2.1?content=nonconfig``
122
123 **Method:** ``GET``
124
125 .. tabs::
126
127    .. tab:: XML
128
129       **Response Body:**
130
131       .. code-block:: xml
132          :linenos:
133          :emphasize-lines: 8,13,35,40,62,66
134
135          <peer xmlns="urn:opendaylight:params:xml:ns:yang:bgp-rib">
136              <peer-id>bgp://192.0.2.1</peer-id>
137              <supported-tables>
138                  <afi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:ipv4-address-family</afi>
139                  <safi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:unicast-subsequent-address-family</safi>
140              </supported-tables>
141              <peer-role>ibgp</peer-role>
142              <adj-rib-in>
143                  <tables>
144                      <afi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:ipv4-address-family</afi>
145                      <safi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:unicast-subsequent-address-family</safi>
146                      <ipv4-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
147                          <ipv4-route>
148                              <path-id>0</path-id>
149                              <prefix>10.0.0.10/32</prefix>
150                              <attributes>
151                                  <as-path></as-path>
152                                  <origin>
153                                      <value>igp</value>
154                                  </origin>
155                                  <local-pref>
156                                      <pref>100</pref>
157                                  </local-pref>
158                                  <ipv4-next-hop>
159                                      <global>10.10.1.1</global>
160                                  </ipv4-next-hop>
161                              </attributes>
162                          </ipv4-route>
163                      </ipv4-routes>
164                      <attributes>
165                          <uptodate>true</uptodate>
166                      </attributes>
167                  </tables>
168              </adj-rib-in>
169              <effective-rib-in>
170                  <tables>
171                      <afi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:ipv4-address-family</afi>
172                      <safi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:unicast-subsequent-address-family</safi>
173                      <ipv4-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
174                          <ipv4-route>
175                              <path-id>0</path-id>
176                              <prefix>10.0.0.10/32</prefix>
177                              <attributes>
178                                  <as-path></as-path>
179                                  <origin>
180                                      <value>igp</value>
181                                  </origin>
182                                  <local-pref>
183                                      <pref>100</pref>
184                                  </local-pref>
185                                  <ipv4-next-hop>
186                                      <global>10.10.1.1</global>
187                                  </ipv4-next-hop>
188                              </attributes>
189                          </ipv4-route>
190                      </ipv4-routes>
191                      <attributes>
192                          <uptodate>true</uptodate>
193                      </attributes>
194                  </tables>
195              </effective-rib-in>
196              <adj-rib-out>
197                  <tables>
198                      <afi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:ipv4-address-family</afi>
199                      <safi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:unicast-subsequent-address-family</safi>
200                      <ipv4-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet"></ipv4-routes>
201                      <attributes></attributes>
202                  </tables>
203              </adj-rib-out>
204          </peer>
205
206       @line 8: **Adj-RIB-In** - Per-peer RIB, which contains unprocessed routes that has been advertised to local BGP speaker by the remote peer.
207
208       @line 13: Here is the reported route with destination *10.0.0.10/32* in Adj-RIB-In.
209
210       @line 35: **Effective-RIB-In** - Per-peer RIB, which contains processed routes as a result of applying inbound policy to Adj-RIB-In routes.
211
212       @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.
213
214       @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.
215
216       @line 66: The peer's Adj-RIB-Out is empty as there are no routes to be advertise from local BGP speaker.
217
218    .. tab:: JSON
219
220       **Response Body:**
221
222       .. code-block:: json
223          :linenos:
224          :emphasize-lines: 12,18,42,48,72,76
225
226          {
227              "peer": [
228                  {
229                      "peer-id": "bgp://192.0.2.1",
230                      "peer-role": "ibgp",
231                      "supported-tables": [
232                          {
233                              "afi": "bgp-types:ipv4-address-family",
234                              "safi": "bgp-types:unicast-subsequent-address-family"
235                          }
236                      ],
237                      "adj-rib-in": {
238                          "tables": [
239                              {
240                                  "afi": "bgp-types:ipv4-address-family",
241                                  "safi": "bgp-types:unicast-subsequent-address-family",
242                                  "bgp-inet:ipv4-routes":{
243                                      "ipv4-route": [
244                                          {
245                                              "path-id": 0,
246                                              "prefix": "10.0.0.10/32",
247                                              "attributes": {
248                                                  "origin": {
249                                                      "value": "igp"
250                                                  },
251                                                  "local-pref": {
252                                                      "pref": 100
253                                                  },
254                                                  "ipv4-next-hop": {
255                                                      "global": "10.10.1.1"
256                                                  }
257                                              }
258                                          }
259                                      ]
260                                  },
261                                  "attributes": {
262                                      "uptodate": true
263                                  }
264                              }
265                          ]
266                      },
267                      "effective-rib-in": {
268                          "tables": [
269                              {
270                                  "afi": "bgp-types:ipv4-address-family",
271                                  "safi": "bgp-types:unicast-subsequent-address-family",
272                                  "bgp-inet:ipv4-routes":{
273                                      "ipv4-route": [
274                                          {
275                                              "path-id": 0,
276                                              "prefix": "10.0.0.11/32",
277                                              "attributes": {
278                                                  "origin": {
279                                                      "value": "igp"
280                                                  },
281                                                  "local-pref": {
282                                                      "pref": 100
283                                                  },
284                                                  "ipv4-next-hop": {
285                                                      "global": "10.11.1.1"
286                                                  }
287                                              }
288                                          }
289                                      ]
290                                  },
291                                  "attributes": {
292                                      "uptodate": true
293                                  }
294                              }
295                          ]
296                      },
297                      "adj-rib-out": {
298                          "tables": [
299                              {
300                                  "afi": "bgp-types:ipv4-address-family",
301                                  "safi": "bgp-types:unicast-subsequent-address-family"
302                              }
303                          ]
304                      }
305                  }
306              ]
307          }
308
309       @line 12: **Adj-RIB-In** - Per-peer RIB, which contains unprocessed routes that has been advertised to local BGP speaker by the remote peer.
310
311       @line 18: Here is the reported route with destination *10.0.0.10/32* in Adj-RIB-In.
312
313       @line 42: **Effective-RIB-In** - Per-peer RIB, which contains processed routes as a result of applying inbound policy to Adj-RIB-In routes.
314
315       @line 48: 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.
316
317       @line 72: **Adj-RIB-Out** - Per-peer RIB, which contains routes for advertisement to the peer by means of the local speaker's UPDATE message.
318
319       @line 76: The peer's Adj-RIB-Out is empty as there are no routes to be advertise from local BGP speaker.
320
321 -----
322
323 Also the same route should appeared in Loc-RIB now:
324
325 **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``
326
327 **Method:** ``GET``
328
329 .. tabs::
330
331    .. tab:: XML
332
333       **Response Body:**
334
335       .. code-block:: xml
336          :linenos:
337          :emphasize-lines: 4,6,8,11,14
338
339          <ipv4-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
340              <ipv4-route>
341                  <path-id>0</path-id>
342                  <prefix>10.0.0.10/32</prefix>
343                  <attributes>
344                      <as-path></as-path>
345                      <origin>
346                          <value>igp</value>
347                      </origin>
348                      <local-pref>
349                          <pref>100</pref>
350                      </local-pref>
351                      <ipv4-next-hop>
352                          <global>10.10.1.1</global>
353                      </ipv4-next-hop>
354                  </attributes>
355              </ipv4-route>
356          </ipv4-routes>
357
358       @line 4: **Destination** - IPv4 Prefix Address.
359
360       @line 6: **AS_PATH** - mandatory attribute, contains a list of the autonomous system numbers through that routing information has traversed.
361
362       @line 8: **ORIGIN** - mandatory attribute, indicates an origin of the route - **ibgp**, **egp**, **incomplete**.
363
364       @line 11: **LOCAL_PREF** - indicates a degree of preference for external routes, higher value is preferred.
365
366       @line 14: **NEXT_HOP** - mandatory attribute, defines IP address of the router that should be used as the next hop to the destination.
367
368    .. tab:: JSON `
369
370       **Response Body:**
371
372       .. code-block:: json
373          :linenos:
374          :emphasize-lines: 6,8,10,13,16
375
376          {
377              "bgp-inet:ipv4-routes":{
378                  "ipv4-route": [
379                      {
380                          "path-id": 0,
381                          "prefix": "10.0.0.10/32",
382                          "attributes": {
383                              "as-path": "",
384                              "origin": {
385                                  "value": "igp"
386                              },
387                              "local-pref": {
388                                  "pref": "100"
389                              },
390                              "ipv4-next-hop": {
391                                  "global": "10.10.1.1"
392                              }
393                          }
394                      }
395                  ]
396              }
397          }
398
399       @line 6: **Destination** - IPv4 Prefix Address.
400
401       @line 8: **AS_PATH** - mandatory attribute, contains a list of the autonomous system numbers through that routing information has traversed.
402
403       @line 10: **ORIGIN** - mandatory attribute, indicates an origin of the route - **ibgp**, **egp**, **incomplete**.
404
405       @line 13: **LOCAL_PREF** - indicates a degree of preference for external routes, higher value is preferred.
406
407       @line 16: **NEXT_HOP** - mandatory attribute, defines IP address of the router that should be used as the next hop to the destination.
408
409 -----
410
411 There are much more attributes that may be carried along with the destination:
412
413 **BGP-4 Path Attributes**
414
415 * **MULTI_EXIT_DISC** (MED)
416    Optional attribute, to be used to discriminate among multiple exit/entry points on external links, lower number is preferred.
417
418 .. tabs::
419
420    .. tab:: XML
421
422       .. code-block:: xml
423
424          <multi-exit-disc>
425              <med>0</med>
426          </multi-exit-disc>
427
428    .. tab:: JSON
429
430       .. code-block:: json
431
432          {
433              "multi-exit-disc": {
434                  "med": 0
435              }
436          }
437
438 * **ATOMIC_AGGREGATE**
439    Indicates whether AS_SET was excluded from AS_PATH due to routes aggregation.
440
441 .. tabs::
442
443    .. tab:: XML
444
445       .. code-block:: xml
446
447          <atomic-aggregate/>
448
449    .. tab:: JSON
450
451       .. code-block:: json
452
453          {
454          "atomic-aggregate": {
455          }
456          }
457
458 * **AGGREGATOR**
459    Optional attribute, contains AS number and IP address of a BGP speaker which performed routes aggregation.
460
461 .. tabs::
462
463    .. tab:: XML
464
465       .. code-block:: xml
466
467          <aggregator>
468              <as-number>65000</as-number>
469              <network-address>192.0.2.2</network-address>
470          </aggregator>
471
472    .. tab:: JSON
473
474       .. code-block:: json
475
476          {
477              "aggregator": {
478                  "as-number": 65000,
479                  "network-address": "192.0.2.2"
480              }
481          }
482
483 * **Unrecognised**
484    Optional attribute, used to store optional attributes, unrecognized by a local BGP speaker.
485
486 .. tabs::
487
488    .. tab:: XML
489
490       .. code-block:: xml
491
492          <unrecognized-attributes>
493              <partial>true</partial>
494              <transitive>true</transitive>
495              <type>101</type>
496              <value>0101010101010101</value>
497          </unrecognized-attributes>
498
499    .. tab:: JSON
500
501       .. code-block:: json
502
503          {
504              "unrecognized-attributes": {
505                  "partial": true,
506                  "transitive": true,
507                  "type": 101,
508                  "value": 0101010101010101
509              }
510          }
511
512 **Route Reflector Attributes**
513
514 * **ORIGINATOR_ID**
515    Optional attribute, carries BGP Identifier of the originator of the route.
516
517 .. tabs::
518
519    .. tab:: XML
520
521       .. code-block:: xml
522
523          <originator-id>
524              <originator>41.41.41.41</originator>
525          </originator-id>
526
527    .. tab:: JSON
528
529       .. code-block:: json
530
531          {
532              "originator-id": {
533                  "originator": "41.41.41.41",
534              }
535          }
536
537 * **CLUSTER_LIST**
538    Optional attribute, contains a list of CLUSTER_ID values representing the path that the route has traversed.
539
540 .. tabs::
541
542    .. tab:: XML
543
544       .. code-block:: xml
545
546          <cluster-id>
547              <cluster>40.40.40.40</cluster>
548          </cluster-id>
549
550    .. tab:: JSON
551
552       .. code-block:: json
553
554          {
555              "cluster-id": {
556                  "cluster": "41.41.41.41",
557              }
558          }
559
560 * **Communities**
561    Optional attribute, may be used for policy routing.
562
563 .. tabs::
564
565    .. tab:: XML
566
567       .. code-block:: xml
568
569          <communities>
570              <as-number>65000</as-number>
571              <semantics>30740</semantics>
572          </communities>
573
574    .. tab:: JSON
575
576       .. code-block:: json
577
578          {
579              "communities": {
580                  "as-number": 65000,
581                  "semantics": 30740
582              }
583          }
584
585 **Extended Communities**
586
587 * **Route Target**
588    Identifies one or more routers that may receive a route.
589
590 .. tabs::
591
592    .. tab:: XML
593
594       .. code-block:: xml
595
596          <extended-communities>
597              <transitive>true</transitive>
598              <route-target-ipv4>
599                  <global-administrator>192.0.2.2</global-administrator>
600                  <local-administrator>123</local-administrator>
601              </route-target-ipv4>
602          </extended-communities>
603          <extended-communities>
604              <transitive>true</transitive>
605              <as-4-route-target-extended-community>
606                  <as-4-specific-common>
607                      <as-number>65000</as-number>
608                      <local-administrator>123</local-administrator>
609                  </as-4-specific-common>
610              </as-4-route-target-extended-community>
611          </extended-communities>
612
613    .. tab:: JSON
614
615       .. code-block:: json
616
617          {
618              "extended-communities": [
619                  {
620                      "transitive": true,
621                      "route-target-ipv4": {
622                          "global-administrator": "192.0.2.2",
623                          "local-administrator": 123
624                      }
625                  },
626                  {
627                      "transitive": true,
628                      "as-4-route-target-extended-community": {
629                          "as-4-specific-common": {
630                              "as-number": 65000,
631                              "local-administrator": 123
632                          }
633                      }
634                  }
635              ]
636          }
637
638 * **Route Origin**
639    Identifies one or more routers that injected a route.
640
641 .. tabs::
642
643    .. tab:: XML
644
645       .. code-block:: xml
646
647          <extended-communities>
648              <transitive>true</transitive>
649              <route-origin-ipv4>
650                  <global-administrator>192.0.2.2</global-administrator>
651                  <local-administrator>123</local-administrator>
652              </route-origin-ipv4>
653          </extended-communities>
654          <extended-communities>
655              <transitive>true</transitive>
656              <as-4-route-origin-extended-community>
657                  <as-4-specific-common>
658                      <as-number>65000</as-number>
659                      <local-administrator>123</local-administrator>
660                  </as-4-origin-common>
661              </as-4-route-target-extended-community>
662          </extended-communities>
663
664    .. tab:: JSON
665
666       .. code-block:: json
667
668          {
669              "extended-communities": [
670                  {
671                      "transitive": true,
672                      "route-origin-ipv4": {
673                          "global-administrator": "192.0.2.2",
674                          "local-administrator": 123
675                      }
676                  },
677                  {
678                      "transitive": true,
679                      "as-4-route-target-extended-community": {
680                          "as-4-specific-common": {
681                              "as-number": 65000,
682                              "local-administrator": 123
683                          }
684                      }
685                  }
686              ]
687          }
688
689 * **Link Bandwidth**
690    Carries the cost to reach external neighbor.
691
692 .. tabs::
693
694    .. tab:: XML
695
696       .. code-block:: xml
697
698          <extended-communities>
699              <transitive>true</transitive>
700              <link-bandwidth-extended-community>
701                  <bandwidth>BH9CQAA=</bandwidth>
702              </link-bandwidth-extended-community>
703          </extended-communities>
704
705    .. tab:: JSON
706
707       .. code-block:: json
708
709          {
710              "extended-communities": {
711                  "transitive": true,
712                  "link-bandwidth-extended-community": {
713                      "bandwidth": "BH9CQAA="
714                  }
715              }
716          }
717
718 * **AIGP**
719    Optional attribute, carries accumulated IGP metric.
720
721 .. tabs::
722
723    .. tab:: XML
724
725       .. code-block:: xml
726
727          <aigp>
728              <aigp-tlv>
729                  <metric>120</metric>
730              </aigp-tlv>
731          </aigp>
732
733    .. tab:: JSON
734
735       .. code-block:: json
736
737          {
738              "aigp": {
739                  "aigp-tlv": {
740                      "metric": 120
741                  }
742              }
743          }
744
745 .. note:: When the remote peer disconnects, it disappear from operational state of local speaker instance and advertised routes are removed too.
746
747 External peering configuration
748 ''''''''''''''''''''''''''''''
749 An example above provided configuration for internal peering only.
750 Following configuration sample is intended for external peering:
751
752 **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``
753
754 **Method:** ``POST``
755
756 .. tabs::
757
758    .. tab:: XML
759
760       **Content-Type:** ``application/xml``
761
762       **Request Body:**
763
764       .. code-block:: xml
765          :linenos:
766          :emphasize-lines: 5
767
768          <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
769              <neighbor-address>192.0.2.3</neighbor-address>
770              <config>
771                  <peer-type>EXTERNAL</peer-type>
772                  <peer-as>64999</peer-as>
773              </config>
774          </neighbor>
775
776       @line 5: AS number of the remote peer.
777
778    .. tab:: JSON
779
780       **Content-Type:** ``application/json``
781
782       **Request Body:**
783
784       .. code-block:: json
785          :linenos:
786          :emphasize-lines: 6
787
788          {
789              "neighbor": [
790                  {
791                      "neighbor-address": "192.0.2.3",
792                      "config": {
793                          "peer-as": 64999,
794                          "peer-type": "EXTERNAL"
795                      }
796                  }
797              ]
798          }
799
800       @line 6: AS number of the remote peer.
801
802 Local AS
803 ''''''''
804
805 .. figure:: ./images/local-as.png
806    :alt: BGP eBGP with Local AS setup.
807
808 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.
809
810 In above figure, R3 is eBGP router with configured local-as of 62, and peer-as of 63.
811
812 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".
813
814 AS 62 will be prepended to updates that are sent to and received from R3.
815
816 Following configuration sample is intended for external peering with Local AS:
817
818 **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``
819
820 **Method:** ``POST``
821
822 .. tabs::
823
824    .. tab:: XML
825
826       **Content-Type:** ``application/xml``
827
828       **Request Body:**
829
830       .. code-block:: xml
831          :linenos:
832          :emphasize-lines: 5,6
833
834          <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
835              <neighbor-address>192.0.2.3</neighbor-address>
836              <config>
837                  <peer-type>EXTERNAL</peer-type>
838                  <peer-as>63</peer-as>
839                  <local-as>62</local-as>
840              </config>
841          </neighbor>
842
843       @line 5: AS number of the remote peer.
844
845       @line 6: Local AS number of the remote peer.
846
847    .. tab:: JSON
848
849       **Content-Type:** ``application/json``
850
851       **Request Body:**
852
853       .. code-block:: json
854          :linenos:
855          :emphasize-lines: 7,8
856
857          {
858              "neighbor": [
859                  {
860                      "neighbor-address": "192.0.2.3",
861                      "config": {
862                          "peer-type": "EXTERNAL",
863                          "peer-as": 63,
864                          "local-as":62
865                      }
866                  }
867              ]
868          }
869
870       @line 7: AS number of the remote peer.
871
872       @line 8: Local AS number of the remote peer.
873
874 Route reflector configuration
875 '''''''''''''''''''''''''''''
876 The local BGP speaker can be configured with a specific *cluster ID*.
877 Following example adds the cluster ID to the existing speaker instance:
878
879 **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``
880
881 **Method:** ``PUT``
882
883 .. tabs::
884
885    .. tab:: XML
886
887       **Content-Type:** ``application/xml``
888
889       **Request Body:**
890
891       .. code-block:: xml
892          :linenos:
893          :emphasize-lines: 4
894
895          <config>
896              <router-id>192.0.2.2</router-id>
897              <as>65000</as>
898              <route-reflector-cluster-id>192.0.2.1</route-reflector-cluster-id>
899          </config>
900
901       @line 4: Route-reflector cluster id to use when local router is configured as a route reflector.
902          The *router-id* is used as a default value.
903
904    .. tab:: JSON
905
906       **Content-Type:** ``application/json``
907
908       **Request Body:**
909
910       .. code-block:: json
911          :linenos:
912          :emphasize-lines: 5
913
914          {
915              "bgp-openconfig-extensions:config": {
916                  "router-id": "192.0.2.2",
917                  "as": 65000,
918                  "route-reflector-cluster-id": "192.0.2.1"
919              }
920          }
921
922       @line 5: Route-reflector cluster id to use when local router is configured as a route reflector.
923          The *router-id* is used as a default value.
924
925 -----
926
927 Following configuration sample is intended for route reflector client peering:
928
929 **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``
930
931 **Method:** ``POST``
932
933 .. tabs::
934
935    .. tab:: XML
936
937       **Content-Type:** ``application/xml``
938
939       **Request Body:**
940
941       .. code-block:: xml
942          :linenos:
943          :emphasize-lines: 8
944
945          <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
946              <neighbor-address>192.0.2.4</neighbor-address>
947              <config>
948                  <peer-type>INTERNAL</peer-type>
949              </config>
950              <route-reflector>
951                  <config>
952                      <route-reflector-client>true</route-reflector-client>
953                  </config>
954              </route-reflector>
955          </neighbor>
956
957       @line 8: Configure the neighbor as a route reflector client. Default value is *false*.
958
959    .. tab:: JSON
960
961       **Content-Type:** ``application/json``
962
963       **Request Body:**
964
965       .. code-block:: json
966          :linenos:
967          :emphasize-lines: 10
968
969          {
970              "neighbor": [
971                  {
972                      "neighbor-address": "192.0.2.4",
973                      "config": {
974                          "peer-type": "INTERNAL"
975                      },
976                      "route-reflector": {
977                          "config": {
978                              "route-reflector-client": true
979                          }
980                      }
981                  }
982              ]
983          }
984
985       @line 10: Configure the neighbor as a route reflector client. Default value is *false*.
986
987 Route reflector and Multiple Cluster IDs
988 ''''''''''''''''''''''''''''''''''''''''
989
990 An optional non-transitive attribute called CLUSTER_LIST is modified when a route reflector reflects a prefix.
991 For loop prevention the route reflector adds its own cluster ID to, and discards any update containing router's own cluster ID.
992 Using multiple cluster IDs allows updates to propagate to nodes that reside in a different cluster.
993
994
995 .. figure:: ./images/MultipleClustersIds.png
996    :alt: BGP RR Multiple Cluster IDs setup.
997
998 Following configuration sample is intended for route reflector client peering using specific cluster id:
999
1000 **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``
1001
1002 **Method:** ``POST``
1003
1004 .. tabs::
1005
1006    .. tab:: XML
1007
1008       **Content-Type:** ``application/xml``
1009
1010       **Request Body:**
1011
1012       .. code-block:: xml
1013          :linenos:
1014          :emphasize-lines: 8,9
1015
1016          <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
1017              <neighbor-address>192.0.2.4</neighbor-address>
1018              <config>
1019                  <peer-type>INTERNAL</peer-type>
1020              </config>
1021              <route-reflector>
1022                  <config>
1023                      <route-reflector-client>true</route-reflector-client>
1024                      <route-reflector-cluster-id>192.0.2.4</route-reflector-cluster-id>
1025                  </config>
1026              </route-reflector>
1027          </neighbor>
1028
1029       @line 8: Configure the neighbor as a route reflector client. Default value is *false*.
1030
1031       @line 9: Route-reflector cluster id to use for this specific neighbor when local router is configured as a route reflector.
1032
1033    .. tab:: JSON
1034
1035       **Content-Type:** ``application/json``
1036
1037       **Request Body:**
1038
1039       .. code-block:: json
1040          :linenos:
1041          :emphasize-lines: 10,11
1042
1043          {
1044              "neighbor": [
1045                  {
1046                      "neighbor-address": "192.0.2.4",
1047                      "config": {
1048                          "peer-type": "INTERNAL"
1049                      },
1050                      "route-reflector": {
1051                          "config": {
1052                              "route-reflector-client": true,
1053                              "route-reflector-cluster-id":"192.0.2.4"
1054                          }
1055                      }
1056                  }
1057              ]
1058          }
1059
1060       @line 10: Configure the neighbor as a route reflector client. Default value is *false*.
1061
1062       @line 11: Route-reflector cluster id to use for this specific neighbor when local router is configured as a route reflector.
1063
1064 MD5 authentication configuration
1065 ''''''''''''''''''''''''''''''''
1066 The OpenDaylight BGP implementation is supporting TCP MD5 for authentication.
1067 Sample configuration below shows how to set authentication password for a peer:
1068
1069 **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``
1070
1071 **Method:** ``POST``
1072
1073 .. tabs::
1074
1075    .. tab:: XML
1076
1077       **Content-Type:** ``application/xml``
1078
1079       **Request Body:**
1080
1081       .. code-block:: xml
1082          :linenos:
1083          :emphasize-lines: 4
1084
1085          <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
1086              <neighbor-address>192.0.2.5</neighbor-address>
1087              <config>
1088                  <auth-password>topsecret</auth-password>
1089              </config>
1090          </neighbor>
1091
1092       @line 4: Configures an MD5 authentication password for use with neighboring devices.
1093
1094    .. tab:: JSON
1095
1096       **Content-Type:** ``application/json``
1097
1098       **Request Body:**
1099
1100       .. code-block:: json
1101          :linenos:
1102          :emphasize-lines: 6
1103
1104          {
1105              "neighbor": [
1106                  {
1107                      "neighbor-address": "192.0.2.5",
1108                      "config": {
1109                          "auth-password": "topsecret"
1110                      }
1111                  }
1112              ]
1113          }
1114
1115       @line 6: Configures an MD5 authentication password for use with neighboring devices.
1116
1117 BGP Peer Group
1118 ''''''''''''''
1119
1120 Allows the creation of a peer group configuration that applies to all peers configured as part of the group.
1121
1122 A sample peer group configuration follows:
1123
1124 **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``
1125
1126 **Method:** ``POST``
1127
1128 .. tabs::
1129
1130    .. tab:: XML
1131
1132       **Content-Type:** ``application/xml``
1133
1134       **Request Body:**
1135
1136       .. code-block:: xml
1137          :linenos:
1138          :emphasize-lines: 2
1139
1140          <peer-group xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
1141              <peer-group-name>internal-neighbor</peer-group-name>
1142              <config>
1143                  <peer-type>INTERNAL</peer-type>
1144                  <peer-as>64496</peer-as>
1145              </config>
1146              <transport>
1147                  <config>
1148                      <remote-port>179</remote-port>
1149                      <passive-mode>true</passive-mode>
1150                  </config>
1151              </transport>
1152              <timers>
1153                  <config>
1154                      <hold-time>180</hold-time>
1155                      <connect-retry>10</connect-retry>
1156                  </config>
1157              </timers>
1158              <route-reflector>
1159                  <config>
1160                      <route-reflector-client>false</route-reflector-client>
1161                  </config>
1162              </route-reflector>
1163              <afi-safis>
1164                  <afi-safi>
1165                      <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV4-UNICAST</afi-safi-name>
1166                      <!--Advertise N Paths
1167                      <receive>true</receive>
1168                      <send-max>0</send-max>-->
1169                  </afi-safi>
1170                  <afi-safi>
1171                      <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV6-UNICAST</afi-safi-name>
1172                  </afi-safi>
1173                  <afi-safi>
1174                      <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV4-LABELLED-UNICAST</afi-safi-name>
1175                  </afi-safi>
1176                  <afi-safi>
1177                      <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV6-LABELLED-UNICAST</afi-safi-name>
1178                  </afi-safi>
1179                  <afi-safi>
1180                      <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:L3VPN-IPV4-UNICAST</afi-safi-name>
1181                  </afi-safi>
1182                  <afi-safi>
1183                      <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:L3VPN-IPV6-UNICAST</afi-safi-name>
1184                  </afi-safi>
1185                  <afi-safi>
1186                      <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:L2VPN-EVPN</afi-safi-name>
1187                  </afi-safi>
1188                  <afi-safi>
1189                      <afi-safi-name>LINKSTATE</afi-safi-name>
1190                  </afi-safi>
1191                  <afi-safi>
1192                      <afi-safi-name>IPV4-FLOW</afi-safi-name>
1193                  </afi-safi>
1194                  <afi-safi>
1195                      <afi-safi-name>IPV6-FLOW</afi-safi-name>
1196                  </afi-safi>
1197                  <afi-safi>
1198                      <afi-safi-name>IPV4-L3VPN-FLOW</afi-safi-name>
1199                  </afi-safi>
1200                  <afi-safi>
1201                      <afi-safi-name>IPV6-L3VPN-FLOW</afi-safi-name>
1202                  </afi-safi>
1203              </afi-safis>
1204          </peer-group>
1205
1206       @line 2: Peer Group Identifier.
1207
1208    .. tab:: JSON
1209
1210       **Content-Type:** ``application/json``
1211
1212       **Request Body:**
1213
1214       .. code-block:: json
1215          :linenos:
1216          :emphasize-lines: 4
1217
1218          {
1219              "peer-group": [
1220                  {
1221                      "peer-group-name": "internal-neighbor",
1222                      "config": {
1223                          "peer-as": 64496,
1224                          "peer-type": "INTERNAL"
1225                      },
1226                      "transport": {
1227                          "config": {
1228                              "remote-port": 179,
1229                              "passive-mode": true
1230                          }
1231                      },
1232                      "timers": {
1233                          "config": {
1234                              "hold-time": 180,
1235                              "connect-retry": 10
1236                          }
1237                      },
1238                      "route-reflector": {
1239                          "config": {
1240                              "route-reflector-client": false
1241                          }
1242                      },
1243                      "afi-safis": {
1244                          "afi-safi": [
1245                              {
1246                                  "afi-safi-name": "openconfig-bgp-types:L2VPN-EVPN"
1247                              },
1248                              {
1249                                  "afi-safi-name": "openconfig-bgp-types:L3VPN-IPV6-UNICAST"
1250                              },
1251                              {
1252                                  "afi-safi-name": "bgp-openconfig-extensions:IPV6-FLOW"
1253                              },
1254                              {
1255                                  "afi-safi-name": "openconfig-bgp-types:IPV4-LABELLED-UNICAST"
1256                              },
1257                              {
1258                                  "afi-safi-name": "openconfig-bgp-types:L3VPN-IPV4-UNICAST"
1259                              },
1260                              {
1261                                  "afi-safi-name": "openconfig-bgp-types:IPV6-LABELLED-UNICAST"
1262                              },
1263                              {
1264                                  "afi-safi-name": "bgp-openconfig-extensions:LINKSTATE"
1265                              },
1266                              {
1267                                  "afi-safi-name": "openconfig-bgp-types:IPV6-UNICAST"
1268                              },
1269                              {
1270                                  "afi-safi-name": "bgp-openconfig-extensions:IPV4-L3VPN-FLOW"
1271                              },
1272                              {
1273                                  "afi-safi-name": "bgp-openconfig-extensions:IPV6-L3VPN-FLOW"
1274                              },
1275                              {
1276                                  "afi-safi-name": "openconfig-bgp-types:IPV4-UNICAST"
1277                              },
1278                              {
1279                                  "afi-safi-name": "bgp-openconfig-extensions:IPV4-FLOW"
1280                              }
1281                          ]
1282                      }
1283                  }
1284              ]
1285          }
1286
1287       @line 4: Peer Group Identifier.
1288
1289 -----
1290
1291 A sample basic neighbor configuration using a peer group follows:
1292
1293 **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``
1294
1295 **Method:** ``POST``
1296
1297 .. tabs::
1298
1299    .. tab:: XML
1300
1301       **Content-Type:** ``application/xml``
1302
1303       **Request Body:**
1304
1305       .. code-block:: xml
1306          :linenos:
1307          :emphasize-lines: 4
1308
1309          <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
1310             <neighbor-address>192.0.2.1</neighbor-address>
1311             <config>
1312                <peer-group>/bgp/neighbors/neighbor/bgp/peer-groups/peer-group[peer-group-name="internal-neighbor"]</peer-group>
1313             </config>
1314          </neighbor>
1315
1316       @line 4: Peer group identifier.
1317
1318    .. tab:: JSON
1319
1320       **Content-Type:** ``application/json``
1321
1322       **Request Body:**
1323
1324       .. code-block:: json
1325          :linenos:
1326          :emphasize-lines: 6
1327
1328          {
1329              "neighbor": [
1330                  {
1331                      "neighbor-address": "192.0.2.1",
1332                      "config": {
1333                          "peer-group": "/bgp/neighbors/neighbor/bgp/peer-groups/peer-group[peer-group-name=\"internal-neighbor\"]"
1334                      }
1335                  }
1336              ]
1337          }
1338
1339       @line 6: Peer group identifier.
1340
1341 .. note:: Existing neighbor configuration can be reconfigured (change configuration parameters) anytime.
1342    As a result, established connection is dropped, peer instance is recreated with a new configuration settings and connection re-established.
1343
1344 .. note:: The BGP configuration is persisted on OpendDaylight shutdown and restored after the re-start.