BGP - jibingl/CCNA-CCNP GitHub Wiki

Border Gateway Protocol

BGP is an exterior gateway protocol (EGP) designed to exchange routing and reachability information among ASs on the Internet.

  • iBGP (Internal BGP) - Within an AS
  • eBGP (External BGP) - AS to AS

Each AS is identified by an ASN that is either public or private. A public ASN is globally unique and can be advertised across the Internet; however, a private ASN is not globally unique and should not be advertised to external networks. Private ASNs range from 64512 to 65534, and from 4,200,000,000 to 4,294,967,294. All other ASNs are public and available for use on the Internet except for a few reserved numbers.

eBGP iBGP
Use case Between ASs Within an AS
AD value 20 200
How a BGP router handles next_hop value when received a BGP advertisement Update to neighbor (another AS) router's IP No update at all
How a BGP router handles as_path info when sending a BGP advertisement Prepend its own AS number No changes

Example - eBGP Basic

Topology

Configurations

On ISP

ISP(config)# router bgp 65000
ISP(config-router)# neighbor 61.203.1.2 remote-as 65001

On R1

R1(config)# router bgp 65001
R1(config-router)# neighbor 61.203.1.1 remote-as 65000
R1(config-router)# network 10.0.0.0 mask 255.255.255.0
R1(config-router)# network 192.168.1.0 mask 255.255.255.0

show ip route on ISP

show ip bgp on ISP

show ip route on R1

show ip bgp on R1


BGP Attributes

There are many attributes used to decide BGP path selection. Below are some.

Attribute Name Value About Path Selection Preference Attribute category
Weight 0 - 65535 A locally significant, Cisco-specific param. Default is 0. Higher
LOCAL_PREF 0 - 4,294,967,295 A param communicated throughout a single AS. Default is 100. Higher
Originated Impacted by next_hop "Do I connect to the network directly?" If so, next hop is 0.0.0.0. Locally well-known, mandatory
AS_Path ASNs All numbers of ASs on the path to a destination network Shorter well-known, mandatory
Origin i, e or ? How the route was injected into BGP: i(IGP), e(EGP), or ?(Other means). i > e > ? well-known, mandatory
MED Metric Set and advertised to influence routers' selection within another AS. Lower
Paths i or e eBGP > iBGP
Router ID Lower

image

AS_PATH

The AS_PATH attribute is a list of all ASs that a specific route passes through to reach a specified network. When a router is advertising a BGP route, the AS_PATH attribute is first created empty. Each time the route is advertised from one AS to another, the AS_PATH attribute is modified to prepend the ASN of the router that advertised the route.

Routers use the AS_PATH attribute to detect and prevent loops. For example, a router drops any route in which its own ASN is part of the AS_PATH attribute.

Private ASNs are not globally unique, hence, they cannot be leaked to the Internet. To achieve this goal, routers must strip the private ASNs from the AS_PATH attribute list before the routes are advertised to the Internet.

(config)# route-map prepend_out permit 10
(config-route-map)# set as-path prepend 100 100
(config-route-map)# exit
(config)# router bgp 100
(config-router)# neighbor 192.168.45.2 route-map prepend_out out

LOCAL_PREF

A router sending iBGP update packets will include the LOCAL_PREF attribute. This attribute indicates the degree of preference for one BGP route over the others when an AS has multiple routes to another AS. The LOCAL_PREF attribute is always advertised to iBGP neighbors and never advertised to eBGP peers, hence, it is exchanged only among routers within the same AS. The BGP route with the highest LOCAL_PREF value is preferred.

(config)# route-map primary_outbound permit 10
(config-route-map)# set local-preference 150
(config-route-map)# exit
(config)# router ospf 200
(config-router)# neighbor 192.168.12.1 route-map primary_outbound in

(config)# route-map secondary_outbound permit 10
(config-route-map)# set local-preference 125
(config-route-map)# exit
(config)# router ospf 200
(config-router)# neighbor 192.168.13.1 route-map secondary_outbound in

MED

The MED (Multi Exit Discriminator) attribute indicates to external neighbors the preferred path into an AS if there are multiple entry points into the same AS. The BGP route with the lowest MED value is preferred.
The MED is sent to eBGP peers; those peer routers propagate the MED attribute within their AS, but do not pass it on to the next AS.

(config)# route-map primary_med_inbound permit 10
(config-route-map)# set metric 50
(config-route-map)# exit
(config)# router ospf 200
(config-router)# neighbor 192.168.12.1 route-map primary_med_inbound out

(config)# route-map secondary_med_inbound permit 10
(config-route-map)# set metric 75
(config-route-map)# exit
(config)# router ospf 200
(config-router)# neighbor 192.168.13.1 route-map secondary_med_inbound out

BGP Neighbors

Kevin Wallace Training, LLC
image


Multiprotocol and Redistributing Routing Protocols


Full Mesh IBGP topology

A topology is called full mesh (fully meshed topology) when there is an IBGP peering relationship between any two routers in the AS. All BGP routers within a single AS must be fully meshed so that any external routing information must be re-distributed to all other routers within that AS.


BGP Route Reflection

A BGP route reflector is an IBGP router (R1) that repeats routes learned from IBGP peers (R2 and R3) to some of its other IBGP peers, its clients (R4, R5, and R6).

neighbor 192.168.23.1 route-reflector-client
neighbor 192.168.34.2 route-reflector-client