1 .. _bgp-user-guide-bgp-peering:
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.
9 Here is a sample basic neighbor configuration:
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``
15 **Content-Type:** ``application/xml``
21 :emphasize-lines: 2,5,6,11,12,17,19
23 <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
24 <neighbor-address>192.0.2.1</neighbor-address>
27 <hold-time>90</hold-time>
28 <connect-retry>10</connect-retry>
33 <remote-port>179</remote-port>
34 <passive-mode>false</passive-mode>
35 <!--<local-address>192.0.2.5</local-address>-->
39 <peer-type>INTERNAL</peer-type>
46 @line 2: IP address of the remote BGP peer. Also serves as an unique identifier of a neighbor in a list of neighbors.
48 @line 5: Proposed number of seconds for value of the Hold Timer. Default value is **90**.
50 @line 6: Time interval in seconds between attempts to establish session with the peer. Effective in active mode only. Default value is **30**.
52 @line 11: Remote port number to which the local BGP is connecting. Effective in active mode only. Default value **179**.
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**.
56 @line 13: Optional Local IP (either IPv4 or IPv6) address used to establish connections to the remote peer. Effective in active mode only.
58 @line 17: Explicitly designate the peer as internal or external. Default value is **INTERNAL**.
60 @line 19: Enable families.
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:
67 **URL:** ``/restconf/operational/bgp-rib:bgp-rib/rib/bgp-example/peer/bgp:%2F%2F192.0.2.1``
75 :emphasize-lines: 8,13,35,40,62,66
77 <peer xmlns="urn:opendaylight:params:xml:ns:yang:bgp-rib">
78 <peer-id>bgp://192.0.2.1</peer-id>
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>
83 <peer-role>ibgp</peer-role>
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">
91 <prefix>10.0.0.10/32</prefix>
101 <global>10.10.1.1</global>
107 <uptodate>true</uptodate>
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">
118 <prefix>10.0.0.10/32</prefix>
128 <global>10.10.1.1</global>
134 <uptodate>true</uptodate>
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>
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.
150 @line 13: Here is the reported route with destination *10.0.0.10/32* in Adj-RIB-In.
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.
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.
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.
158 @line 66: The peer's Adj-RIB-Out is empty as there are no routes to be advertise from local BGP speaker.
162 Also the same route should appeared in Loc-RIB now:
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``
172 :emphasize-lines: 4,6,8,11,14
174 <ipv4-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
177 <prefix>10.0.0.10/32</prefix>
187 <global>10.10.1.1</global>
193 @line 4: **Destination** - IPv4 Prefix Address.
195 @line 6: **AS_PATH** - mandatory attribute, contains a list of the autonomous system numbers through that routing information has traversed.
197 @line 8: **ORIGIN** - mandatory attribute, indicates an origin of the route - **ibgp**, **egp**, **incomplete**.
199 @line 11: **LOCAL_PREF** - indicates a degree of preference for external routes, higher value is preferred.
201 @line 14: **NEXT_HOP** - mandatory attribute, defines IP address of the router that should be used as the next hop to the destination.
205 There are much more attributes that may be carried along with the destination:
207 **BGP-4 Path Attributes**
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.
219 * **ATOMIC_AGGREGATE**
220 Indicates whether AS_SET was excluded from AS_PATH due to routes aggregation.
227 Optional attribute, contains AS number and IP address of a BGP speaker which performed routes aggregation.
232 <as-number>65000</as-number>
233 <network-address>192.0.2.2</network-address>
237 Optional attribute, used to store optional attributes, unrecognized by a local BGP speaker.
241 <unrecognized-attributes>
242 <partial>true</partial>
243 <transitive>true</transitive>
245 <value>0101010101010101</value>
246 </unrecognized-attributes>
248 **Route Reflector Attributes**
251 Optional attribute, carries BGP Identifier of the originator of the route.
256 <originator>41.41.41.41</originator>
260 Optional attribute, contains a list of CLUSTER_ID values representing the path that the route has traversed.
265 <cluster>40.40.40.40</cluster>
269 Optional attribute, may be used for policy routing.
274 <as-number>65000</as-number>
275 <semantics>30740</semantics>
278 **Extended Communities**
281 Identifies one or more routers that may receive a route.
285 <extended-communities>
286 <transitive>true</transitive>
288 <global-administrator>192.0.2.2</global-administrator>
289 <local-administrator>123</local-administrator>
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>
304 Identifies one or more routers that injected a route.
308 <extended-communities>
309 <transitive>true</transitive>
311 <global-administrator>192.0.2.2</global-administrator>
312 <local-administrator>123</local-administrator>
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>
327 Carries the cost to reach external neighbor.
331 <extended-communities>
332 <transitive>true</transitive>
333 <link-bandwidth-extended-community>
334 <bandwidth>BH9CQAA=</bandwidth>
335 </link-bandwidth-extended-community>
336 </extended-communities>
339 Optional attribute, carries accumulated IGP metric.
350 .. note:: When the remote peer disconnects, it disappear from operational state of local speaker instance and advertised routes are removed too.
352 External peering configuration
353 ''''''''''''''''''''''''''''''
354 An example above provided configuration for internal peering only.
355 Following configuration sample is intended for external peering:
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``
361 **Content-Type:** ``application/xml``
369 <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
370 <neighbor-address>192.0.2.3</neighbor-address>
372 <peer-type>EXTERNAL</peer-type>
373 <peer-as>64999</peer-as>
377 @line 5: AS number of the remote peer.
382 .. figure:: ./images/local-as.png
383 :alt: BGP eBGP with Local AS setup.
385 The local-AS feature allows a router(eBGP) to appear to be a member of a second autonomous system (AS), in addition to its real AS.
387 In above figure, R3 is eBGP router with configured local-as of 62, and peer-as of 63.
389 In updates sent from R3 to R2, the AS_SEQUENCE in the AS_PATH attribute contains "62 63". And updates sent from R2 to R3, the AS_SEQUENCE in the AS_PATH attribute contains "62 65".
391 AS 62 will be prepended to updates that are sent to and received from R3.
393 Following configuration sample is intended for external peering with Local AS:
395 **URL:** ``/restconf/config/openconfig-network-instance:network-instances/network-instance/global-bgp/openconfig-network-instance:protocols/protocol/openconfig-policy-types:BGP/bgp-example/bgp/neighbors``
399 **Content-Type:** ``application/xml``
405 :emphasize-lines: 5,6
407 <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
408 <neighbor-address>192.0.2.3</neighbor-address>
410 <peer-type>EXTERNAL</peer-type>
411 <peer-as>63</peer-as>
412 <local-as>62</local-as>
416 @line 5: AS number of the remote peer.
418 @line 6: Local AS number of the remote peer.
420 Route reflector configuration
421 '''''''''''''''''''''''''''''
422 The local BGP speaker can be configured with a specific *cluster ID*.
423 Following example adds the cluster ID to the existing speaker instance:
425 **URL:** ``/restconf/config/openconfig-network-instance:network-instances/network-instance/global-bgp/openconfig-network-instance:protocols/protocol/openconfig-policy-types:BGP/bgp-example/bgp/global/config``
429 **Content-Type:** ``application/xml``
438 <router-id>192.0.2.2</router-id>
440 <route-reflector-cluster-id>192.0.2.1</route-reflector-cluster-id>
443 @line 4: Route-reflector cluster id to use when local router is configured as a route reflector.
444 The *router-id* is used as a default value.
448 Following configuration sample is intended for route reflector client peering:
450 **URL:** ``/restconf/config/openconfig-network-instance:network-instances/network-instance/global-bgp/openconfig-network-instance:protocols/protocol/openconfig-policy-types:BGP/bgp-example/bgp/neighbors``
454 **Content-Type:** ``application/xml``
462 <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
463 <neighbor-address>192.0.2.4</neighbor-address>
465 <peer-type>INTERNAL</peer-type>
469 <route-reflector-client>true</route-reflector-client>
474 @line 8: Configure the neighbor as a route reflector client. Default value is *false*.
476 Route reflector and Multiple Cluster IDs
477 ''''''''''''''''''''''''''''''''''''''''
479 An optional non-transitive attribute called CLUSTER_LIST is modified when a route reflector reflects a prefix.
480 For loop prevention the route reflector adds its own cluster ID to, and discards any update containing router's own cluster ID.
481 Using multiple cluster IDs allows updates to propagate to nodes that reside in a different cluster.
484 .. figure:: ./images/MultipleClustersIds.png
485 :alt: BGP RR Multiple Cluster IDs setup.
487 Following configuration sample is intended for route reflector client peering using specific cluster id:
489 **URL:** ``/restconf/config/openconfig-network-instance:network-instances/network-instance/global-bgp/openconfig-network-instance:protocols/protocol/openconfig-policy-types:BGP/bgp-example/bgp/neighbors``
493 **Content-Type:** ``application/xml``
499 :emphasize-lines: 8,9
501 <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
502 <neighbor-address>192.0.2.4</neighbor-address>
504 <peer-type>INTERNAL</peer-type>
508 <route-reflector-client>true</route-reflector-client>
509 <route-reflector-cluster-id>192.0.2.4</route-reflector-cluster-id>
514 @line 8: Configure the neighbor as a route reflector client. Default value is *false*.
516 @line 9: Route-reflector cluster id to use for this specific neighbor when local router is configured as a route reflector.
518 MD5 authentication configuration
519 ''''''''''''''''''''''''''''''''
520 The OpenDaylight BGP implementation is supporting TCP MD5 for authentication.
521 Sample configuration below shows how to set authentication password for a peer:
523 **URL:** ``/restconf/config/openconfig-network-instance:network-instances/network-instance/global-bgp/openconfig-network-instance:protocols/protocol/openconfig-policy-types:BGP/bgp-example/bgp/neighbors``
527 **Content-Type:** ``application/xml``
535 <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
536 <neighbor-address>192.0.2.5</neighbor-address>
538 <auth-password>topsecret</auth-password>
542 @line 4: Configures an MD5 authentication password for use with neighboring devices.
547 Allows the creation of a peer group configuration that applies to all peers configured as part of the group.
549 A sample peer group configuration follows:
551 **URL:** ``/restconf/config/openconfig-network-instance:network-instances/network-instance/global-bgp/openconfig-network-instance:protocols/protocol/openconfig-policy-types:BGP/bgp-example/bgp/peer-groups``
555 **Content-Type:** ``application/xml``
563 <peer-group xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
564 <peer-group-name>internal-neighbor</peer-group-name>
566 <peer-type>INTERNAL</peer-type>
567 <peer-as>64496</peer-as>
571 <remote-port>179</remote-port>
572 <passive-mode>true</passive-mode>
577 <hold-time>180</hold-time>
578 <connect-retry>10</connect-retry>
583 <route-reflector-client>false</route-reflector-client>
588 <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV4-UNICAST</afi-safi-name>
589 <!--Advertise N Paths
590 <receive>true</receive>
591 <send-max>0</send-max>-->
594 <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV6-UNICAST</afi-safi-name>
597 <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV4-LABELLED-UNICAST</afi-safi-name>
600 <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV6-LABELLED-UNICAST</afi-safi-name>
603 <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:L3VPN-IPV4-UNICAST</afi-safi-name>
606 <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:L3VPN-IPV6-UNICAST</afi-safi-name>
609 <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:L2VPN-EVPN</afi-safi-name>
612 <afi-safi-name>LINKSTATE</afi-safi-name>
615 <afi-safi-name>IPV4-FLOW</afi-safi-name>
618 <afi-safi-name>IPV6-FLOW</afi-safi-name>
621 <afi-safi-name>IPV4-L3VPN-FLOW</afi-safi-name>
624 <afi-safi-name>IPV6-L3VPN-FLOW</afi-safi-name>
629 @line 2: Peer Group Identifier.
633 A sample basic neighbor configuration using a peer group follows:
635 **URL:** ``/restconf/config/openconfig-network-instance:network-instances/network-instance/global-bgp/openconfig-network-instance:protocols/protocol/openconfig-policy-types:BGP/bgp-example/bgp/neighbors``
639 **Content-Type:** ``application/xml``
647 <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
648 <neighbor-address>192.0.2.1</neighbor-address>
650 <peer-group>/bgp/neighbors/neighbor/bgp/peer-groups/peer-group[peer-group-name="internal-neighbor"]</peer-group>
654 @line 4: Peer group identifier.
656 .. note:: Existing neighbor configuration can be reconfigured (change configuration parameters) anytime.
657 As a result, established connection is dropped, peer instance is recreated with a new configuration settings and connection re-established.
659 .. note:: The BGP configuration is persisted on OpendDaylight shutdown and restored after the re-start.