How to find a website’s DNS (name server) address

last updated in Categories , , ,

How can I find a website’s DNS address? How do I check the current DNS servers of a domain or website using a Linux or macOS command line option? How do I find DNS address of a website using bash?

DNS stands for “Domain Name System“. The DNS is a naming system for computers, servers and other network devices over the Internet. DNS is created for us to translate human-friendly computer names into IP addresses. This page shows how to use Linux, *BSD, macOS, and Unix command dig or host to find DNS addresses and names.

How to find a website’s DNS address

To check the current nameservers (DNS) for any domain name from a Linux or Unix/macOS command line:

  1. Open the Terminal application
  2. Type host -t ns domain-name-com-here to print the current DNS servers of a domain.
  3. Another options is to run dig ns your-domain-name command.
  4. To find the delegation path from the root name servers, try: dig +trace your-domain-name
  5. Above Linux or Unix, commands will show you detailed information about the domain name, including its nameserver (DNS).

Let us see all commands and examples in details.

Check the current DNS servers of a domain

Do you need to find the DNS address of a website called cyberciti.biz from the command line? Simply type the following dig command:
dig ns website-domain
dig ns google.com
dig ns cyberciti.biz

Linux Unix find a website's DNS (name server) address
The default is to print the answer in a verbose format. However, one can get a terse answer by passing the +short as follows:
dig +short ns cyberciti.biz
Sample outputs:

fay.ns.cloudflare.com.
clay.ns.cloudflare.com.

One can use the same commands to print actual IP address of name servers:
dig +short a fay.ns.cloudflare.com.
173.245.58.115
dig +short aaaa fay.ns.cloudflare.com.
2400:cb00:2049:1::adf5:3a73

How to look for the delegation path from the root DNS/name servers

Tracing is disabled by default. When tracing is enabled, dig makes iterative queries to resolve the name being looked up. It will follow referrals from the root servers, showing the answer from each server that was used to resolve the lookup. If @server is also specified, it affects only the initial query for the root zone name servers. For example:
dig +trace cyberciti.biz
dig +trace cyberciti.biz @8.8.8.8

Sample outputs:

; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> +trace cyberciti.biz @8.8.8.8
;; global options: +cmd
.			7313	IN	NS	a.root-servers.net.
.			7313	IN	NS	b.root-servers.net.
.			7313	IN	NS	c.root-servers.net.
.			7313	IN	NS	d.root-servers.net.
.			7313	IN	NS	e.root-servers.net.
.			7313	IN	NS	f.root-servers.net.
.			7313	IN	NS	g.root-servers.net.
.			7313	IN	NS	h.root-servers.net.
.			7313	IN	NS	i.root-servers.net.
.			7313	IN	NS	j.root-servers.net.
.			7313	IN	NS	k.root-servers.net.
.			7313	IN	NS	l.root-servers.net.
.			7313	IN	NS	m.root-servers.net.
.			7313	IN	RRSIG	NS 8 0 518400 20191115050000 20191102040000 22545 . Z14B+vD/MKz0X1UBwu04kzwQNajhg1AflK7j5Jvd9NZac1HZ/M9xdSGN F85s/5ITxEiWWeiBhRghy9PkdOmN3ZzhzS5E8ZeIibm0DdIse+qlPNas sfmNZEsIRbXEOER98eQ+Ieb0hjOlu7Y5l6Mo3dnuyE203IxXZTmtD9QH zMRbX8gOrBnee1XYe7kxw+S2AN6BBeRHNFPHuT5nBCwWQlDVFao2ICrV 0oU97YJE7fwDNzyBgb89G++GjVKhQoM/0Bmr4D2vUAqCz7Nt9Gb28TOt A+FpA6Ax9MpjZSCH8dOvz1nytjWfRMYyF5LVGEN6oPW6BKX2fWrfhIC4 TWIfWA==
;; Received 525 bytes from 8.8.8.8#53(8.8.8.8) in 7 ms
 
biz.			172800	IN	NS	a.gtld.biz.
biz.			172800	IN	NS	b.gtld.biz.
biz.			172800	IN	NS	c.gtld.biz.
biz.			172800	IN	NS	e.gtld.biz.
biz.			172800	IN	NS	f.gtld.biz.
biz.			172800	IN	NS	k.gtld.biz.
biz.			86400	IN	DS	12385 8 2 AE03B95863B999FC84B725DF5C903511FF96D53825F0454CE6880987 E96F5D20
biz.			86400	IN	DS	12385 8 1 E917523077754FB03308402D76144EAF0D4F6778
biz.			86400	IN	DS	28450 8 1 D9C2F912C657E4005CF0C13BA55C5AAA291AEF56
biz.			86400	IN	DS	28450 8 2 403F234609C56B3A221BC4CFB694948AB5DDF4A26AE17439BF1279CF C5CF21AB
biz.			86400	IN	RRSIG	DS 8 1 86400 20191116050000 20191103040000 22545 . i3J7qFB7/r4bUrZgZg8OcjcfguFXlSWJbgSzWJyFb+04qKWOFks4HwI9 uYKbr35anabpF2DfHlwKurmO/0HN/7uRC5da5VPMild2gUiJmXKjcN73 Gx/8F3zo3fVAjNxi+/JWicUgpCAY4iKfDq21YNV1CZopAn7QPw3+OUoo Haewp4MEF0T+omyMirn1RxBbK6+P2FNFxgGysJsUUNt1yz7Ax2tR/otY DllMPu6sLhY8MvThBVXmZCrpVTXmd/+VUlim8m/BUz/E7fumnrrraFam Khf3skCrfuLlHgemOz/pugUx8qnJ3BtsQKQzsL2cAY34I3g0kA7ckC6c moAEFA==
;; Received 778 bytes from 193.0.14.129#53(k.root-servers.net) in 191 ms
 
cyberciti.biz.		7200	IN	NS	clay.ns.cloudflare.com.
cyberciti.biz.		7200	IN	NS	fay.ns.cloudflare.com.
9ivsa0gimv18nm4si1tkf2r78navcdut.biz. 86400 IN NSEC3 1 1 1 E3C15F5F 9J0FSB5H124LGRSLHHGR0RDCP0RTEF1N NS SOA RRSIG DNSKEY NSEC3PARAM
9ivsa0gimv18nm4si1tkf2r78navcdut.biz. 86400 IN RRSIG NSEC3 8 2 86400 20191203045447 20191103042210 24963 biz. wkpoTyfFje28GBCJSTzgpV3Cr0Kbknw0n+WTv8/CpXUxG5CiKAfb2qmA KRClCT5oBelSA0FE1GekCjiEWFStCrnW2JOsLsSNWA3QKf8oWPhtBjLq Ij1+YEBFDVC67b0Kdeg6ndM3OZVlb7q9Xvi3n1PIUHS3fbuNF1MyYqMu V10e1Zfn8elyC4fEtJ6YmUhsm4oxHKkhk1NIUG8FQNg0YQ==
91phatls11fhcqsue6s1v6pi3rvttmnn.biz. 86400 IN NSEC3 1 1 1 E3C15F5F 91U8FRHJGMNHK5TPH2253L6LFIU8HM5A NS DS RRSIG
91phatls11fhcqsue6s1v6pi3rvttmnn.biz. 86400 IN RRSIG NSEC3 8 2 86400 20191127183100 20191028181200 24963 biz. YbrRM0lxpgF4rhRe4rfDAMrRq4ifiM9MkIlPuV0XYEY9NpyUNAc19xoi MRqbyUl56YlKiIlrhZPzUedDdkObt3Zz4mXI5tz5DhNPE6t4l4tNEjzH hnagx8TeCLI19S3GBE3tFzlF5zC/1ccOrl2bkYIMBHXssLkJwEGaqX9B VTRGAS1JDOxE0bXG2iEZtWotzu3Jgv+zeXG0HnCALyLFmQ==
;; Received 653 bytes from 156.154.126.65#53(e.gtld.biz) in 30 ms
 
cyberciti.biz.		300	IN	A	104.20.186.5
cyberciti.biz.		300	IN	A	104.20.187.5
;; Received 74 bytes from 173.245.58.115#53(fay.ns.cloudflare.com) in 65 ms

Find DNS address of a website using host command

The syntax is as follows for the host command:
host -t ns domain-name-here
host -t ns google.com
host -t ns cyberciti.biz

Sample outputs:

cyberciti.biz name server fay.ns.cloudflare.com.
cyberciti.biz name server clay.ns.cloudflare.com.

Again use host to display IP address for clay.ns.cloudflare.com nameserver:
host -t a clay.ns.cloudflare.com
clay.ns.cloudflare.com has address 173.245.59.88
host -t aaaa clay.ns.cloudflare.com
clay.ns.cloudflare.com has IPv6 address 2400:cb00:2049:1::adf5:3b58

A note about Windows users

You can use the nslookup command to show information about Domain Name System (DNS) infrastructure on Windows desktop or server. Go to Start and type cmd in search field to open the command prompt. Type nslookup and hit Enter as follows:
nslookup domain-name
nslookup cyberciti.biz

Sample outputs:

Server:		127.0.0.53
Address:	127.0.0.53#53

Non-authoritative answer:
Name:	www.cyberciti.biz
Address: 104.20.187.5
Name:	www.cyberciti.biz
Address: 104.20.186.5
Name:	www.cyberciti.biz
Address: 2606:4700:10::6814:bb05
Name:	www.cyberciti.biz
Address: 2606:4700:10::6814:ba05

Of course one print ns type as follows:
nslookup
> set q=ns
> cyberciti.biz

Use Windows or Unix nslookup command for DNS

A list of DNS record types

Commonly used record typesDescriptionExamples
AHost addresshost -t a nixcraft.com
AAAAIPv6 host addresshost -t aaaa nixcraft.com
ALIASAuto resolved aliashost -t alias portal2.cyberciti.biz
CNAMECanonical name for an aliashost -t cname feeds.cyberciti.biz
MXMail eXchangehost -t mx google.com
NSName Serverhost -t ns nixcraft.com
PTRPointerhost -t ptr 216.58.200.147
SOAStart Of Authorityhost -t soa nixcraft.com
SRVLocation of servicehost -t srv server1.cyberciti.biz
TXTDescriptive texthost -t txt nixcraft.com

You can use record types with nslookup, dig and host commands as follows:
$ host -t TYPE domain-name-here
$ dig TYPE domain-name-here
$ nslookup
> set q=TYPE
> dommain-name-here

Conclusion

You learned how to use dig, nslookup, and host commands to find information that you can use to diagnose Domain Name System (DNS) infrastructure, including mx, ns, and other records for a given website or DNS address.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Start the discussion at www.nixcraft.com

Historical Comment Archive