{"id":35,"date":"2010-06-27T12:00:38","date_gmt":"2010-06-27T11:00:38","guid":{"rendered":"http:\/\/itblog.antik.sk\/?p=35"},"modified":"2013-10-22T08:23:48","modified_gmt":"2013-10-22T07:23:48","slug":"how-to-make-redundant-multihomed-anycast-ipv4ipv6-dns-cloud-using-djbdnsdbndns-and-tinydns-on-debian","status":"publish","type":"post","link":"http:\/\/itblog.antik.sk\/?p=35","title":{"rendered":"How to make redundant multihomed anycast IPv4\/IPv6 DNS cloud using djbdns\/dbndns and tinydns on Debian"},"content":{"rendered":"<p>At firs you need N+1 servers which will be parts of the cloud. On each server you need at least 2 NICs which will be connected to two different routers.<\/p>\n<p>\/\/You also need a IP range for anycast purpose, the best is to use \/23 so you have enough IP space and no problem with BGP filtering across multiple Internet exchange peerings or you can use smaller if you know how to setup it.<\/p>\n<p>From the range you need IP for the DNS service. Two for DNS recursor and two for DNS cache. For each server you need also 3 unique IPs from this range. 2 for each NIC of two NICs and one for identify loopback. .<\/p>\n<p>For example for 4 server you need together (4&#215;3)+4=16 IPs. It is also possible to use anycast range only for loopback and NIC interfaces will have IP from another range depending on the location, but the configuration will be more complicated when adding another server to cloud. \u00a0So it is better to use only one range.<\/p>\n<p>This article is using the imaginary example IP range 8.8.8.0\/24 which is google using for there anycast servers.<\/p>\n<p>On each server you need to install:<\/p>\n<ul>\n<li>quagga routing software (or any other routing daemon)<\/li>\n<li>djbdns\/dbndns and tinydns (or any other DNS daemon)<\/li>\n<li>iptables with DNAT support<\/li>\n<\/ul>\n<p># apt-get install quagga dbndns dnscache-run iptables<\/p>\n<p>In our example we use 8.8.8.0\/24 as the anycast range in which all IPs are used. We have two Cisco 7600 routers which are on two geological different sites.<\/p>\n<p><a href=\"http:\/\/itblog.antik.sk\/wp-content\/anycast5-itblog.png\"><\/a><a href=\"http:\/\/itblog.antik.sk\/wp-content\/anycast5-itblog2.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-74\" title=\"anycast5-itblog\" src=\"http:\/\/itblog.antik.sk\/wp-content\/anycast5-itblog2-1024x536.png\" alt=\"\" width=\"1024\" height=\"536\" srcset=\"http:\/\/itblog.antik.sk\/wp-content\/anycast5-itblog2-1024x536.png 1024w, http:\/\/itblog.antik.sk\/wp-content\/anycast5-itblog2-300x157.png 300w, http:\/\/itblog.antik.sk\/wp-content\/anycast5-itblog2.png 1127w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<p>Cisco 7600 crs-01 configuration needed for the anycast configuration:<\/p>\n<p>interface GigabitEthernet1\/9<br \/>\ndescription ### ENI_R | ANTI_IT_0030 | xxx | eth1-dns21 ###<br \/>\nip address 8.8.8.129 255.255.255.252<br \/>\nno ip redirects<br \/>\nno ip unreachables<br \/>\nno ip proxy-arp<br \/>\nip ospf authentication message-digest<br \/>\nip ospf message-digest-key 1 md5 7 0968415C<br \/>\nip ospf network point-to-point<br \/>\nip ospf hello-interval 1<\/p>\n<p>ip ospf dead-interval 5<\/p>\n<p>load-interval 30<br \/>\nipv6 address 2A02:131:8888:FE01::1\/64<br \/>\nipv6 enable<br \/>\nipv6 nd ra suppress<br \/>\nno ipv6 pim<br \/>\nipv6 ospf hello-interval 1<br \/>\nipv6 ospf dead-interval 5<br \/>\nipv6 ospf database-filter all out<br \/>\nipv6 ospf 16 area 8<br \/>\nno cdp enable<br \/>\nend<br \/>\ninterface GigabitEthernet1\/10<br \/>\ndescription ### ENI_R | ANTI_IT_0031 | xxx | eth1-dns22 ###<br \/>\nip address 8.8.8.133 255.255.255.252<br \/>\nno ip redirects<br \/>\nno ip unreachables<br \/>\nno ip proxy-arp<br \/>\nip ospf authentication message-digest<br \/>\nip ospf message-digest-key 1 md5 7 0968415C<br \/>\nip ospf network point-to-point<br \/>\nip ospf hello-interval 1<br \/>\nip ospf dead-interval 5<br \/>\nload-interval 30<br \/>\nipv6 address 2A02:131:8888:FE02::1\/64<br \/>\nipv6 enable<br \/>\nipv6 nd ra suppress<br \/>\nno ipv6 pim<br \/>\nipv6 ospf hello-interval 1<br \/>\nipv6 ospf dead-interval 5<br \/>\nipv6 ospf database-filter all out<br \/>\nipv6 ospf 16 area 8<br \/>\nno cdp enable<br \/>\nend<br \/>\ninterface GigabitEthernet1\/11<br \/>\ndescription ### ENI_R | ANTI_IT_0032 | xxx | eth1-dns11 ###<br \/>\nip address 8.8.8.137 255.255.255.252<br \/>\nno ip redirects<br \/>\nno ip unreachables<br \/>\nno ip proxy-arp<br \/>\nip ospf authentication message-digest<br \/>\nip ospf message-digest-key 1 md5 7 0968415C<br \/>\nip ospf network point-to-point<br \/>\nip ospf hello-interval 1<br \/>\nip ospf dead-interval 5<br \/>\nload-interval 30<br \/>\nipv6 address 2A02:131:8888:FE03::1\/64<br \/>\nipv6 enable<br \/>\nipv6 nd ra suppress<br \/>\nno ipv6 pim<br \/>\nipv6 ospf hello-interval 1<br \/>\nipv6 ospf dead-interval 5<br \/>\nipv6 ospf database-filter all out<br \/>\nipv6 ospf 16 area 8<br \/>\nno cdp enable<br \/>\nend<\/p>\n<p>interface GigabitEthernet1\/12<br \/>\ndescription ### ENI_R | ANTI_IT_0033 | xxx | eth1-dns12 ###<br \/>\nip address 8.8.8.141 255.255.255.252<br \/>\nno ip redirects<br \/>\nno ip unreachables<br \/>\nno ip proxy-arp<br \/>\nip ospf authentication message-digest<br \/>\nip ospf message-digest-key 1 md5 7 0968415C<br \/>\nip ospf network point-to-point<br \/>\nip ospf hello-interval 1<br \/>\nip ospf dead-interval 5<br \/>\nload-interval 30<br \/>\nipv6 address 2A02:131:8888:FE04::1\/64<br \/>\nipv6 enable<br \/>\nipv6 nd ra suppress<br \/>\nno ipv6 pim<br \/>\nipv6 ospf hello-interval 1<br \/>\nipv6 ospf dead-interval 5<br \/>\nipv6 ospf database-filter all out<br \/>\nipv6 ospf 16 area 8<br \/>\nno cdp enable<br \/>\nendrouter ospf 10<br \/>\nrouter-id 1.2.3.4<br \/>\nispf<br \/>\nlog-adjacency-changes detail<br \/>\nauto-cost reference-bandwidth 100000<br \/>\narea 8 authentication message-digest<br \/>\narea 8 stub no-summary<br \/>\ntimers throttle spf 10 100 5000<br \/>\ntimers throttle lsa 10 100 5000<br \/>\nredistribute connected subnets<br \/>\nredistribute static subnets<br \/>\npassive-interface default<br \/>\nno passive-interface GigabitEthernet1\/9<br \/>\nno passive-interface GigabitEthernet1\/10<br \/>\nno passive-interface GigabitEthernet1\/11<br \/>\nno passive-interface GigabitEthernet1\/12<br \/>\nnetwork 8.8.8.129 0.0.0.0 area 8<br \/>\nnetwork 8.8.8.133 0.0.0.0 area 8<br \/>\nnetwork 8.8.8.137 0.0.0.0 area 8<br \/>\nnetwork 8.8.8.141 0.0.0.0 area 8<br \/>\ndistribute-list prefix OSPF_DENY out<br \/>\nbfd all-interfaces<br \/>\n!<\/p>\n<p>ip prefix-list OSPF_DENY seq 10 permit 0.0.0.0\/0 le 32<\/p>\n<p>ipv6 router ospf 16<br \/>\nrouter-id 8.8.8.1<br \/>\nlog-adjacency-changes detail<br \/>\nauto-cost reference-bandwidth 100000<br \/>\npassive-interface default<br \/>\nno passive-interface GigabitEthernet1\/9<br \/>\nno passive-interface GigabitEthernet1\/10<br \/>\nno passive-interface GigabitEthernet1\/11<br \/>\nno passive-interface GigabitEthernet1\/12<\/p>\n<p>For the crs-02 router the configuration is almost the same but the ip addresses of interfaces are changed according to the server configuration.<\/p>\n<p>Configuration needed on server dns21:<\/p>\n<p>cat \/etc\/network\/interfaces<br \/>\n# This file describes the network interfaces available on your system<br \/>\n# and how to activate them. For more information, see interfaces(5).<\/p>\n<p># The loopback network interface<br \/>\nauto lo<br \/>\niface lo inet loopback<\/p>\n<p># The primary network interface<br \/>\nauto eth0<br \/>\niface eth0 inet static<br \/>\naddress 8.8.8.194<br \/>\nnetmask 255.255.255.252<\/p>\n<p>iface eth0 inet6 static<\/p>\n<p>address 2a02:131:8888:fd01::194<br \/>\nnetmask 64<br \/>\ngateway 2a02:131:8888:fd01::1<\/p>\n<p>auto eth1<br \/>\niface eth1 inet static<br \/>\naddress 8.8.8.130<br \/>\nnetmask 255.255.255.252<\/p>\n<p>iface eth1 inet6 static<br \/>\naddress 2a02:131:8888:fe01::130<br \/>\nnetmask 64<br \/>\ngateway 2a02:131:8888:fe01::1<\/p>\n<p>auto lo:7<br \/>\niface lo:7 inet static<br \/>\naddress 8.8.8.7<br \/>\nnetmask 255.255.255.255<br \/>\nup ip -6 addr add 2a02:131:1:8888::7\/128 dev lo:7<\/p>\n<p>auto lo:77<br \/>\niface lo:77 inet static<br \/>\naddress 8.8.8.77<br \/>\nnetmask 255.255.255.255<br \/>\nup ip -6 addr add 2a02:131:1:8888::77\/128 dev lo:77<\/p>\n<p>auto lo:8<br \/>\niface lo:8 inet static<br \/>\naddress 8.8.8.8<br \/>\nnetmask 255.255.255.255<br \/>\nup ip -6 addr add 2a02:131:1:8888::8\/128 dev lo:8<\/p>\n<p>auto lo:88<br \/>\niface lo:88 inet static<br \/>\naddress 8.8.8.88<br \/>\nnetmask 255.255.255.255<br \/>\nup ip -6 addr add 2a02:131:1:8888::88\/128 dev lo:88<\/p>\n<p>auto lo:100<br \/>\niface lo:100 inet static<br \/>\naddress 8.8.8.21<br \/>\nnetmask 255.255.255.255<br \/>\nup ip -6 addr add 2a02:131:1:8888::21\/128 dev lo:100<\/p>\n<p>dns-cache21:~# iptables-save<\/p>\n<p># Generated by iptables-save v1.4.2 on Fri Jun 25 11:10:33 2010<\/p>\n<p>*filter<\/p>\n<p>:INPUT ACCEPT [685482823:68925443107]<\/p>\n<p>:FORWARD ACCEPT [22:1681]<\/p>\n<p>:OUTPUT ACCEPT [734294686:70957724473]<\/p>\n<p>COMMIT<\/p>\n<p># Completed on Fri Jun 25 11:10:33 2010<\/p>\n<p># Generated by iptables-save v1.4.2 on Fri Jun 25 11:10:33 2010<\/p>\n<p>*nat<\/p>\n<p>:PREROUTING ACCEPT [24359827:1724945664]<\/p>\n<p>:POSTROUTING ACCEPT [294052022:18879912475]<\/p>\n<p>:OUTPUT ACCEPT [294052012:18879911514]<\/p>\n<p>-A PREROUTING -d 8.8.8.8\/32 -i eth1 -p tcp -m tcp &#8211;dport 53 -j DNAT &#8211;to-destination 88.212.8.130:53<\/p>\n<p>-A PREROUTING -d 8.8.8.8\/32 -i eth1 -p udp -m udp &#8211;dport 53 -j DNAT &#8211;to-destination 88.212.8.130:53<\/p>\n<p>-A PREROUTING -d 8.8.8.8\/32 -i eth0 -p tcp -m tcp &#8211;dport 53 -j DNAT &#8211;to-destination 88.212.8.194:53<\/p>\n<p>-A PREROUTING -d 8.8.8.8\/32 -i eth0 -p udp -m udp &#8211;dport 53 -j DNAT &#8211;to-destination 88.212.8.194:53<\/p>\n<p>-A PREROUTING -d 8.8.8.88\/32 -i eth1 -p tcp -m tcp &#8211;dport 53 -j DNAT &#8211;to-destination 88.212.8.130:53<\/p>\n<p>-A PREROUTING -d 8.8.8.88\/32 -i eth1 -p udp -m udp &#8211;dport 53 -j DNAT &#8211;to-destination 88.212.8.130:53<\/p>\n<p>-A PREROUTING -d 8.8.8.88\/32 -i eth0 -p tcp -m tcp &#8211;dport 53 -j DNAT &#8211;to-destination 88.212.8.194:53<\/p>\n<p>-A PREROUTING -d 8.8.8.88\/32 -i eth0 -p udp -m udp &#8211;dport 53 -j DNAT &#8211;to-destination 88.212.8.194:53<\/p>\n<p>COMMIT<\/p>\n<p>The DNAT si needed for translating anycast request from cleint to defined recursor based on source interface\u00a0 and destination IP, because djbdns can`t listen on one IP addres and make recursive request from another IP. If you will use BIND for recursor\u00a0 you can do it without this iptables trick and only with one DNS server insteat of two.<\/p>\n<p>On each server are running two IPv4 dns recursor dnscache.<br \/>\ndns-cache21:\/etc\/sv# cat dnscache\/env\/IP dnscache\/env\/IPSEND dnscache\/env\/ROOT dnscache\/env\/CACHESIZE dnscache2\/env\/IP dnscache2\/env\/IPSEND dnscache2\/env\/ROOT dnscache2\/env\/CACHESIZE<br \/>\n8.8.8.194<br \/>\n8.8.8.194<br \/>\n\/etc\/sv\/dnscache\/root<br \/>\n1572864000<br \/>\n8.8.8.130<br \/>\n8.8.8.130<br \/>\n\/etc\/sv\/dnscache2\/root<br \/>\n1572864000<\/p>\n<p>cat tinydns\/env\/IP tinydns\/env\/ROOT tinydns2\/env\/IP tinydns2\/env\/ROOT tinydns-ipv6\/env\/IP tinydns-ipv6\/env\/ROOT tinydns2-ipv6\/env\/IP tinydns2-ipv6\/env\/ROOT<br \/>\n::ffff:8.8.8.7<br \/>\n\/etc\/sv\/tinydns\/root<br \/>\n::ffff:8.8.8.77<br \/>\n\/etc\/sv\/tinydns\/root<br \/>\n2a02:131:1:8888::7<br \/>\n\/etc\/sv\/tinydns\/root<br \/>\n2a02:131:1:8888::77<br \/>\n\/etc\/sv\/tinydns\/root<\/p>\n<p>As you can see, we have 4 authoritative DNS server 2xIPv4 and 2xIPv6 but shared ROOT enviroment for easier management. There is no need for iptables, because authoritative DNS uses only one IP address which is the loopback IP address.<\/p>\n<p>The quagga configuration on server looks like this:<\/p>\n<p>dns-cache21:~# cat \/etc\/quagga\/ospfd.conf<br \/>\nhostname ospfd<br \/>\npassword secretpassword<br \/>\nlog file \/var\/log\/quagga\/ospfd.log<br \/>\nservice advanced-vty<\/p>\n<p>nterface eth0<br \/>\nip ospf authentication message-digest<br \/>\nip ospf message-digest-key 1 md5 Dn5<br \/>\nip ospf network point-to-point<br \/>\nip ospf hello-interval 1<br \/>\nip ospf dead-interval 5<br \/>\n!<br \/>\ninterface eth1<br \/>\nip ospf authentication message-digest<br \/>\nip ospf message-digest-key 1 md5 Dn5<br \/>\nip ospf network point-to-point<br \/>\nip ospf hello-interval 1<br \/>\nip ospf dead-interval 5<br \/>\n!<br \/>\nrouter ospf<br \/>\nrouter-id 8.8.8.194<br \/>\nnetwork 8.8.8.7\/32 area 8<br \/>\nnetwork 8.8.8.77\/32 area 8<br \/>\nnetwork 8.8.8.8\/32 area 8<br \/>\nnetwork 8.8.8.88\/32 area 8<br \/>\nnetwork 8.8.8.21\/32 area 8<br \/>\nnetwork 8.8.8.194\/30 area 8<br \/>\nnetwork 8.8.8.130\/30 area 8<br \/>\narea 8 stub<br \/>\narea 8 authentication message-digest<br \/>\n!<br \/>\nlog stdout<\/p>\n<p>dns-cache21:~# cat \/etc\/quagga\/ospf6d.conf<\/p>\n<p>hostname ospf6d@plant<br \/>\npassword secretpass<br \/>\nlog stdout<br \/>\nlog file \/var\/log\/quagga\/ospf6d.log<br \/>\nservice advanced-vty<br \/>\n!<br \/>\ndebug ospf6 neighbor state<br \/>\n!<br \/>\ninterface eth1<br \/>\nipv6 ospf6 hello-interval 1<br \/>\nipv6 ospf6 dead-interval 5<br \/>\n!<br \/>\ninterface eth0<br \/>\nipv6 ospf6 hello-interval 1<br \/>\nipv6 ospf6 dead-interval 5<\/p>\n<p>!<br \/>\ninterface lo<br \/>\n!<br \/>\nrouter ospf6<br \/>\nrouter-id 8.8.8.21<br \/>\ninterface eth1 area 0.0.0.8<br \/>\ninterface eth0 area 0.0.0.8<br \/>\ninterface lo area 0.0.0.8<\/p>\n<p>After that you should have working full redundant multihomed anycast DNS cloud. As next you should make some statistics about how well is your cloud working and devolep some external decentralized monitoring tool for testing your services and act proactive according to that. The dnscache and tinydns are running using sv daemon, so that manage the restarting of service going down, but you have to monitor your configuration mistakes.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>At firs you need N+1 servers which will be parts of the cloud. On each server you need at least 2 NICs which will be connected to two different routers. \/\/You also need a IP range for anycast purpose, the best is to use \/23 so you have enough IP space and no problem with [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[7,3],"tags":[],"_links":{"self":[{"href":"http:\/\/itblog.antik.sk\/index.php?rest_route=\/wp\/v2\/posts\/35"}],"collection":[{"href":"http:\/\/itblog.antik.sk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/itblog.antik.sk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/itblog.antik.sk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/itblog.antik.sk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=35"}],"version-history":[{"count":44,"href":"http:\/\/itblog.antik.sk\/index.php?rest_route=\/wp\/v2\/posts\/35\/revisions"}],"predecessor-version":[{"id":52,"href":"http:\/\/itblog.antik.sk\/index.php?rest_route=\/wp\/v2\/posts\/35\/revisions\/52"}],"wp:attachment":[{"href":"http:\/\/itblog.antik.sk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=35"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/itblog.antik.sk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=35"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/itblog.antik.sk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=35"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}