Skip to content

BGP

Border Gateway Protocol

Border Gateway Protocol (BGP) is an EGP standardized path-vector routing protocol that guarantees scalability, flexibility, and network stability. It was established by the Internet Engineering Task Force (IETF) and is known as the primary routing protocol for service provider networks and the internet. BGP was initially designed to provide internet connectivity information, but has expanded its ability to support multicast, IPv6, and VPN routes, among other forms of data.

The Neighbor Command

  • The peering between routers works differently for BGP than IGPs.
  • BGP routers located in the same AS may not be physically connected to each other directly, and could be separated by several intermediary hops.
  • Using link-local multicast Hello messages to form adjacencies is not possible, as they are not forwarded to another interface.
  • To establish BGP peering, it is necessary to specify the neighbor manually. This is done by including a neighbor statement in the configuration and providing the IP address of the peer router.

How BGP works

  • The administrator configures BGP and specifies the neighbor IP address.
  • In order for a router to send BGP packets to the destination router, there must be a route to the neighbor IP address in the router's routing table. Otherwise, the router will not know how to reach the destination.

iBGP Neighbors

  • If the BGP session is established using the IP address of a physical interface, and that interface becomes unavailable, the BGP session will be disrupted, even if there are alternative paths available to reach the router.
  • Loopback addresses, usually advertised within the IGP, are commonly used as the address in the neighbor statement for BGP peers. This allows the BGP peers to maintain connectivity with each other even if a physical interface fails.

BGP Router Advertisement Rules

  • BGP gives more importance to advertising routes that it is actively using.
  • BGP advertises routes it has learned from an external BGP peer with all of its BGP peers, whether they are external or internal to its own network.
  • Once BGP has successfully connected with a new peer, BGP advertises all the routes matching the above criteria to the peer. Then, BGP only shares updates related to changes or additions to those routes with the peer.
FRR Command Explanation
router bgp ASN Enable a BGP protocol process with the specified ASN.
bgp router-id X.X.X.X Sets the router's id, which is used as a source for identifying route source
neighbor PEER remote-as ASN Creates a new neighbor whose remote-as is ASN. PEER can be an IPv4 address or an IPv6 address or an interface to use for the connection.
neighbor PEER update-source lo Used for iBGP, to make BGP-peering sourced from loopback, which allows igp to control internal routing.
redistribute \ Redistribute routes from other protocols into BGP. Must be defined inside an address-family
VyOS Command Explanation
set protocols bgp $name neighbor $address remote-as '$as-number' Specify a BGP neighbor
set protocols bgp $name address-family ipv4-unicast network '$address' Specify a network to redistribute
set protocols bgp $name address-family redistribute \ redistributes the selected routing source into bgp
set protocols bgp $name parameters router-id X.X.X.X Specifies the bgp router-ID of the router.

Address-family specification

Inside the BGP, configuration, there are multiple options tied to a specific address-family. BGP uses mostly the same protocol for both IPv4 and IPv6 for communicating with peers (establishing and maintaining a BGP-connection), but has further options regarind route-distribution for each protocol. For this, address-family subsets are used when configuring BGP. For TTM4240, address families IPv4-Unicast and IPv6-Unicast are used. Notice, that when configuring each of the address-types, the inputs are set within the correct address-family.

FRR example:

router bgp AS
 bgp router-id ROUTER-ID
 neighbor PEER remote-as PEER-AS
 neighbor iBGP-PEER-LOOPBACK-ADDRESS remote-as AS (Same AS as local router)
 neighbor iBGP-PEER-LOOPBACK-ADDRESS update-source LOOPBACK-ADDRESS
 !
 address-family ipv4 unicast
  network NETWORK-TO-SHARE
  redistribute connected
  redistribute ospf
  neighbor PEER prefix-list PREFIX-LIST-NAME-IPv4 in
  neighbor PEER prefix-list PREFIX-LIST-NAME-IPv4 out
 exit-address-family
 address-family ipv6 unicast
  redistribute connected
  redistribute ospf6
  neighbor PEER activate
  neighbor PEER prefix-list PREFIX-LIST-NAME-IPv6 in
  neighbor PEER prefix-list PREFIX-LIST-NAME-IPv6 out

VyOS example:

set protocols bgp $name address-family ipv4-unicast redistribute connected
set protocols bgp $name address-family ipv6-unicast redistribute connected
set protocols bgp $name neighbor PEER remote-as PEER-AS
set protocols bgp $name neighbor PEER address-family ipv4-unicast prefix-list export PREFIX-LIST-NAME-IPv4
set protocols bgp $name neighbor PEER address-family ipv4-unicast prefix-list import PREFIX-LIST-NAME-IPv4
set protocols bgp $name neighbor PEER address-family ipv6-unicast prefix-list export PREFIX-LIST-NAME-IPv6
set protocols bgp $name neighbor PEER address-family ipv6-unicast prefix-list import PREFIX-LIST-NAME-IPv6
set protocols bgp $name parameters router-id ROUTER-ID (probably ipv4 loopback address)