Lesson 12 advanced

Routing Protocols

The protocols routers use to learn routes: RIP, OSPF areas and costs, IS-IS, EIGRP, BGP autonomous systems, path attributes and route leaks, plus MPLS label switching and GRE tunnels, with FRRouting examples you can run on Linux.

Lesson 11 explained the families: distance vector, link state and path vector. This lesson meets the actual protocols you will find in networks today, what each one is good at, and how they look on a Linux router running FRRouting (FRR), the open-source routing suite used by many cloud providers, Kubernetes networking projects and white-box switches.

Overview

ProtocolTypeScopeTransportMetricWhere you see it
RIP v2 / RIPngDistance vectorInteriorUDP 520 / 521Hop count (max 15)Labs, tiny legacy networks
OSPFv2 / v3Link stateInteriorIP protocol 89Cost from bandwidthEnterprises, campus, data centers
IS-ISLink stateInteriorDirectly on layer 2Configurable costLarge ISPs and some data centers
EIGRPAdvanced distance vectorInteriorIP protocol 88Bandwidth + delayCisco-heavy enterprises
BGP-4Path vectorExterior (and big interiors)TCP 179Path attributes and policyThe internet, data center fabrics, Kubernetes

RIP

The oldest and simplest. Every 30 seconds each router sends its whole table to its neighbors; the metric is the number of hops, and 16 means “unreachable”. That limit caps a RIP network at 15 hops, and convergence after a failure can take minutes. Learn it to understand distance vector, then use something else.

OSPF

Open Shortest Path First is the most common interior protocol in enterprises.

  • Routers discover neighbors with Hello packets and form adjacencies.
  • They exchange LSAs (link-state advertisements) until all routers in an area have the same database, then run SPF.
  • Cost = reference bandwidth ÷ interface bandwidth. With the old default reference of 100 Mbit/s, every link of 100 Mbit/s or faster has cost 1, so set the reference higher (for example 100 Gbit/s) on modern networks.
  • On shared segments, a DR (designated router) and BDR reduce the number of adjacencies.

Areas

Big OSPF networks are split into areas to limit how far link-state floods travel. Area 0 is the backbone; every other area must connect to it through an ABR (area border router). Routes from other areas arrive as summaries, so a flapping link in one area does not force SPF everywhere.

A minimal FRR configuration:

router ospf
 ospf router-id 10.255.0.1
 auto-cost reference-bandwidth 100000
 network 10.0.12.0/30 area 0
 network 10.10.0.0/24 area 0
 passive-interface eth2

passive-interface advertises the LAN without sending Hellos into it, so no rogue device can become a neighbor.

$ sudo vtysh -c 'show ip ospf neighbor'
Neighbor ID     Pri State           Up Time         Dead Time Address         Interface
10.255.0.2        1 Full/-          01:12:44          34.217s 10.0.12.2       eth1:10.0.12.1

Full means the databases are synchronized. Stuck in ExStart or Exchange usually means an MTU mismatch; stuck in Init means Hellos only flow one way; no neighbor at all means mismatched area, subnet, timers or authentication.

IS-IS

Intermediate System to Intermediate System is the other link-state protocol. It does the same job as OSPF with a different structure: Level 1 (inside an area) and Level 2 (backbone) instead of numbered areas. It runs directly over layer 2, not IP, so it carries IPv4 and IPv6 in one instance easily. Large ISPs favor it for its stability and scale.

EIGRP

Enhanced Interior Gateway Routing Protocol began as a Cisco-only protocol (partly published in RFC 7868). It is a distance vector protocol with smart additions: the DUAL algorithm keeps a pre-computed loop-free backup path (a “feasible successor”) so failover is nearly instant, and its metric combines bandwidth and delay. You meet it in networks built mostly on Cisco gear.

BGP: the routing protocol of the internet

The internet is about 80,000 autonomous systems (ASes), each with an AS number (ASN), such as AS13335 or AS15169. BGP is how they tell each other which prefixes they can reach. The global IPv4 table holds more than a million prefixes.

  • BGP runs over TCP port 179 between configured neighbors (peers). Nothing is discovered automatically.
  • eBGP runs between different ASes; iBGP runs inside one AS to share external routes.
  • Each route carries its AS_PATH, the list of ASes it crossed. A router that sees its own ASN in the path rejects the route, which prevents loops.
  • Path choice follows attributes in order, the most important being local preference (prefer this exit), AS path length (shorter is better), origin, MED (hint from a neighbor about which entry to use) and finally tie-breakers. It is policy, not shortest path: a company might prefer its cheaper provider even if the path is longer.
router bgp 64512
 bgp router-id 10.255.0.1
 neighbor 203.0.113.1 remote-as 64500
 address-family ipv4 unicast
  network 198.51.100.0/24
  neighbor 203.0.113.1 prefix-list FROM-ISP in
  neighbor 203.0.113.1 prefix-list OUR-PREFIXES out
 exit-address-family
$ sudo vtysh -c 'show bgp summary'
Neighbor        V    AS   MsgRcvd   MsgSent   Up/Down  State/PfxRcd   PfxSnt
203.0.113.1     4 64500     98142        612  2d01h53m       1012347        1

The neighbor is up and sending over a million prefixes (a full table); we send one.

Always filter what you announce. BGP trusts its peers. A misconfigured router that announces prefixes it does not own (a route leak or hijack) can black-hole parts of the internet. Use prefix lists in and out, and sign your routes with RPKI so other networks can reject invalid announcements.

BGP is also used inside data centers (as the routing protocol of leaf-spine fabrics) and inside Kubernetes (Calico and Cilium announce Pod and Service addresses to the physical network with BGP).

MPLS

Multiprotocol Label Switching forwards packets by a short label instead of a full IP lookup. The ingress router classifies a packet, pushes a label, and every router along a label-switched path just swaps labels until the egress router pops it. It sits between layer 2 and 3, which is why it is called “layer 2.5”.

Why providers use it:

  • VPNs for business customers (L3VPN and L2VPN), keeping each customer’s routes separate even if they use the same private addresses.
  • Traffic engineering: forcing traffic onto chosen paths instead of the shortest one.
  • Fast reroute: pre-computed backup paths that switch in under 50 ms.

Many enterprises now buy SD-WAN over ordinary internet links instead of MPLS circuits, but provider backbones still run on MPLS or its newer form, Segment Routing.

GRE tunnels

Generic Routing Encapsulation (IP protocol 47) wraps one packet inside another IP packet. It lets you carry routing protocols, multicast or non-IP traffic across a network that would not route them, for example running OSPF between two sites over the internet. GRE adds 24 bytes of overhead and no encryption, so it is usually wrapped in IPsec.

$ sudo ip tunnel add gre1 mode gre local 198.51.100.10 remote 203.0.113.20 ttl 64
$ sudo ip addr add 10.99.0.1/30 dev gre1
$ sudo ip link set gre1 up mtu 1476
$ ping -c 1 10.99.0.2
64 bytes from 10.99.0.2: icmp_seq=1 ttl=64 time=21.3 ms

The MTU drops to 1,476 because the 24-byte GRE and outer IP headers must fit in the 1,500-byte path. Modern alternatives include VXLAN (layer 2 over UDP, used by cloud and Kubernetes overlays) and WireGuard (encrypted layer 3 tunnels).

Exercise

Two OSPF routers stay stuck in the ExStart state and never reach Full. What should you check first?

  1. The BGP AS number
  2. Whether the interface MTUs match
  3. The DHCP lease time
  4. The RIP hop count
Show answer

Answer: B. ExStart and Exchange are where routers trade database descriptions. A different MTU on each side makes those packets get rejected, so the adjacency never completes.

Exercise

How does BGP prevent routing loops between autonomous systems?

  1. By counting hops up to 16
  2. By running Dijkstra on the whole internet
  3. A router rejects any route whose AS_PATH already contains its own AS number
  4. By using administrative distance
Show answer

Answer: C. The AS_PATH lists every AS a route crossed. Seeing your own ASN means the route has looped back, so it is discarded.

Exercise

Why does a GRE tunnel interface usually get an MTU of 1,476?

  1. GRE and the outer IP header add 24 bytes that must fit inside the 1,500-byte path MTU
  2. GRE encrypts packets, which adds padding
  3. OSPF requires an MTU of 1,476
  4. Linux cannot create tunnels with an MTU of 1,500
Show answer

Answer: A. The outer 20-byte IP header and 4-byte GRE header wrap every packet. 1,500 − 24 = 1,476. GRE does not encrypt at all.

Key takeaways

  • RIP is simple and limited to 15 hops; use it to learn, not to build.
  • OSPF and IS-IS are link-state IGPs; OSPF uses areas around backbone area 0.
  • BGP connects autonomous systems over TCP 179 and chooses paths by policy and AS_PATH.
  • Filter BGP announcements and use RPKI to avoid leaks and hijacks.
  • MPLS forwards by labels for provider VPNs; GRE tunnels wrap packets but do not encrypt.

FAQ

Which interior protocol should I pick?

OSPF for most enterprise and campus networks, since every vendor supports it. IS-IS for very large provider networks. BGP alone is a popular choice for modern data center fabrics. EIGRP only if you are all Cisco and already use it.

Do I need BGP for my company?

Only if you have your own public address space and connect to two or more providers (multihoming) or run a data center fabric. A single internet connection only needs a default route.

Can I practise these protocols at home?

Yes. FRRouting runs in containers, and tools such as containerlab build whole topologies of FRR or vendor routers on a laptop from a short YAML file.

What is RPKI?

Resource Public Key Infrastructure: a system where address owners sign which AS may announce their prefixes. Routers that do route origin validation drop announcements that contradict the signed record.

↑ ↓ navigate Enter open Esc close