BGP Concepts

BGP Basic concepts
BGP neighbors do not have to reside in the same subnet as long as IP address is accessible.
BGP neighbors use TCP connection (179) to exchange topology information.
16-bit ASN assignments 


Next-Hop in BGP advertisement: For EBGP, the next hop is always the IP address of the neighbor specified in the neighbor command. For IBGP, the protocol states that the next hop advertised by EBGP should be carried into IBGP. Therefore, when the advertisement is passed through several hops, it is possible for the ultimate receivers to not know how to access the next-hop address in that BGP advertisement. Solution to this problem is issuing “neighbor x.x.x.x next-hop-self” on every transit routers.

iBGP neighborhood:  iBGP neighbors do not have to directly connected to each other as long as IP reachable. eBGP router need to manually configure each iBGP routers as its iBGP neighbor as the iBGP advertisements was never relayed by any iBGP routers. This is called the BGP split-horizon rule (which states that a route learned from one IBGP neighbor will not be advertised to another IBGP neighbor)

Enable eBGP
Router bgp {asn id}
Neighbor {neighbor Physical IP address} remote-as {neighbor’s ASN id}
bgp router-id {router ID} //Optional, same logic for router ID generation in EIGRP or OSPF
neighbor {eBGP peer loopback ip address} update-source {local loop back address}       //use loopback for eBGP updates when multi-connection, static route or IGP need to be configured to access remote loopback IP address.
neighbor { remote eBGP peer’s loopback ip address} ebgp-multihop xxx  ////by default, TTL for eBGP update exchange IP packet is 1, which is not suitable for exchange between loopback addresses.
neighbor x.x.x.x password xxxx            //MD5 authentication

BGP Path selection procedure
N | Next hop reachable | if not, route can not be used
W | Weight | Outbound | 16 bits long default 0 | bigger | cisco proprietary, local significant to each router and never advertised to neighbors.
L | Local Pref | Outbound | 32 bits long default 100 | bigger | exchanged in the whole AS, indicate the whole AS which path is preferred for outbound.
L | locally Injected | | local injected better than iBGP/eBGP learned, next hop = (redistribute from IGP, generated by network or aggregate command, )
A | AS_Path length | bidirectional | smaller
O | origin | Outbound | I>E>?//I: injected from IGP using network statement, E: from eBGP, ?: undetermined, redistributed from IGP
M | MED | Inbound | default 0 | smaller
N | Neighbor Type | | eBGP>iBGP
I | IGP metric to Next_Hop | | smaller
Oldest (longest-known) eBGP route
Lowest neighbor BGP RID
Lowest neighbor IP address

4 BGP attribute types:
+ Well-known Mandatory: recognized by all implementations of BGP and must appear in a BGP update message. If missing, a notification error will be generated.
+ Well-Known Discretionary: recognized by all implementations of BGP but may not be sent in the BGP update message (include LOCAL_PREF, ATOMIC_AGGREGATOR).
+ Optional Transitive: may or may not be recognized by all BGP implementations. Because the attribute is transitive, BGP accepts and advertises the attribute even if it is not recognized (include Community attribte).
+ Optional Nontransitive: may or may not be recognized by all BGP implementations. Whether or not the receiving BGP router recognizes the attribute, it is nontransitive and is not passed along to other BGP peers (include MED).
Well-know mandatory BGP attributes in BGP updates are Origin, AS_Path, Next_Hop.

BGP IP Address Summary
router(config)# router bgp 11
router(config-router)# aggregate-address [sumamry-only]
//by default, summary route and relevant subordinate subnets are all advertised, if “summary-only” specified, only summary route will be advertised.
Command only takes effect when one or more subordinate routes exist in the BGP routing table.

advertise internal routes to ISP through BGP
+ use aggregate routes
+ defining routes via network statement.
in BGP, the function of a network statement is to tell the router to search the IP routing table for a particular network, and if that network is found, originate it into the BGP database. But notice that you must have an exact match in the IP routing table in terms of both the prefix and prefix length with the ones specified in the network statement.

BGP synchronization
The complete synchronization rule is “A BGP router should not use, or advertise to an external neighbor, a route learned by IBGP, unless that route is local or is learned from the IGP.” By default, synchronization is disabled. Synchronization issue happens in iBGP-partial-meshed (some iBGP routers do not form iBGP neighborhood with eBGP router)  networks. The router who is not running iBGP but only IGP has no idea about the route path to external BGP network prefix. Therefore, it will drop the packets destined for external BGP network regardless the packets are self-originated or received from other internal routers, which is called black hole issue. So synchronization here mean the redistribution or synchronization between iBGP and IGP (RIP, EIGRP, OSPF etc).
While in iBGP-full-meshed Transit AS, synchronization should be turned off otherwise BGP will not work fine. There is not IGP running in iBGP-full-meshed AS (not physically full meshed), so the BGP router will never find the BGP external network in their IGP routing table, thus BGP router will never advertise the learned eBGP routes to other AS.

MD5 authentication
if RouterB has a password set but not RouterA, debug ip bgp will output “No MD5 digest from RouterA…”
If both ends has password set but different ones, debug ip bgp will output “Invalid MD5 digest from ….”