in Uncategorized

The reason: Asterisk kept querying a ultra slow (Orange) server for NAPTR records (from pjsip), making calls very slow (needed to wait at least 5 or 6 rings before the call could go on!). You would answer “but you just need to add a disable_naptr = yes in the pjsip.conf file! Well, no, I did, and Asterisk keeps making these DNS queries. Maybe Asterisk is broken (using version 20.6.0) ?

Anyway, I decided to set a local DNS server (Ubuntu Linux server) and use the really nice blocking features of CoreDNS. I didn’t find any other DNS server that could do this. Unbound has no such options, and Bind9 (obsolete anyway) has RPZ stuff, but doesn’t seem to manage queries this way.

CoreDNS installation

No deb or snap packages to install, so you’ll need to get it from https://github.com/coredns/coredns/releases/latest and use the specific info for deployment (mainly systemd installation/configuration) from https://github.com/coredns/deployment.

CoreDNS configuration

Add the configuration in the file `/etc/coredns/Corefile`:

.:53 {
    bind 127.0.0.54

    log . "{remote} {type} {name} {class} {size} {rcode} {duration}"
    reload 30s

    cache 3600

    template ANY NAPTR {
      rcode NOERROR
      authority "{{ .Zone }} 3600 {{ .Class }} SOA ns1.home.net. dnsadmin.home.net (2022122100 14400 3600 604800 30)"
    }

    forward . 1.1.1.1 8.8.8.8
}

The template here will intercept the queries of type “NAPTR”, and return NOTHING instead.