Anycast: The Loophole

As I mentioned in my last post, there’s a loophole inherent in how routers forward your packets around the Internet—specifically, routers are next-hop forwarding: your data is sent as a stream of packets to a router, and it looks at its routing table and decides where the packet should go next.

A route is just an entry in a table that says “packets for should be sent to this IP address, which will send it to the right place for you.” On the last router before the host, the route says “ is right here, so just send it to the MAC address associated with that IP straight away.”

So here’s the first half of the loophole: Each router decides for itself what the routing table looks like. There’s nothing saying that two different routers can’t *both* have totally different routes to a particular IP. Whichever route you take depends entirely on which router your packets go through on the way to the destination. This is inherent in how IP networks work.

Here’s the second half of the loophole: there’s nothing that says that an IP address has to be unique to a particular machine or network interface.

Anycast DNS

Put those two together, and you’ve got the basics of anycasting: two different servers, in two different cities, both own The router each server is plugged into knows that IP is right there, and because routers need to know what the other router does in order to be useful, each router knows that there is *another* route to that same IP via the router in the other city.

The routers talk either talk to each other via an Interior Gateway Protocol (basically, they each say “these are all the routes I have”), or they’re statically configured to know about each other. You actually have to do this for anything to work.

And if your network is sane, any overlapping routes have a concept of metrics: that is, how much does it “cost” to go from here to there. The cost of a connected route is (by default) 1. The cost of anything else is going to be higher—because there’s the other side’s “1”, plus the cost of the link (in this case, the link between the two cities). So whichever router has a better metric is the one that will be used.

But all this is transparent. You’re still just talking to, but that IP is “owned” by lots of servers, and the routers decide which way to send the traffic (that is, they do their jobs :-)).

Now, it’s not quite that simple to implement this. You’ve got to have a sane network—one with a properly configured IGP—and you’ve got to have some way to “watch” the service.

More on that in the next installment:

  1. Anycast: Networking Introduction
  2. Anycast: The Loophole
  3. Anycast: The Interface
  4. Anycast: Handling Routes
  5. Anycast: DGRAM vs. STREAM
  6. Anycast: IP-SLA HOWTO


  1. David says:

    Looking forward to the next iteration 🙂 That was an extremely simple way of explaining it.

  2. Daniel Morgan says:

    Very interesting. By day, I am a programmer, but I am very lacking in my understanding of computer networks — especially TCP/IP. I’ve gotten many books on TCP/IP, but they assumed you already knew a lot before reading the book. What you wrote is easy to understand, and I would like to read more.

Comments are closed.