IPv6 Anycast Address
Anycast is basically the same on IPv4 and IPv6 so this part below refers to both.
As the name says it’s an address that can exist more than once anywhere in the network. If we look public IP space that’s available on the Internet, anycast IPv6 address can exist on multiple places all over the Internet. This kind of address is basically enabling us to have servers and services physically closer to us as they would be if the unicast address was used. It this way we are able to have, for example, a server with one anycast IP address somewhere in US and other server with same service and same IP address somewhere is Europe. If I am in Europe, closest server with that IP address will handle my request. Without to much additional technology solutions my service will automatically be resolved to server who is closer to me and it will probably also improve service security and speed. All that is called load balancing and can be accomplished by different networking solutions and technology designs but anycast addressing is basically the simplest method possible to enable this kind of “geo” localization for a service.
How anycast works?
As said before anycast addresses are called anycast because one address can be assigned to multiple interfaces inside the same network. Packets that are going to anycast IP destination address will be caught by nearest device. Today’s anycast IP addresses are used on some special routers and the most important thing that runs them is Global Internet’s DNS root servers service. Google also rely on anycast for all his different solutions and apps like gmail, search and so on.
If you imagine how DNS works you can see why anycast would be used on root DNS servers. You can then have one copy of the same DNS server on each continent. BGP will by himself bring your DNS query to server near you and in that way save you some delay time and bandwidth usage and thus some time.
In IPv6 world, what changes?
IPv6 had from the development phase the intention to support anycast just like described from RFC 1546. (RFC 1546 mentioned below in history section). IPv6 anycast has no special prefix and IPv6 anycast addresses are basically normal global unicast addresses. Each IPv6 configured interface on some device needs to be configured with one anycast address.
There is a big chance that anycast interfaces have no defined region, in that case every anycast entry would need to be propagated throughout the whole Internet. That would probably not scale well so support for that kind of global anycast addresses will be more or less impossible to handle.
If there are regions defined, inside the region devices with same anycast address will only need a separate entry in the routing table.
The only this that we need to know here and that can possibly be an issue is that anycast gives us no way to choose which device of more with the same anycast IP we will get our packet sent. The decision is done by the routing protocol and it is basically random router or the fastest or physically closest one. If we are sending multiple packets to an anycast address, the packets can also arrive at different destinations. If our communication is using a series of requests and replies this can be a problem. There is the thing with packets that are fragmented too. Fragments can be sent to different destinations and lost because they will not have a chance to get assembled back to real packets.
Subnet-router anycast address
The subnet-router anycast address is a special type of IPv6 anycast address that is required. That means that every router needs to support the subnet-router anycast address for all locally connected subnets on their interfaces. The important fact is that some data sent to subnet-router anycast address will be delivered to only one router of that subnet. Subnet-router anycast address is like a regular unicast address with a prefix specifying the subnet and special identifier bite range set to all zeros.
The “subnet prefix” in anycast address it identifies a particular link. To get this you can imagine a LAN segment with three routers that are having anycast address and they are all three gateways for going out to the Internet. If we have an applications which needs to communicate with any one of the routers available in order to have a closed connection state we should use subnet-router anycast address so that we are sure that all the communication pieces will go to the same router untill the specific communication is closed. In normal anycast configuration every piece can select different (from three) same anycast router interfaces.
Some more details and history stuff
We can deduce from the upper text that anycast is basically the simplest way to implement redundancy and load balancing in situations where more devices are running same services.
Anycast was actually present before the IPv6 so we cannot say that is IPv6 technology only. It’s defined before that in RFC 1546. It was years ago in 1993 and it was experimental IPv4 technology. In that specification it is intended to use special prefix for anycast so it would be recognized based on the prefix. Something like special prefix 22.214.171.124/4 for Multicast or 127.0.0.0/8 for Loopback addresses to the local host.
Anycast was intended to be good implementation of redundancy and load balancing for DNS and HTTP. Although the idea was practical and very innovative, anycast was not implemented as it was described in RC 1546. Shared unicast address way of implement redundancy and load balancing was used at the end.
This is something similar but in IPv4 it removes the requirement of any new prefix or TCP changes. It’s implemented by assigning normal unicast address on more interfaces and then creating multiple entries in the routing table. Whole network on L3 and L4 thinks that this address is globally unique.
There are some exceptions but root DNS servers across the Internet are set up with shared unicast addresses and this is working fine.