2

Background and goal

Am setting up high availability DNS servers based on Unbound. Both DNS servers has in reality twelve BGP sessions against different routers but to make this easier only one router is showed below.

Both DNS servers are configured with the same two addresses on localhost (10.100.0.1, 10.100.0.2) and they both advertise these addresses with BGP. Problem is that if the DNS server that is preferred by other routers hangs, there is a timeout before BGP switches over to the second DNS server for both addresses. My goal is to have each DNS server have a primary responsibility for one of these two addresses so DNS clients do not have to wait for BGP timeout but instead handle failover as they know best. I do not want to add configurations to other routers, only on the DNS servers.

                    +------------+
                    |            |
                +---+  Router 1  +---+
                |   |            |   |
                |   +------------+   |
                |                    |
          +-----+----+          +----+-----+
          |          |          |          |
          |  DNS 1   |          |  DNS 2   |
          |          |          |          |
          +----------+          +----------+

(primary) 10.100.0.1          10.100.0.1
          10.100.0.2          10.100.0.2 (primary)

Problem and question

In the configuration below, how can I make DNS 1 announce 10.100.0.1 with a higher local preference so other routers choose this server instead of DNS 2 that is also announcing this IP but with lower priority?

router bgp 65002
    bgp router-id 10.0.0.1
    bgp confederation identifier 42xxx
    bgp confederation peers 65001 65002

    network 10.100.0.1/32
    network 10.100.0.2/32

    neighbor 10.0.0.10 remote-as 65001
    neighbor 10.0.0.10 route-map only-local-ASes out
!
ip as-path access-list only-local-ASes permit ^$
!
route-map only-local-ASes permit 10
match as-path only-local-ASes

Should I create a route-map that adds local preference 200 for only matched prefix 10.100.0.1? Problem am having is that this makes the router only announce 10.100.0.1 prefix and not both (also 10.100.0.2) at the same time with different preference.

Software

Linux kernel 4.4.0
Ubuntu 16.04 server
Quagga 0.99.24.1

2 Answers 2

1

What you have described is not the way anycast works. For anycast, you have all the DNS servers configured with the same address (usually on the loopback interface), they then participate in the routing protocols and advertise that address from each DNS server. Then the router hears the advertisement from each running server (and, of course, not from any dead ones providing robustness) and is configured to do round-robin on equal cost routes. Since DNS uses UDP (at least preferably) and is idempotent, this spreading out of the requests (and ultimately the load) does not impact the service.

As an additional fine tuning, you should have rules in the router for DNS over TCP where all packets in a connection need to go to the same server. There are a number of ways to achieve this, one I have seen used is to have another server with that common address configured, but which does not advertise it into the routing and you send all TCP to that one (so it ends up getting all AXFR requests, for example).

Much more elaborate setups are also possible. I've done some fairly complex ones...

4
  • Thanks for taking your time to answer my question. I realize based on your answer that I forget some important information. All my DNS servers are configured with the same two addresses (on localhost) and they both advertise these addresses by BGP making it anycast. Problem is that if the DNS server that is preferred by other routers hangs, there is a timeout before BGP switches over to the second DNS server for both addresses. Commented Jul 1, 2016 at 6:31
  • My goal is to have each DNS server have a primary responsibility for one of these two addresses so DNS clients do not have to wait for BGP timeout but instead handle failover as they know best. So why anycast at all? Well, my customers seems to forget using two nameservers in setups so when for example maintenance is ongoing on one DNS server, customers is complaining that Internet is not working. Commented Jul 1, 2016 at 6:31
  • I have edited my question and explaining more about my goal. Commented Jul 1, 2016 at 6:40
  • OK, the routing I'm talking about in my description of anycast would be an IGP (e.g. OSPF) which has a very fast convergence, there is no need for an EGP at that point. The routers that the DNS servers are talking to would, probably be talking an EGP (e.g. BGP) or otherwise passing the route on.
    – MAP
    Commented Jul 2, 2016 at 6:15
1

The solution is to have one route-map directly on the BGP network route. This is not documented in Quagga docs (July 2016) but works.

network 10.100.0.1/32 route-map localpref150

Complete configuration becomes

router bgp 65002
    bgp router-id 10.0.0.1
    bgp confederation identifier 42xxx
    bgp confederation peers 65001 65002

    network 10.100.0.1/32 route-map localpref150
    network 10.100.0.2/32

    neighbor 10.0.0.10 remote-as 65001
    neighbor 10.0.0.10 route-map only-local-ASes out
!
ip as-path access-list only-local-ASes permit ^$
!
route-map only-local-ASes permit 10
match as-path only-local-ASes
!
route-map localpref150 permit 10
set local-preference 150
!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.