A real-life situation
The company's website must stay online even if its ISP has an outage. So it signs up with a second ISP. Now the rest of the internet needs to know that the company's public addresses, 198.51.100.0/24, can be reached through either ISP. A static default route can't announce anything to the internet. This is BGP's job.
What BGP is
BGP (Border Gateway Protocol) is the routing protocol that connects separate networks into the internet. Each of those networks is an autonomous system (AS): a group of routers run by one organisation with one routing policy. Each AS has a number, an ASN. In this lesson the company is AS 64500 and its ISPs are AS 64501 and AS 64502 (numbers reserved for documentation).
BGP is a path-vector protocol. Every route carries the AS path: the list of ASes it has passed through. A router that sees its own ASN in the path rejects the route, which stops loops between networks.
- 1. R1 announces the company's block to both ISPs. AS path so far: 64500.
- 2. The ISPs pass it on, each adding its own ASN to the path. The internet now knows two ways in.
- 3. ISP-A fails: its announcement is withdrawn, and traffic arrives through ISP-B instead.
eBGP and iBGP
| eBGP (external) | iBGP (internal) | |
|---|---|---|
| Neighbours are in | Different ASes | The same AS |
| Used for | Exchanging routes with ISPs and partners | Carrying those routes across your own AS |
| Administrative distance | 20 | 200 |
BGP neighbours, called peers, are configured by hand and talk over a TCP connection on port 179. Nothing is discovered automatically like OSPF's hellos.
Why it works this way
OSPF runs inside one network you control, so it simply finds the cheapest path. BGP runs between organisations that don't trust each other and have business rules: "use the cheaper ISP for outbound traffic", "never carry traffic between my two providers". So BGP chooses paths by policy, using attributes such as local preference and AS path length, rather than by speed. It is also built to carry about a million internet routes calmly, which no IGP is designed for.
| OSPF | BGP | |
|---|---|---|
| Type | IGP, link state | EGP, path vector |
| Runs | Inside one organisation | Between organisations (and inside large ones) |
| Picks paths by | Lowest cost | Policy and attributes |
| Neighbours | Found automatically | Configured by hand, over TCP 179 |
A minimal example
⚠️ Based on Cisco IOS / IOS XE documentation, not run on a lab device. Real ISP connections also need filters so you only announce your own prefix; that is beyond the CCNA.
ip route 198.51.100.0 255.255.255.0 Null0
router bgp 64500
neighbor 203.0.113.1 remote-as 64501
neighbor 192.0.2.1 remote-as 64502
network 198.51.100.0 mask 255.255.255.0On R1. BGP only announces a network that exists exactly in the routing table, so a static route to Null0 (a discard interface) holds the /24 in place.
How to verify it
This output is based on Cisco documentation, not run on a lab device.
R1#show ip bgp summary BGP router identifier 1.1.1.1, local AS number 64500 BGP table version is 4, main routing table version 4 2 network entries using 496 bytes of memory 3 path entries using 408 bytes of memory Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 192.0.2.1 4 64502 38 36 4 0 0 00:31:02 1 203.0.113.1 4 64501 45 42 4 0 0 00:35:10 1
Idle or Active there means the session is not up.Check yourself
Two routers in the same AS run BGP with each other. What is this called?
A BGP route arrives with AS path 64502 64500 at a router in AS 64500. What does the router do?