Fri Sep 8 12:18:39 EDT 2017
A routing protocol does three things:
RIP and OSPF are Interior Gateway Protocols (IGP). BGP is and Exterior Gateway Protocol (EGP), the routing protocol of the public internet.
RIP is an old distance vector routing protocol that uses hop count as a metric to find the best route. It routes messages up to fifteen hops (a limit to prevent routing loops).
RIP routers send messages to query routing tables from neighboring routers. Neighbors respond by sending their full routing tables. The original routers merges all the replies into its own routing table. These exchanges occur periodically (usually every thirty seconds) to propagate changes across the network.
Every RIP packet includes a command, a version number, a Routing Domain, and up to twenty-five routes. The routing domain specifies which routers should pay attention; more than one routing domain can operate on the same network. Each of the twenty-five routes include the starting address of the network, the netmask, the next-hop IP, and a Metric indicating how many hops away the network is. (“Routing by rumor”; RIP includes networks it had only heard about, and when it re-sends that route it increments the metric.)
Configuring RIP is usually as simple as setting which networks to advertise.
RIP has three versions: RIP v1 (obsolete), RIP v2, and RIPng (which adds IPv6 support).
RIP uses UDP port 520 (and 521 for RIPng).
On OpenBSD, see RIPD(8), RIPD.CONF(5), and RIPCTL(8). On linux, check out the “quagga” packages and quagga’s ripd.
Open Shortest Path First improves on RIP by removing the fifteen hop limit. OSPF is a link-state routing protocol that uses a routing hierarchy to improve performance and management on larger networks.
OSPF is more complex than RIP, but significantly more capable.
OSPF routers can exchange individual route data (Link State Advertisements) rather than entire routing tables. Routing information propagates through a routing domain by a process called flooding.
OSPF routers discover one another automatically via OSPF hello packets. OSPF routers communicate via two multicast groups: 188.8.131.52 (all Shortest Path First routers) and 184.108.40.206 (all Designated Routers). OSPF runs directly on top of IP and uses neither TCP nor UDP.
How OSPF operates:
OSPFv2 exchanges can be authenticated. OSPFv3 uses IPsec. OSPF supports various auth schemes, and different schemes can be configures for different areas.
On OpenBSD, see OSPFD(8), OSPFD.CONF(5), and OSPFCTL(8). (There are IPv6 version too, like
On linux, check out the “quagga” packages and quagga’s ospfd.
When a router has more than one possible route to the same destination network, it uses a route metric to choose between them. RIP uses hop count as the metric. OSPF calls its metric “cost”.
OSPF assigns cost per interface. The cost of an interface is inversely proportional to its bandwidth (i.e. — a fast link has a low cost). OSPF calculates the cost as 100000000 (bits per second, i.e., 100 Mbps) divided by the actual bandwidth of the link in bps. For example, a 6Mbps link has a cost of 16.666 (100000000⁄6000000).
In most OSPF implementations, it also possible to manually configure a link cost.
OSPF can’t flood routes across IPsec (no routable interface, and IPsec doesn’t pass multicast traffic). Use a GRE tunnel, or a VTI. It’s also possible to in some scenarios to configure OSPF in non-broadcast mode.
BGP (Border Gateway Protocol) is the routing protocol of the internet. (It bears minimal resemblance to RIP, OSPF and EIGRP, which are all interior gateway protocols.)
Someone on the internet describes BGP: > AS, standing for Autonomous System, is like an ISP’s name. BGP spreads routing information by rumor. For example, I start the rumor that I can route to IP addresses in 220.127.116.11/24, and tell my peer ISPs. They tell their peers I told them… etc. To prevent rumors from going in circles, you keep a record of every ISP in the path of spreading the rumor, and call it the AS path. (Otherwise you could never retract the rumor, as it would go in circles. BGP speakers do not accept rumors that they themselves are in the path of. (Except in cases of dirty hacks, but then only a finite number of times.))
Imagine the following scenario. We have a company with a router, a web server, and a mail server. We want the redundancy of two different ISP’s. How do we keep our web and mail server available on either of the connections? Use our own IP address (rather than ones from the ISP’s) and BGP.
Of course, this is less useful to non-huge companies than it was before IPv4 address exhaustion. It is possible to get IPv6 blocks from ARIN if (as of 2017) you meet one of the following requirements:
Getting an ASN involves paying ARIN an initial fee ($550) and an annual recurring fee ($100).
Note that it is often unnecessary to own an IPv4 block to do multihoming (which is good, since they’re scarce). Many ISP’s willing to lease a /24 or larger to customers, are also willing to let customers announce that block on a second link from another ISP.