According to this answer Google DNS ( has low worldwide latencies because it uses anycast.

How is anycast actually implemented? That is, how does a packet get routed to different computers around the world?

Wouldn't that mean that different versions of routing tables exists? If yes, who controls what these routing tables contain?


3 Answers 3


Wouldn't that mean that different versions of routing tables exists? If yes, who controls what these routing tables contain?

Yes. Each router maintains its own routing table. Anycast is simply that the same network is advertised from multiple places. A router receiving multiple advertisements for the same network will choose which advertisement to place in its routing table based on the metrics of the routing protocol. This results in the closest (from the perspective of the routing protocol metrics) destination being used by a router.

For example, the primary way that BGP determines which of multiple destinations is the closest by the number of ASes in the AS_PATH attribute. If a router receives five advertisements for the network, it will choose one to place in its routing table, and it will route the traffic destined for to that network. If the site with that network goes down, the entry in its routing table will be withdrawn, and the next closest destination will be placed in its routing table.

Different routers in different locations will each make their own independent determinations as to which destination is closest. Anycast is simply advertising the same network from multiple sites and letting each router determine for itself where to send traffic destined for that network.

  • "Anycast is simply advertising the same network from multiple sites", doesn't have a different network for different (geographical) sites though? E.g. A ping to would be routed to different machines from London then from Toronto Canada. Commented Sep 19, 2017 at 16:31
  • 4
    No, belongs to the network which contains that address. Individual addresses are not advertised on the public Internet. ISPs will not advertise a prefix longer than /24, so host prefixes (/32) cannot be advertised on the Internet. The networks containing the host addresses are what is advertised.
    – Ron Maupin
    Commented Sep 19, 2017 at 16:47
  • Old thread, I know, but the people above are talking past each other to some extent. Google advertises from multiple locations. Of course, in reality, these are different networks with different computers on them, but on a protocol level, there is no way to tell them apart, so routers send packages towards the nearest "", without having to know that others exist. From the perspective of IP and BGP (and other protocols), is only one network.
    – elaforma
    Commented Oct 23, 2022 at 20:36

Each router has it's own routing table. The routing tables are built by the routers based on exchanging routing information with other routers and by policies set up by the owners of the routers.

The exact policies will vary between ISPs but as a general rule a shorter AS path will be preffered over a longer AS path and if the AS paths are the same length a closer exit will be preffered over a more distant exit.

Google interconnect with other networks at many locations around the world. At each of these locations they advertise address block. The routing rules work out such that traffic to the block is usually delivered to google's network at a location close to the sender.

Once inside google's network google can then route the traffic to a nearby cluster of DNS servers.


Anycast works by announcing an subnet (most /24 as this is the smallest accepted size) from all location Anycast comes from.

the easiest explaination come from: https://downloads.isc.org/isc/pubs/tn/isc-tn-2003-1.txt which is F-root(ISC, the guy behind bind9) anycast architecture.

or read the wikipedia article about anycast.

  • "Anycast is a network addressing and routing methodology in which a single destination address has multiple routing paths to two or more endpoint destinations. Routers will select the desired path on the basis of number of hops, distance, lowest cost, latency measurements or based on the least congested route." wikipedia
    – Max N
    Commented Jan 19, 2021 at 2:03
  • Anycast is mostly used for DNS, some even run TCP over it(the usage is limited, because every route change will terminate missrouted connections)
    – Max N
    Commented Jan 19, 2021 at 2:07
  • Server doesn't know about the connection and send a RST back to the client.
    – Max N
    Commented Jan 19, 2021 at 2:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.