Compared
OSPF vs BGP
OSPF routes inside one organisation: every router holds the same map and computes the shortest path by link cost. BGP routes between organisations, the autonomous systems of the internet: each announces its networks, and the path through the fewest systems wins unless policy says otherwise.
Side by side
| OSPF | BGP | |
|---|---|---|
| Runs | Inside one autonomous system | Between autonomous systems |
| Kind | Link state: every router holds the same map and runs Dijkstra on it | Path vector: each announcement carries the list of systems it crossed (the AS path) |
| Best path | Lowest total link cost | Local preference first, then the shortest AS path; link speed plays no part |
| Neighbours | Found by Hello packets on a shared link | Configured by hand |
| Carried in | Its own IP protocol, number 89 | A TCP connection to port 179 |
| After a failure | Every router recomputes within seconds | A silent peer is dropped after the hold time, and its routes withdrawn |
Each one explained
- OSPF
- A routing protocol inside one organisation: routers share a map and compute shortest paths.
- BGP
- The protocol between autonomous systems: how the networks of the internet find each other.
- Autonomous system
- A network run by one organisation, with a number of its own, as seen by the rest of the internet.
- AS path
- The list of autonomous systems a BGP route crossed: used to choose paths and to prevent loops.
- Local preference
- A BGP value an AS sets on routes it receives to choose its own way out, checked before the AS path.
See the difference on real machines
Each lab is a small network of real Linux machines in your browser.
- OSPF routing: every router holds the same map
- BGP routing: how the internet's networks find each other
- BGP policies: steering traffic and refusing bad routes
Open OSPF routing: every router holds the same map