Querying DNS records for a domain

Posted:  May 14th, 2016

 

To query DNS servers, you can use the "host" command or "dig" command.

 

For example, if you want to get the IP address for your domain, use one of the two following commands:

 

    host domain.com

    dig domain.com

 

To get the MX records, use any of the following commands:

 

    host -t mx domain.com

    dig mx domain.com

 

To get the nameservers records for your domain, use any of the following commands:

 

    host -t ns domain.com

    dig ns domain.com

 

To query a DNS record on a specific server (to check if the DNS zone is properly configured, for example):

 

    dig domain.com @DNS_server

 

"DNS_Server" can be replaced by an A entry or an IP address.

 

For example, to query the DNS zone of domain.com on the google public DNS server, we would use the following command:

 

    dig domain.com @8.8.8.8