BGP is the routing protocol of the internet. Where OSPF routes inside an organization, BGP exchanges routes between them — between autonomous systems.
Why: OSPF routes WITHIN an organization (an autonomous system); BGP routes BETWEEN them, which is how independently run networks — ISPs, enterprises, clouds — exchange reachability to form the internet. When: you run BGP at the edge to peer with an ISP or between data centers. Where: each network has an AS number, and BGP advertises which prefixes each AS can reach.
AS 65001 (your network) <---BGP peering---> AS 64500 (your ISP)
OSPF/EIGRP = interior (inside one AS, find best internal paths)
BGP = exterior (between ASes, policy-based reachability)
BGP chooses paths by POLICY and attributes (AS-path length, local
preference, ...), not just by lowest cost — control, not just speed.Why: eBGP is set up by declaring your AS, defining the neighbor and its remote AS, and advertising the networks you own — the two routers then exchange their prefixes. When: peer with an ISP to advertise your public network and learn internet routes. Where: the neighbor’s remote-as must match its actual AS, or the session never establishes.
R1(config)# router bgp 65001 ! MY autonomous system
R1(config-router)# neighbor 203.0.113.1 remote-as 64500 ! the ISP's AS
R1(config-router)# network 198.51.100.0 mask 255.255.255.0 ! a prefix I own
R1# show ip bgp summary ! neighbor state should be "Established"
R1# show ip bgp ! the BGP table with AS-pathsWhy: unlike interior protocols that just find the fastest path, BGP lets you shape traffic with attributes — prefer one ISP for outbound (local preference), influence inbound (AS-path prepending) — because between networks, business policy matters as much as performance. When: use these knobs for multi-homing (two ISPs) and traffic engineering. Where: a small policy mistake can leak routes or black-hole traffic, so BGP changes are handled carefully.
ATTRIBUTE CONTROLS HIGHER/LOWER WINS
Local Preference outbound path higher wins (within your AS)
AS-Path length path selection shorter wins
MED inbound hint lower wins
AS-Path prepend make a path look longer -> less preferred inbound
BGP is about CONTROL. That power is also why mistakes are impactful.