If public IPs are pinned to a single AS, how does BGP anycast work

anycastbgpnetwork-securitynetworking

It is my understanding that public IP blocks are assigned from IANA, which assigns sub-blocks to RIRs, which assigns sub-blocks to ISPs, which assigns sub-blocks to individual ASs as outlined in this question: How are IP addresses actually assigned?

This (and resources like this page) seems to imply a mapping of 1 public IP to 1 AS.

However, anycast seems to work by advertising the same public ip address from multiple locations, providing different paths to that IP. For example:

If public ips are supposed to resolve to a single AS, how does anycast work?

Best Answer

There is no requirement that IP addresses or Internet routes for a prefix come from a single AS. ASNs are assigned to organizations, and addresses are also assigned to organizations. Registrars like ARIN don't link my address allocation to my ASN allocation. Even in new systems like Resource Public Key Infrastructure it still allows for multiple ASs to originate a route to a network. The Team Cymru page says this in the FAQs:

In some cases a network prefix will be announced by multiple, but disparate, networks or autonomous systems. The most likely reason for this is something known as "multihoming". This is perfectly normal. Depending on your view of the Internet topology and the originating network's policies, one of those originating networks will be the preferred path for sending and receiving traffic with the netblock in question.

Here's a (long) list of networks that are currently advertised from multiple ASs.

As to how it gets to where it's going: Routes are selected using a BGP path selection algorithm that chooses a path based on the information each router the traffic passes through knows about. Each router on the Internet has it's own view of the routing table, so traffic in one part of the Internet can end up in a different place and AS than traffic in another part of the Internet. There's not even a requirement to have every packet in a flow go to the same place, which can obviously make things interesting in the case of anycasting or multihoming.