Tag Archives: dns

Check DNS with DIG command

General Query

dig @ns2.dnsserver.com TXT domain.com +short   

With the +short it will show only the value of the queried field(s). Without +short  it will show the full result

 

Querying CNAME records 

dig @ns2.dnsserver.com CNAME 4xugchxxxxxxxxxxxxxxxxxx3eread3uc._domainkey.domain.com +short

This will return the value of that particular CNAME field.

 

Querying particular entry

dig @ns2.dnsserver.com TXT domain.com +short
dig @ns2.dnsserver.com NS domain.com +short

 

Bind server not responding to external queries

Recently I ran into a problem where one DNS server setup using Bind9 was not responding to external queries.

systemctl status bind9 –no-pager –full  shows “Denied

Common issues (listed below) that can cause the problem were not there.

  1. Bind9 was running properly
  2. The server was listening on both IPv4 and IPv6
  3. Port 53 was open
  4. The DNS server or port 53 could be connected using Telnet

 

The issue was with “recursive query” permissions. To allow external queries needed to add the following option

options {
   ...
   ...
     allow-recursion { any; };
   ...
   ...
}

The options are commonly stored in /etc/bind/named.conf.options for Bind9 servers.

Manually adding a DNS Zone to Bind9 server

  • Create a Zone file in /etc/bind/  Example – /etc/bind/pri.domain.com
  • Add the entries . Example below
    $TTL 3600
    @ IN SOA ns2.dnserver.net. manish.gmail.com. (
    2019051606 ; serial, todays date + todays serial #
    7200 ; refresh, seconds
    540 ; retry, seconds
    604800 ; expire, seconds
    3600 ) ; minimum, seconds
    ;
    
    domain.com. 3600 A xxx.xxx.xxx.xxx
    mail 3600 A xxx.xxx.xxx.xxx
    www 3600 A xxx.xxx.xxx.xxx
    domain.com. 3600 AAAA xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx
    mail 3600 AAAA xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx
    www 3600 AAAA xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx
    domain.com. 3600 MX 10 mail.domain.net.
    domain.com. 3600 NS ns1.dnserver.net.
    domain.com. 3600 NS ns2.dnserver.net.
    domain.com. 3600 TXT "v=spf1 mx a ~all"
    default._domainkey.domain.com. 3600 TXT "v=DKIM1; t=s; p=......NBgkqhki................................................"
    _dmarc.domain.com. 3600 TXT "v=DMARC1; p=quarantine"
  • Add the zone to /etc/bind/named.conf.local . Example below

    zone "domain.com" {
        type master;
        allow-transfer {none;};
        file "/etc/bind/pri.domain.com";
    };
  • service bind9 restart for Ubuntu and likes. For CentOS and likes service named restart

Check CNAME or TXT records

If the CNAME or TXT records are not displayed with normally available online tools, then they can be found using

dig TXT _axxxxxxxs.kolkataonweb.com +short
OR
dig CNAME 4xxxxxxxxxxxxxxxxxc._domainkey.kolkataonweb.com +short

(mention the keys that you want to lookup)

If everything is fine then the answer section will return the record (like below)

;; ANSWER SECTION:
xxxxxxxxxxxx 3584 IN CNAME xxxxxxxxxxxxxxxxxx

The +short can be omitted or +all can be used or nothing can be given