How BGP Works: Internet Routing, Route Hijacks & RPKI (Animated)
The internet is a network of networks, called autonomous systems (AS). BGP is how they tell each other “these IP addresses live with me, send traffic this way”. It works largely on trust, so a wrong announcement can send a bank’s traffic, or a whole country’s, to the wrong place.
1. Peering: two networks agree to talk
Neighbouring routers open a TCP session on port 179, exchange OPEN messages with their AS numbers, then send KEEPALIVEs.
- OPEN (Bank network → Transit provider): The bank’s router introduces itself.
- OPEN + KEEPALIVE (Transit provider → Bank network): The session is up.
Wireshark filter:
bgp.type == 1 || bgp.type == 4
2. Announce a route: update: “these addresses are mine”
The bank announces its address block. Each network that passes it on adds its own AS number to the AS path.
- UPDATE (Bank network → Transit provider): The bank says: this /24 lives with me.
- UPDATE (Transit provider → Your ISP): The transit provider passes it on, adding its own AS.
- TRAFFIC (Your ISP → Bank network): Customers reach the real bank.
Wireshark filter:
bgp.type == 2
3. Route hijack: attack: announcing someone else’s addresses
A network (through a mistake or on purpose) announces a more specific slice of the bank’s block. Routers always prefer the most specific route, so traffic for those addresses flows to the wrong network.
- UPDATE (Hijacking network → Transit provider): A false, more specific announcement.
- UPDATE (Transit provider → Your ISP): Nobody checks the origin, so it spreads.
- TRAFFIC (Your ISP → Hijacking network): Customers’ traffic to the bank now goes to the wrong network. HTTPS certificates are the last line of defence.
Wireshark filter:
bgp.type == 2 && bgp.update.path_attribute.as_path contains 64666
4. Rpki & filters: defence: check who may announce what
Address holders publish signed ROAs (“only AS 64500 may announce 203.0.113.0/24, up to /24”). Networks that perform route origin validation drop announcements marked invalid. Prefix filters with customers add another layer.
- UPDATE (Hijacking network → Transit provider): The transit provider rejects the invalid route.
- TRAFFIC (Your ISP → Bank network): Traffic keeps going to the real bank.
Check a prefix:
Look up the prefix in an RPKI validator (status: Valid / Invalid / Not found)
Practise this in a real lab
Build a small BGP topology in a lab, watch announcements and withdrawals, cause a route leak on purpose, and fix it with filters and RPKI.
Explore ER Segment training →FAQ
What is an autonomous system?
A network under one administration with its own routing policy and an AS number, such as an ISP, a cloud provider or a large company.
Why do more specific routes win?
Routers always prefer the longest matching prefix, so a /25 beats a /24 for the addresses it covers.
What is RPKI?
Resource Public Key Infrastructure: signed records (ROAs) stating which AS may announce which prefixes, so routers can reject invalid origins.