BGP (Border Gateway Protocol)

  • TCP port 179
  • Path vector protocol (list of AS on path to the network)
  • eBGP AD: 20
  • iBGP AD: 200
  • Loop prevention mechanism is AS_PATH attribute (if own AS in list, discard)
  • Triggered updates (only when something changes)

Message Types

Type Description
Open Attempt to establish peering - includes AS#, router ID, hold time. TCP 179
Keepalive Keeps peering active. 60 seconds default (Cisco)
Update New routes; withdrawn routes ; path attributes
Notification Sent when problem occurs. Connection closed when received

BGP States

Type Description
Idle Searching for neighbors
Connect TCP 3-way handshake complete w/ neighbor
Open Sent BGP Open message has been sent (displayed as "active")
Open Confirm Response received (displayed as "active")
Estabished Neighborship established

Synchronization

Requires that when a BGP router receives information about a network from an iBGP neighbor, it does not use that information until a matching route is learned via an IGP or static route

Generally prevents traffic from being forward to unreachable destinations

Reasons to turn off synchronization: - All routers in AS running BGP - All BGP routers are meshed - When not a transit AS

Router(config-router)# no synchronization

Split Horizon (iBGP)

  • Routes learned from iBGP are never propagated to other iBGP peers (unless you use route reflectors)

Next-hop

  • When a router receives an update from eBGP, it must pass the update to its iBGP neighbors without changing the next-hop attribute.
  • To change this behavior on the edge of an AS, use next-hop-self

Excellent link on BGP next-hop processing

  • BGP next hop is set to routers own address on EBGP sessions
  • Next-hop is not changed on iBGP sessions
  • Route reflectors cannot change BGP next hop of reflected routes

Attributes

Name Category Description
Origin Well-known Mandatory IGP / EGP / Unknown. iBGP (i) < eBGP (e) < incomplete (?). Origin IGP = network statement, incomplete = redistributed into BGP.
AS Path Well-known Mandatory List of AS's traversed. Prefer shortest.
Next Hop Well-known Mandatory External peer in neighboring AS. Not used in path selection
Local Preference Well-known Discretionary Metric for internal neighbors to reach destinations (default 100 - Cisco)
Atomic Aggregate Well-known Discretionary Includes ASes which have been dropped due to route aggregation
Aggregator Optional Transitive Id and AS of summarizing router
Community Optional Transitive Route tag
MED (Multiple Exit Discriminator) Optional Nontransitive Metric for external neighbors to reach the local AS (0 default)
Originator Id Optional Nontransitive Originator of a reflected route (identifies route refector)
Cluster List Optional Nontransitive List of cluster IDs (loop prevention for reflected routes simiar to AS_PATH)
Cluster ID Optional Nontransitive Originating cluster (route reflector)

BGP Route Selection Process

  1. Select only the routes whose next hop is reachable.
  2. Select route with highest WEIGHT [ Cisco Specific and Local on the router]
  3. Select route with highest LOCAL PREFERENCE [Local within an AS, default is 100]
  4. Select Locally originated Routes (Self sourced routes into BGP are preferred)
  5. Select Shortest AS Path
  6. Select Lowest Origin Code: IGP > EGP > Incomplete( Route with a ?)
  7. Select Lowest MED (shown as metric in sh ip bgp command). Used externally to enter an AS.
  8. Select EBGP routes over IBGP routes
  9. Select Smallest IGP metric to next-hop.
  10. Select Oldest Route (Age) - Does not apply to iBGP routes
  11. Select neighbor with Lowest Router ID
  12. Select Lowest Interface IP address if the router-id is the same.

Multi-hop

Example for peering between loopbacks for EBGP:

router bgp 65000
  ebgp-multihop 2
  update-source loopback 0
!
ip route 3.3.3.3 255.255.255.255 172.12.123.2

Example Configs

router bgp 100
  network 3.3.3.3 mask 255.255.255.255
  neighbor 172.12.123.2 remote-as 200

Setting default local-pref (globally):

router bgp 100
  bgp default local-preference 100

Summarization:

  • Without summary-only more specifics are advertised in addition to the summary aggregate route
router bgp 5
  aggregate-address 16.0.0.0 252.0.0.0 summary-only
  network 16.0.0.0 mask 255.0.0.0
  network 17.0.0.0 mask 255.0.0.0
  network 18.0.0.0 mask 255.0.0.0
  network 19.0.0.0 mask 255.0.0.0

Peer-Groups:

router bgp 100
  neighbor MyAS peer-group
  neighbor MyAS remote-as 100
  neighbor 10.1.1.1 peer-group MyAS
  neighbor 10.1.1.2 peer-group MyAS

Source address: neighbor 10.1.1.2 update-source loopback0

Authentication: neighbor 10.1.1.2 password c1sc0

Route-Reflector:

Specify clients on the route-reflector router

(config-router)# neighbor 172.1.1.1 route-reflector-client

Route Reflectors

  • Updates from RR clients are sent to all client and non-client peers
  • Updates from ebgp peers are sent to all client and non-client peers
  • Updates from non-client peers are sent to all clients

Prefix Lists

  • Have implicit deny
  • Auto-increment by 5 in IOS
  • Verify with show ip prefix-lists
ip prefix-list BLAH deny 16.0.0.0/8
ip prefix-list BLAH permit 0.0.0.0/0 le 32
router bgp 100
  neighbor 172.12.123.2 prefix-list BLAH out

Examples/explanations:

10.0.0.0/24 le 30 will match 10.0.0.0/24 and all prefixes contained therein with a length of 30 or less

0.0.0.0/0 le 32 matches any prefix with a length between 0 and 32 bits inclusive

10.0.0.0/8 ge 16 le 24 will match all prefixes within the 10.0.0.0/8 network having a mask both a) greater than or equal to 16 bits, and b) less than or equal to 24 bits in length

Private ASNs

  • 64496 - 65535

Adding to an existing list:

ip prefix-list BLAH seq 9 deny 55.55.55.55/32

Commands

show ip bgp neighbor
show ip bgp summary
show ip bgp
show ip bgp 3.3.3.3

Miscellaneous Notes

  • eBGP packets have a TTL of 1 (reason for ebgp-multihop)
  • "Soft" resets require soft-reconfiguration inbound, which keeps an unprocessed copy of neighbor updates. Requires more memory. Does not tear down BGP session or flap.
  • Route refresh capability can request neighbor re-advertise all routes. Negotiated in Open message exchange. Cannot use soft-reconfiguration simultaneously on Cisco with route-refresh.
  • When advertising routes with the network command, it must be an exact match for a network in the RIB. Use mask or the match is classful.
  • Always check route to the next-hop if a route is not showing as valid in show ip bgp.
  • Router ID is the highest IP loopback, or highest IP of an up interface. Can be manually set with (config-router)# bgp router-id 1.1.1.1. Changing the router-id drops adjacencies.

Design notes

  • IBGP sessions configured between loopback addresses and EBGP sessions configured across directly connected subnets (best practice)

Sample packets

Open:

bgp-open

Update:

bgp-update

Keepalive:

bgp-keepalive

Notification:

bgp-notification

Route Refresh: bgp-route-refresh