Friday, January 14, 2011

Anycast DNS setup using Linux and Cisco routers.

Cisco Router Configuration:

ip sla 101
dns name-server
frequency 30
ip sla schedule 101 life forever start-time now
track 101 ip sla 101
ip route track 101

Here is the IP route on the router:

router# show ip route
Routing entry for
Known via "static", distance 1, metric 0
Redistributing via eigrp 1234
Advertised by eigrp 1234 route-map STATIC-TO-EIGRP
bgp 1234
Routing Descriptor Blocks:
Route metric is 0, traffic share count is 1

Then you can see that this same address is also available from multiple locations:

router# show ip eigrp topology
EIGRP-IPv4 Topology Entry for AS(1234)/ID( for
State is Passive, Query origin flag is 1, 1 Successor(s), FD is 2562560
Descriptor Blocks:, from Rstatic, Send flag is 0x0
... (Vlan20), from, Send flag is 0x0
... (Vlan30), from, Send flag is 0x0

On the Unix server I have the following network interfaces setup:

eth0 Link encap:Ethernet HWaddr 00:15:17:A6:25:97
inet addr: Bcast: Mask:

lo:1 Link encap:Local Loopback
inet addr: Mask:

To summarize the whole setup.

1) The router does a DNS query to the DNS server that is directly connected to it every 30 seconds.
2) If the DNS query succeeds the static router stays in the table.
3) If the test fails the route is withdrawn.

1) If a DNS query is sent to the router will process this by sending the query to the IP address the static route points to.
2) The DNS server accepts the query on the management interface, then passes it to the lo:1 interface for processing.

Depending on where you are at you automatically get routed to the closest server:

jemurray@pluto:~$ traceroute
traceroute to (, 30 hops max, 60 byte packets
1 ( 0.309 ms 0.338 ms 0.381 ms
2 ( 0.202 ms 0.195 ms 0.180 ms

jemurray@paddington:~$ sudo traceroute
traceroute to (, 64 hops max, 52 byte packets
1 ( 0 ms 0 ms 0 ms
2 ( 0 ms 0 ms 0 ms

The best thing about this setup is:

1) If a server fails you automatically fail over to the next closest server. This way the client does not have to deal with DNS times outs.
2) Depending on your location you are automatically routed to the closest server. This will help with DNS response time.
3) It is not that hard to setup.
4) Nothing special is needed either the router or the server.


  1. This is really cool, but i wonder if it would make things a little bit more obvious if you could number your eth0 address like 192.168.x.x, so it is more easily seen where the real server address is and the virtual address is.

    it's an example after all


  2. Is there a particular reason you used the loopback interface for the anycast IP as opposed to a subinterface like eth0:0?

  3. If you multi-home your server, you want your most stable interface to be the anycast interface. This way if you have a single network uplink fail your anycast interface will stay up. It also keeps the routing table more stable.

  4. These types of routers have superior capabilities than the customary wireless network router. Although typically more costly than other routers, it is considered a healthy investment to purchase such type.attuatori pneumatici

  5. In the wake of perusing this, only one things to state. Out of this world.
    Mike Wallace

  6. I haven’t any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us. best wireless router

  7. Awesome article, it was exceptionally helpful! I simply began in this and I'm becoming more acquainted with it better! Cheers, keep doing awesome! product reviews

  8. Very useful info. Hope to see more posts soon!. chicago med season 5