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``
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>
38 <peer-type>INTERNAL</peer-type>
42 @line 2: IP address of the remote BGP peer. Also serves as an unique identifier of a neighbor in a list of neighbors.
44 @line 5: Proposed number of seconds for value of the Hold Timer. Default value is **90**.
46 @line 6: Time interval in seconds between attempts to establish session with the peer. Effective in active mode only. Default value is **30**.
48 @line 11: Remote port number to which the local BGP is connecting. Effective in active mode only. Default value **179**.
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**.
52 @line 16: Explicitly designate the peer as internal or external. Default value is **INTERNAL**.
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:
59 **URL:** ``/restconf/operational/bgp-rib:bgp-rib/rib/bgp-example/peer/bgp:%2F%2F192.0.2.1``
67 :emphasize-lines: 8,13,35,40,62,66
69 <peer xmlns="urn:opendaylight:params:xml:ns:yang:bgp-rib">
70 <peer-id>bgp://192.0.2.1</peer-id>
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>
75 <peer-role>ibgp</peer-role>
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">
83 <prefix>10.0.0.10/32</prefix>
93 <global>10.10.1.1</global>
99 <uptodate>true</uptodate>
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">
110 <prefix>10.0.0.10/32</prefix>
120 <global>10.10.1.1</global>
126 <uptodate>true</uptodate>
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>
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.
142 @line 13: Here is the reported route with destination *10.0.0.10/32* in Adj-RIB-In.
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.
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.
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.
150 @line 66: The peer's Adj-RIB-Out is empty as there are no routes to be advertise from local BGP speaker.
154 Also the same route should appeared in Loc-RIB now:
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``
164 :emphasize-lines: 4,6,8,11,14
166 <ipv4-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
169 <prefix>10.0.0.10/32</prefix>
179 <global>10.10.1.1</global>
185 @line 4: **Destination** - IPv4 Prefix Address.
187 @line 6: **AS_PATH** - mandatory attribute, contains a list of the autonomous system numbers through that routing information has traversed.
189 @line 8: **ORIGIN** - mandatory attribute, indicates an origin of the route - **ibgp**, **egp**, **incomplete**.
191 @line 11: **LOCAL_PREF** - indicates a degree of preference for external routes, higher value is preferred.
193 @line 14: **NEXT_HOP** - mandatory attribute, defines IP address of the router that should be used as the next hop to the destination.
197 There are much more attributes that may be carried along with the destination:
199 **BGP-4 Path Attributes**
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.
211 * **ATOMIC_AGGREGATE**
212 Indicates whether AS_SET was excluded from AS_PATH due to routes aggregation.
219 Optional attribute, contains AS number and IP address of a BGP speaker which performed routes aggregation.
224 <as-number>65000</as-number>
225 <network-address>192.0.2.2</network-address>
229 Optional attribute, used to store optional attributes, unrecognized by a local BGP speaker.
233 <unrecognized-attributes>
234 <partial>true</partial>
235 <transitive>true</transitive>
237 <value>0101010101010101</value>
238 </unrecognized-attributes>
240 **Route Reflector Attributes**
243 Optional attribute, carries BGP Identifier of the originator of the route.
248 <originator>41.41.41.41</originator>
252 Optional attribute, contains a list of CLUSTER_ID values representing the path that the route has traversed.
257 <cluster>40.40.40.40</cluster>
261 Optional attribute, may be used for policy routing.
266 <as-number>65000</as-number>
267 <semantics>30740</semantics>
270 **Extended Communities**
273 Identifies one or more routers that may receive a route.
277 <extended-communities>
278 <transitive>true</transitive>
280 <global-administrator>192.0.2.2</global-administrator>
281 <local-administrator>123</local-administrator>
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>
296 Identifies one or more routers that injected a route.
300 <extended-communities>
301 <transitive>true</transitive>
303 <global-administrator>192.0.2.2</global-administrator>
304 <local-administrator>123</local-administrator>
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>
319 Carries the cost to reach external neighbor.
323 <extended-communities>
324 <transitive>true</transitive>
325 <link-bandwidth-extended-community>
326 <bandwidth>BH9CQAA=</bandwidth>
327 </link-bandwidth-extended-community>
328 </extended-communities>
331 Optional attribute, carries accumulated IGP metric.
342 .. note:: When the remote peer disconnects, it disappear from operational state of local speaker instance and advertised routes are removed too.
344 External peering configuration
345 ''''''''''''''''''''''''''''''
346 An example above provided configuration for internal peering only.
347 Following configuration sample is intended for external peering:
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``
353 **Content-Type:** ``application/xml``
361 <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
362 <neighbor-address>192.0.2.3</neighbor-address>
364 <peer-type>EXTERNAL</peer-type>
365 <peer-as>64999</peer-as>
369 @line 5: AS number of the remote peer.
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:
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``
380 **Content-Type:** ``application/xml``
389 <router-id>192.0.2.2</router-id>
391 <route-reflector-cluster-id>192.0.2.1</route-reflector-cluster-id>
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.
399 Following configuration sample is intended for route reflector client peering:
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``
405 **Content-Type:** ``application/xml``
413 <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
414 <neighbor-address>192.0.2.4</neighbor-address>
416 <peer-type>INTERNAL</peer-type>
420 <route-reflector-client>true</route-reflector-client>
425 @line 8: Configure the neighbor as a route reflector client. Default value is *false*.
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:
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``
436 **Content-Type:** ``application/xml``
444 <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
445 <neighbor-address>192.0.2.5</neighbor-address>
447 <auth-password>topsecret</auth-password>
451 @line 4: Configures an MD5 authentication password for use with neighboring devices.
456 Allows the creation of a peer group configuration that applies to all peers configured as part of the group.
458 A sample peer group configuration follows:
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``
464 **Content-Type:** ``application/xml``
473 <peer-group-name>internal-neighbor</peer-group-name>
475 <peer-type>INTERNAL</peer-type>
476 <peer-as>64496</peer-as>
480 <remote-port>179</remote-port>
481 <passive-mode>true</passive-mode>
486 <hold-time>180</hold-time>
487 <connect-retry>10</connect-retry>
492 <route-reflector-client>false</route-reflector-client>
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>-->
503 <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV6-UNICAST</afi-safi-name>
506 <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV4-LABELLED-UNICAST</afi-safi-name>
509 <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV6-LABELLED-UNICAST</afi-safi-name>
512 <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:L3VPN-IPV4-UNICAST</afi-safi-name>
515 <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:L3VPN-IPV6-UNICAST</afi-safi-name>
518 <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:L2VPN-EVPN</afi-safi-name>
521 <afi-safi-name>LINKSTATE</afi-safi-name>
524 <afi-safi-name>IPV4-FLOW</afi-safi-name>
527 <afi-safi-name>IPV6-FLOW</afi-safi-name>
530 <afi-safi-name>IPV4-L3VPN-FLOW</afi-safi-name>
533 <afi-safi-name>IPV6-L3VPN-FLOW</afi-safi-name>
538 @line 2: Peer Group Identifier.
542 A sample basic neighbor configuration using a peer group follows:
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``
548 **Content-Type:** ``application/xml``
557 <neighbor-address>192.0.2.1</neighbor-address>
559 <peer-group>/bgp/neighbors/neighbor/bgp/peer-groups/peer-group[peer-group-name="internal-neighbor"]</peer-group>
563 @line 4: Peer group identifier.
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:
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``
574 **Content-Type:** ``application/xml``
582 <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
583 <neighbor-address>192.0.2.7</neighbor-address>
585 <simple-routing-policy>learn-none</simple-routing-policy>
589 @line 4: *Simple Routing Policy*:
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
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.
597 .. note:: The BGP configuration is persisted on OpendDaylight shutdown and restored after the re-start.