BGP Peering

To exchange routing information between two BGP systems (peers), it is required to configure a peering on both BGP speakers first. This mean that each BGP speaker has a white list of neighbors, representing remote peers, with which the peering is allowed. The TCP connection is established between two peers and they exchange messages to open and confirm the connection parameters followed by routes exchange.

Here is a sample basic neighbor configuration:

URL: /rests/data/openconfig-network-instance:network-instances/network-instance=global-bgp/openconfig-network-instance:protocols/protocol=openconfig-policy-types:BGP,bgp-example/bgp-openconfig-extensions:bgp/neighbors

Method: POST

Content-Type: application/xml

Request Body:

 1<neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
 2    <neighbor-address>192.0.2.1</neighbor-address>
 3    <timers>
 4        <config>
 5            <hold-time>90</hold-time>
 6            <connect-retry>10</connect-retry>
 7        </config>
 8    </timers>
 9    <transport>
10        <config>
11            <remote-port>179</remote-port>
12            <passive-mode>false</passive-mode>
13            <!--<local-address>192.0.2.5</local-address>-->
14        </config>
15    </transport>
16    <config>
17        <peer-type>INTERNAL</peer-type>
18    </config>
19    <afi-safis>
20        ...
21    </afi-safis>
22</neighbor>

@line 2: IP address of the remote BGP peer. Also serves as an unique identifier of a neighbor in a list of neighbors.

@line 5: Proposed number of seconds for value of the Hold Timer. Default value is 90.

@line 6: Time interval in seconds between attempts to establish session with the peer. Effective in active mode only. Default value is 30.

@line 11: Remote port number to which the local BGP is connecting. Effective in active mode only. Default value 179.

@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.

@line 13: Optional Local IP (either IPv4 or IPv6) address used to establish connections to the remote peer. Effective in active mode only.

@line 17: Explicitly designate the peer as internal or external. Default value is INTERNAL.

@line 19: Enable families.


Once the remote peer is connected and it advertised routes to local BGP system, routes are stored in peer’s RIBs. The RIBs can be checked via REST:

URL: /rests/data/bgp-rib:bgp-rib/rib=bgp-example/peer=bgp%3A%2F%2F192.0.2.1?content=nonconfig

Method: GET

Response Body:

 1<peer xmlns="urn:opendaylight:params:xml:ns:yang:bgp-rib">
 2    <peer-id>bgp://192.0.2.1</peer-id>
 3    <supported-tables>
 4        <afi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:ipv4-address-family</afi>
 5        <safi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:unicast-subsequent-address-family</safi>
 6    </supported-tables>
 7    <peer-role>ibgp</peer-role>
 8    <adj-rib-in>
 9        <tables>
10            <afi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:ipv4-address-family</afi>
11            <safi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:unicast-subsequent-address-family</safi>
12            <ipv4-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
13                <ipv4-route>
14                    <path-id>0</path-id>
15                    <prefix>10.0.0.10/32</prefix>
16                    <attributes>
17                        <as-path></as-path>
18                        <origin>
19                            <value>igp</value>
20                        </origin>
21                        <local-pref>
22                            <pref>100</pref>
23                        </local-pref>
24                        <ipv4-next-hop>
25                            <global>10.10.1.1</global>
26                        </ipv4-next-hop>
27                    </attributes>
28                </ipv4-route>
29            </ipv4-routes>
30            <attributes>
31                <uptodate>true</uptodate>
32            </attributes>
33        </tables>
34    </adj-rib-in>
35    <effective-rib-in>
36        <tables>
37            <afi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:ipv4-address-family</afi>
38            <safi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:unicast-subsequent-address-family</safi>
39            <ipv4-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
40                <ipv4-route>
41                    <path-id>0</path-id>
42                    <prefix>10.0.0.10/32</prefix>
43                    <attributes>
44                        <as-path></as-path>
45                        <origin>
46                            <value>igp</value>
47                        </origin>
48                        <local-pref>
49                            <pref>100</pref>
50                        </local-pref>
51                        <ipv4-next-hop>
52                            <global>10.10.1.1</global>
53                        </ipv4-next-hop>
54                    </attributes>
55                </ipv4-route>
56            </ipv4-routes>
57            <attributes>
58                <uptodate>true</uptodate>
59            </attributes>
60        </tables>
61    </effective-rib-in>
62    <adj-rib-out>
63        <tables>
64            <afi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:ipv4-address-family</afi>
65            <safi xmlns:x="urn:opendaylight:params:xml:ns:yang:bgp-types">x:unicast-subsequent-address-family</safi>
66            <ipv4-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet"></ipv4-routes>
67            <attributes></attributes>
68        </tables>
69    </adj-rib-out>
70</peer>

@line 8: Adj-RIB-In - Per-peer RIB, which contains unprocessed routes that has been advertised to local BGP speaker by the remote peer.

@line 13: Here is the reported route with destination 10.0.0.10/32 in Adj-RIB-In.

@line 35: Effective-RIB-In - Per-peer RIB, which contains processed routes as a result of applying inbound policy to Adj-RIB-In routes.

@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.

@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.

@line 66: The peer’s Adj-RIB-Out is empty as there are no routes to be advertise from local BGP speaker.


Also the same route should appeared in Loc-RIB now:

URL: /rests/data/bgp-rib:bgp-rib/rib=bgp-example/loc-rib/tables=bgp-types:ipv4-address-family,bgp-types:unicast-subsequent-address-family/ipv4-routes?content=nonconfig

Method: GET

Response Body:

 1<ipv4-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
 2    <ipv4-route>
 3        <path-id>0</path-id>
 4        <prefix>10.0.0.10/32</prefix>
 5        <attributes>
 6            <as-path></as-path>
 7            <origin>
 8                <value>igp</value>
 9            </origin>
10            <local-pref>
11                <pref>100</pref>
12            </local-pref>
13            <ipv4-next-hop>
14                <global>10.10.1.1</global>
15            </ipv4-next-hop>
16        </attributes>
17    </ipv4-route>
18</ipv4-routes>

@line 4: Destination - IPv4 Prefix Address.

@line 6: AS_PATH - mandatory attribute, contains a list of the autonomous system numbers through that routing information has traversed.

@line 8: ORIGIN - mandatory attribute, indicates an origin of the route - ibgp, egp, incomplete.

@line 11: LOCAL_PREF - indicates a degree of preference for external routes, higher value is preferred.

@line 14: NEXT_HOP - mandatory attribute, defines IP address of the router that should be used as the next hop to the destination.


There are much more attributes that may be carried along with the destination:

BGP-4 Path Attributes

  • MULTI_EXIT_DISC (MED)

    Optional attribute, to be used to discriminate among multiple exit/entry points on external links, lower number is preferred.

<multi-exit-disc>
    <med>0</med>
</multi-exit-disc>
  • ATOMIC_AGGREGATE

    Indicates whether AS_SET was excluded from AS_PATH due to routes aggregation.

<atomic-aggregate/>
  • AGGREGATOR

    Optional attribute, contains AS number and IP address of a BGP speaker which performed routes aggregation.

<aggregator>
    <as-number>65000</as-number>
    <network-address>192.0.2.2</network-address>
</aggregator>
  • Unrecognised

    Optional attribute, used to store optional attributes, unrecognized by a local BGP speaker.

<unrecognized-attributes>
    <partial>true</partial>
    <transitive>true</transitive>
    <type>101</type>
    <value>0101010101010101</value>
</unrecognized-attributes>

Route Reflector Attributes

  • ORIGINATOR_ID

    Optional attribute, carries BGP Identifier of the originator of the route.

<originator-id>
    <originator>41.41.41.41</originator>
</originator-id>
  • CLUSTER_LIST

    Optional attribute, contains a list of CLUSTER_ID values representing the path that the route has traversed.

<cluster-id>
    <cluster>40.40.40.40</cluster>
</cluster-id>
  • Communities

    Optional attribute, may be used for policy routing.

<communities>
    <as-number>65000</as-number>
    <semantics>30740</semantics>
</communities>

Extended Communities

  • Route Target

    Identifies one or more routers that may receive a route.

<extended-communities>
    <transitive>true</transitive>
    <route-target-ipv4>
        <global-administrator>192.0.2.2</global-administrator>
        <local-administrator>123</local-administrator>
    </route-target-ipv4>
</extended-communities>
<extended-communities>
    <transitive>true</transitive>
    <as-4-route-target-extended-community>
        <as-4-specific-common>
            <as-number>65000</as-number>
            <local-administrator>123</local-administrator>
        </as-4-specific-common>
    </as-4-route-target-extended-community>
</extended-communities>
  • Route Origin

    Identifies one or more routers that injected a route.

<extended-communities>
    <transitive>true</transitive>
    <route-origin-ipv4>
        <global-administrator>192.0.2.2</global-administrator>
        <local-administrator>123</local-administrator>
    </route-origin-ipv4>
</extended-communities>
<extended-communities>
    <transitive>true</transitive>
    <as-4-route-origin-extended-community>
        <as-4-specific-common>
            <as-number>65000</as-number>
            <local-administrator>123</local-administrator>
        </as-4-origin-common>
    </as-4-route-target-extended-community>
</extended-communities>
  • Link Bandwidth

    Carries the cost to reach external neighbor.

<extended-communities>
    <transitive>true</transitive>
    <link-bandwidth-extended-community>
        <bandwidth>BH9CQAA=</bandwidth>
    </link-bandwidth-extended-community>
</extended-communities>
  • AIGP

    Optional attribute, carries accumulated IGP metric.

<aigp>
    <aigp-tlv>
        <metric>120</metric>
    </aigp-tlv>
</aigp>

Note

When the remote peer disconnects, it disappear from operational state of local speaker instance and advertised routes are removed too.

External peering configuration

An example above provided configuration for internal peering only. Following configuration sample is intended for external peering:

URL: /rests/data/openconfig-network-instance:network-instances/network-instance=global-bgp/openconfig-network-instance:protocols/protocol=openconfig-policy-types:BGP,bgp-example/bgp-openconfig-extensions:bgp/neighbors

Method: POST

Content-Type: application/xml

Request Body:

1<neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
2    <neighbor-address>192.0.2.3</neighbor-address>
3    <config>
4        <peer-type>EXTERNAL</peer-type>
5        <peer-as>64999</peer-as>
6    </config>
7</neighbor>

@line 5: AS number of the remote peer.

Local AS

BGP eBGP with Local AS setup.

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.

In above figure, R3 is eBGP router with configured local-as of 62, and peer-as of 63.

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”.

AS 62 will be prepended to updates that are sent to and received from R3.

Following configuration sample is intended for external peering with Local AS:

URL: /rests/data/openconfig-network-instance:network-instances/network-instance=global-bgp/openconfig-network-instance:protocols/protocol=openconfig-policy-types:BGP,bgp-example/bgp-openconfig-extensions:bgp/neighbors

Method: POST

Content-Type: application/xml

Request Body:

1<neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
2    <neighbor-address>192.0.2.3</neighbor-address>
3    <config>
4        <peer-type>EXTERNAL</peer-type>
5        <peer-as>63</peer-as>
6        <local-as>62</local-as>
7    </config>
8</neighbor>

@line 5: AS number of the remote peer.

@line 6: Local AS number of the remote peer.

Route reflector configuration

The local BGP speaker can be configured with a specific cluster ID. Following example adds the cluster ID to the existing speaker instance:

URL: /rests/data/openconfig-network-instance:network-instances/network-instance=global-bgp/openconfig-network-instance:protocols/protocol=openconfig-policy-types:BGP,bgp-example/bgp-openconfig-extensions:bgp/global/config

Method: PUT

Content-Type: application/xml

Request Body:

1<config>
2    <router-id>192.0.2.2</router-id>
3    <as>65000</as>
4    <route-reflector-cluster-id>192.0.2.1</route-reflector-cluster-id>
5</config>
@line 4: Route-reflector cluster id to use when local router is configured as a route reflector.

The router-id is used as a default value.


Following configuration sample is intended for route reflector client peering:

URL: /rests/data/openconfig-network-instance:network-instances/network-instance=global-bgp/openconfig-network-instance:protocols/protocol=openconfig-policy-types:BGP,bgp-example/bgp-openconfig-extensions:bgp/neighbors

Method: POST

Content-Type: application/xml

Request Body:

 1<neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
 2    <neighbor-address>192.0.2.4</neighbor-address>
 3    <config>
 4        <peer-type>INTERNAL</peer-type>
 5    </config>
 6    <route-reflector>
 7        <config>
 8            <route-reflector-client>true</route-reflector-client>
 9        </config>
10    </route-reflector>
11</neighbor>

@line 8: Configure the neighbor as a route reflector client. Default value is false.

Route reflector and Multiple Cluster IDs

An optional non-transitive attribute called CLUSTER_LIST is modified when a route reflector reflects a prefix. For loop prevention the route reflector adds its own cluster ID to, and discards any update containing router’s own cluster ID. Using multiple cluster IDs allows updates to propagate to nodes that reside in a different cluster.

BGP RR Multiple Cluster IDs setup.

Following configuration sample is intended for route reflector client peering using specific cluster id:

URL: /rests/data/openconfig-network-instance:network-instances/network-instance=global-bgp/openconfig-network-instance:protocols/protocol=openconfig-policy-types:BGP,bgp-example/bgp-openconfig-extensions:bgp/neighbors

Method: POST

Content-Type: application/xml

Request Body:

 1<neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
 2    <neighbor-address>192.0.2.4</neighbor-address>
 3    <config>
 4        <peer-type>INTERNAL</peer-type>
 5    </config>
 6    <route-reflector>
 7        <config>
 8            <route-reflector-client>true</route-reflector-client>
 9            <route-reflector-cluster-id>192.0.2.4</route-reflector-cluster-id>
10        </config>
11    </route-reflector>
12</neighbor>

@line 8: Configure the neighbor as a route reflector client. Default value is false.

@line 9: Route-reflector cluster id to use for this specific neighbor when local router is configured as a route reflector.

MD5 authentication configuration

The OpenDaylight BGP implementation is supporting TCP MD5 for authentication. Sample configuration below shows how to set authentication password for a peer:

URL: /rests/data/openconfig-network-instance:network-instances/network-instance=global-bgp/openconfig-network-instance:protocols/protocol=openconfig-policy-types:BGP,bgp-example/bgp-openconfig-extensions:bgp/neighbors

Method: POST

Content-Type: application/xml

Request Body:

1<neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
2    <neighbor-address>192.0.2.5</neighbor-address>
3    <config>
4        <auth-password>topsecret</auth-password>
5    </config>
6</neighbor>

@line 4: Configures an MD5 authentication password for use with neighboring devices.

BGP Peer Group

Allows the creation of a peer group configuration that applies to all peers configured as part of the group.

A sample peer group configuration follows:

URL: /rests/data/openconfig-network-instance:network-instances/network-instance=global-bgp/openconfig-network-instance:protocols/protocol=openconfig-policy-types:BGP,bgp-example/bgp-openconfig-extensions:bgp/peer-groups

Method: POST

Content-Type: application/xml

Request Body:

 1<peer-group xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
 2    <peer-group-name>internal-neighbor</peer-group-name>
 3    <config>
 4        <peer-type>INTERNAL</peer-type>
 5        <peer-as>64496</peer-as>
 6    </config>
 7    <transport>
 8        <config>
 9            <remote-port>179</remote-port>
10            <passive-mode>true</passive-mode>
11        </config>
12    </transport>
13    <timers>
14        <config>
15            <hold-time>180</hold-time>
16            <connect-retry>10</connect-retry>
17        </config>
18    </timers>
19    <route-reflector>
20        <config>
21            <route-reflector-client>false</route-reflector-client>
22        </config>
23    </route-reflector>
24    <afi-safis>
25        <afi-safi>
26            <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV4-UNICAST</afi-safi-name>
27            <!--Advertise N Paths
28            <receive>true</receive>
29            <send-max>0</send-max>-->
30        </afi-safi>
31        <afi-safi>
32            <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV6-UNICAST</afi-safi-name>
33        </afi-safi>
34        <afi-safi>
35            <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV4-LABELLED-UNICAST</afi-safi-name>
36        </afi-safi>
37        <afi-safi>
38            <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV6-LABELLED-UNICAST</afi-safi-name>
39        </afi-safi>
40        <afi-safi>
41            <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:L3VPN-IPV4-UNICAST</afi-safi-name>
42        </afi-safi>
43        <afi-safi>
44            <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:L3VPN-IPV6-UNICAST</afi-safi-name>
45        </afi-safi>
46        <afi-safi>
47            <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:L2VPN-EVPN</afi-safi-name>
48        </afi-safi>
49        <afi-safi>
50            <afi-safi-name>LINKSTATE</afi-safi-name>
51        </afi-safi>
52        <afi-safi>
53            <afi-safi-name>IPV4-FLOW</afi-safi-name>
54        </afi-safi>
55        <afi-safi>
56            <afi-safi-name>IPV6-FLOW</afi-safi-name>
57        </afi-safi>
58        <afi-safi>
59            <afi-safi-name>IPV4-L3VPN-FLOW</afi-safi-name>
60        </afi-safi>
61        <afi-safi>
62            <afi-safi-name>IPV6-L3VPN-FLOW</afi-safi-name>
63        </afi-safi>
64    </afi-safis>
65</peer-group>

@line 2: Peer Group Identifier.


A sample basic neighbor configuration using a peer group follows:

URL: /rests/data/openconfig-network-instance:network-instances/network-instance=global-bgp/openconfig-network-instance:protocols/protocol=openconfig-policy-types:BGP,bgp-example/bgp-openconfig-extensions:bgp/neighbors

Method: POST

Content-Type: application/xml

Request Body:

1<neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
2   <neighbor-address>192.0.2.1</neighbor-address>
3   <config>
4      <peer-group>/bgp/neighbors/neighbor/bgp/peer-groups/peer-group[peer-group-name="internal-neighbor"]</peer-group>
5   </config>
6</neighbor>

@line 4: Peer group identifier.

Note

Existing neighbor configuration can be reconfigured (change configuration parameters) anytime. As a result, established connection is dropped, peer instance is recreated with a new configuration settings and connection re-established.

Note

The BGP configuration is persisted on OpendDaylight shutdown and restored after the re-start.