Skip to Content

3 Ways to check DNS server IP in Linux

DNS servers are an important part of the internet, translating domain names into IP addresses. If your DNS server is not working correctly, you may experience problems loading websites or sending and receiving email. In this blog post, we will discuss three ways to check your DNS server in Linux. We will also provide some tips for troubleshooting DNS problems. Let’s get started!

Check DNS server IP with Dig command in Linux

The best way to check your DNS server is to use the ‘dig’ command. The ‘dig’ command allows you to query DNS servers for information about domains. To use the ‘dig’ command, open a terminal and type the following: dig example.com

This will query the DNS server for information about the domain “example.com”. For example, if you want to query for A records, you would type the following: dig example.com  +short

You can replace “example.com” with any domain you want to query. From the following example, we can see that the DNS server is 64.104.76.247 .

dig howtouselinux.com
; <<>> DiG 9.10.6 <<>> howtouselinux.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 25003
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1280
;; QUESTION SECTION:
;howtouselinux.com. IN A
;; ANSWER SECTION:
howtouselinux.com. 0 IN A 162.159.137.9
howtouselinux.com. 0 IN A 162.159.138.9
;; Query time: 138 msec
;; SERVER: 64.104.76.247#53(64.104.76.247)
;; WHEN: Wed Mar 02 21:24:01 CST 2022
;; MSG SIZE rcvd: 78

Check DNS server IP with nslookup command in Linux

The second way to check your DNS server is to use the ‘nslookup’ command. ‘Nslookup’ is a tool that allows you to query DNS servers for information about domains. To use the ‘nslookup’ command, open a terminal and type the following: nslookup example.com

This will query the DNS server for information about the domain “example.com”. You can also query specific records by using the ‘querytype’ parameter. For example, if you want to query for A records, you would type the following: nslookup -query=a example.com

The dns server is 64.104.76.247 from the following example.
% nslookup -query=a howtouselinux.com
Server: 64.104.76.247
Address: 64.104.76.247#53
Non-authoritative answer:
Name: howtouselinux.com
Address: 162.159.137.9
Name: howtouselinux.com
Address: 162.159.138.9

Check DNS server IP with /etc/resolv.conf file in Linux

The third way is to check /etc/resolv.conf configuration file. It contains DNS server information we use.

cat /etc/resolv.conf
domain howtouselinux.com
nameserver 64.104.76.247
nameserver 64.104.76.248

We hope this blog post has been helpful in showing you how to check your DNS server in Linux. If you are experiencing DNS problems, be sure to try using these three commands to troubleshoot the issue. Thanks for reading!

Itgu

Tuesday 14th of February 2023

Thanks a lot for the info. It works for me.