IP Anycast
IP Anycast
Definition
Core Concept
Key Characteristics
• Single IP, Multiple Nodes: A single anycast IP address is advertised by multiple servers, each
capable of providing the same service (e.g., DNS resolution, content delivery).
• Transparency: Clients send requests to the anycast IP unaware of which specific node
responds, simplifying application design.
• Scalability and Redundancy: Distributes load and provides failover; if one node fails, traffic
reroutes to another without manual intervention.
o A single IP address (e.g., 8.8.8.8 for Google DNS) is assigned to multiple servers in
different locations, each configured to handle requests identically.
o Example: Servers in New York, London, and Tokyo all use 8.8.8.8.
o Each server (or its associated router) advertises the anycast IP address to the
network using a routing protocol, typically BGP for internet-scale anycast or an IGP
(e.g., OSPF) within a single domain.
o Example: New York router advertises 8.8.8.8 via BGP to AS 15169 (Google).
o Packets are forwarded to the chosen node, which processes the request as if it were
the sole destination; the client receives a response from that node.
o Example: DNS query to 8.8.8.8 from Paris resolves via London server.
o Example: London server fails; BGP withdraws its route, traffic shifts to New York.
o Most common for internet-wide anycast; each node advertises the same prefix (e.g.,
8.8.8.0/24), and BGP’s best-path algorithm (e.g., shortest AS_PATH) selects the
nearest node.
o Example: Google’s 8.8.8.8 is advertised globally, with clients routed to the closest
data center.
o Used within a single AS or network; nodes advertise the anycast IP, and the IGP’s
metric (e.g., cost or hop count) determines the best route.
o Example: An enterprise uses OSPF to route to an anycast IP within its data centers.
• Static Routes: Rarely used, for small-scale anycast with manual path control.
Technical Details
• Address Type: Anycast uses standard unicast IP addresses (IPv4 or IPv6); no special address
range is reserved, unlike multicast (224.0.0.0/4).
• Prefix Advertisement: All nodes advertise the same IP prefix (e.g., 8.8.8.0/24), and routing
protocols treat each advertisement as a separate path to the same destination.
• Statefulness Limitation: Anycast is best for stateless protocols (e.g., DNS, HTTP) since
packets may route to different nodes mid-session if routing changes, breaking stateful
connections like TCP unless mitigated.
Example Scenario
• Process:
o Client in Boston queries 8.8.8.8; BGP routes to New York (shortest path).
o New York server fails; BGP withdraws its route, Boston traffic shifts to another node
(e.g., Chicago).
Diagram Descriptions
o Clients in Boston, Paris, Sydney with arrows to nearest server (e.g., Boston → New
York).
o Timeline: New York → BGP AS 15169 (8.8.8.0/24), London → BGP AS 15169, etc.
• Diagram 3: Failover:
o New York crossed out (route withdrawn), arrows shifting from Boston to Chicago
server.
Applications of IP Anycast
• DNS Services:
o Public DNS (e.g., Google 8.8.8.8, Cloudflare 1.1.1.1) uses anycast to route queries to
the nearest resolver, reducing latency and improving reliability.
o CDNs like Akamai or Cloudflare use anycast to deliver web content from the closest
edge server, optimizing load time and bandwidth.
o Traffic is spread across multiple anycast nodes, diluting attack impact (e.g.,
Cloudflare’s DDoS protection).
• Load Balancing:
o Distributes client requests across servers without complex load balancers (e.g., NTP
servers).
Advantages of IP Anycast
• Low Latency: Routes traffic to the nearest node, minimizing round-trip time (RTT) for clients.
• High Availability: Automatic failover to other nodes if one fails, enhancing redundancy
without client reconfiguration.
• Load Distribution: Naturally balances traffic across nodes based on routing proximity,
reducing server overload.
• Scalability: Adding new nodes is as simple as advertising the same IP from a new location.
• Simplified Client Access: Clients use a single IP regardless of server location, easing
configuration.
Disadvantages of IP Anycast
• Stateful Connection Issues: Mid-session routing changes (e.g., due to BGP reconvergence)
can break TCP sessions unless mitigated (e.g., by sticky routing or short-lived connections).
• Limited Control: Administrators cannot directly choose which node serves a client; routing
protocols dictate the decision.
• Convergence Delay: BGP route changes (e.g., after a failure) may take seconds to minutes,
causing temporary disruptions.
• Troubleshooting Complexity: Debugging is harder since the same IP maps to multiple nodes.
• Short TTLs: Use low Time-to-Live values in DNS or application responses to limit session
duration, reducing state issues.
• Consistent Hashing: CDNs use techniques to ensure requests from the same client hit the
same node despite anycast.
• Route Tuning: Adjust BGP attributes (e.g., LOCAL_PREF, MED) to influence path selection and
avoid suboptimal routing.
o Anycast: One IP, multiple nodes, nearest routing; Unicast: One IP, one node, specific
routing.
• BGP: Dominant for internet anycast; advertises the same prefix from multiple AS locations,
using AS_PATH and policy to determine the best route.
• OSPF/RIP: Used in intra-domain anycast; advertises the anycast IP with cost or hop count
determining proximity.
• Packet Forwarding: Ties to your earlier request—anycast enhances forwarding by
dynamically selecting the nearest destination based on routing tables.
Additional Notes
• IPv6 Support: Anycast works identically in IPv6 (e.g., 2001:4860:4860::8888 for Google DNS).
• Anycast Address: Not a reserved range; any unicast IP can be used, defined by advertisement
behavior.
• Real-World Example: Root DNS servers (e.g., F-root at 192.5.5.241) use anycast for global
reachability.