Home‎ > ‎Server administration‎ > ‎

List DNS records, nameservers of a domain from command line

If you want to find out domains DNS records like TXT, CNAME, MX, A or nameservers for the domain, there are numerous CLI tools for this task, I will show you two built in Ubuntu.

The easiest way is to use host command with -a option.

$ host -a google.com

Trying "google.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20315
;; flags: qr rd ra; QUERY: 1, ANSWER: 18, AUTHORITY: 0, ADDITIONAL: 2

;google.com. IN ANY

google.com. 82014 IN NS ns3.google.com.
google.com. 90 IN A
google.com. 144 IN MX 40 alt3.aspmx.l.google.com.
google.com. 90 IN A
google.com. 90 IN A
google.com. 144 IN MX 30 alt2.aspmx.l.google.com.
google.com. 82014 IN NS ns1.google.com.
google.com. 144 IN MX 20 alt1.aspmx.l.google.com.
google.com. 90 IN A
google.com. 144 IN MX 10 aspmx.l.google.com.
google.com. 90 IN A
google.com. 144 IN MX 50 alt4.aspmx.l.google.com.
google.com. 1478 IN TXT "v=spf1 include:_spf.google.com ip4: ip4: ~all"
google.com. 82014 IN NS ns2.google.com.
google.com. 275 IN AAAA 2a00:1450:4008:c01::71
google.com. 31 IN SOA ns1.google.com. dns-admin.google.com. 1516687 7200 1800 1209600 300
google.com. 90 IN A
google.com. 82014 IN NS ns4.google.com.

alt3.aspmx.l.google.com. 208 IN A
alt4.aspmx.l.google.com. 208 IN A

Received 498 bytes from in 12 ms

The second option is to use nslookup command with -type parameter. Change mx to a, or txt and see for your self.

$ nslookup -type=mx google.com


Non-authoritative answer:
google.com mail exchanger = 40 alt3.aspmx.l.google.com.
google.com mail exchanger = 50 alt4.aspmx.l.google.com.
google.com mail exchanger = 30 alt2.aspmx.l.google.com.
google.com mail exchanger = 20 alt1.aspmx.l.google.com.
google.com mail exchanger = 10 aspmx.l.google.com.

Authoritative answers can be found from:
alt3.aspmx.l.google.com internet address =
alt2.aspmx.l.google.com internet address =
aspmx.l.google.com internet address =
alt4.aspmx.l.google.com internet address =
alt1.aspmx.l.google.com internet address =

A very interesting command line tool you should also check out is dig.