How to Find My DNS Server IP Address in Linux

DNS (Domain Name System) is a fundamental facilitator of several networking technologies such as mail servers, Internet browsing, and streaming services e.g. Netflix and Spotify, among others.

It works on a special computer called a DNS server – which keeps a database record of several public IP addresses along with their corresponding hostnames in order for it to resolve or translate hostnames to IP addresses upon user request.

Read Also: 4 Ways to Find Server Public IP Address in Linux Terminal

This happens so that we would not need to bother ourselves with remembering the IP addresses of the different websites we visit.

While there are several things we can discuss on DNS servers such as redirection and malware attack prevention, our focus today is on how to find out your very own dns server IP address.

There are several ways to check for it depending on the Operating System that you’re running but Linux, BSD, and Unix-like systems all share the same method so let’s begin with them.

How to Find My DNS Server IP Address

1. To find out your DNS Server IP address, use the following cat command or less command.

$ cat /etc/resolv.conf
$ less /etc/resolv.conf

2. Another way is to use the following grep command.

$ grep "nameserver" /etc/resolv.conf


Here, nameserver is a name server IP address in what is called the dot notation – the format that applications on your workstation use for DNS routing.

How to Find My Website DNS Server IP Address

3. To find out a website DNS Server IP address, you can use the following dig command.

$ dig
Sample Output
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.68.rc1.el6_10.1 <<>>
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 30412
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0

;			IN	A


;; Query time: 0 msec
;; WHEN: Mon Jun 24 07:25:42 2019
;; MSG SIZE  rcvd: 61

Easy right? Perhaps we’ll talk about primary and secondary DNS Server addresses next time. Till then, feel free to share and drop your comments/suggestions in the discussion section below.

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Martins D. Okoi

Martins Divine Okoi is a graduate of Computer Science with a passion for Linux and the Open Source community. He works as a Graphic Designer, Web Developer, and programmer.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

9 Responses

  1. rms-mit says:

    Many Linux users these days use a dns cache and so the dns server in resolve.conf is a loopback address to the dns cache on your own PC/Linux.

    systemd’s resolved is also often used but this updates resolve.conf for informational reference. Systemd-Resolved can have different dns servers for different networks concurrently and the resolve.conf will not reflect this but the man pages and status command are very informative.

    network manager also does some things differently. i think it sets up one of these dns caches but id don’t know much about it.

    I keep reading these “how to find my dns” how to pages but have yet to find one that covers the more modern scenarios.

  2. Adonis Tarcio says:

    You missed probably one of the easiest one: nslookup

  3. René Hartman says:

    On my Fedora 29 and RHEL 8 /etc/resolv.conf is still used for listing the nameservers.

    Same for my PureOS, Alpine, TinyCore and Atomic Host…

    My Ubuntu 16.04 LTSB and 18.04 LTSB have and respectively.

  4. Tudor says:

    @Andrew is correct, because modern OSs use a local name server cache.

    • rms-mit says:

      I think you will find this is a dns cache on your local machine. see my other comment on the root article

  5. Tudor says:

    Except that all the modern Desktop Linux distros stopped listing nameservers in /etc/resolve.conf many years ago! If you look in that file now, all you get is, because most now have a local caching nameserver.

  6. Andrew says:

    /etc/resolv.conf says my nameserver is That can’t be right.

  7. René Hartman says:

    How to find your own external IP address?

    $ dig +short

    This works fine on CentOS and RHEL but not on Ubuntu. Looks like Ubuntu’s dig command has less capabilities.

  8. Daniel M Tripp says:

    That’s almost completely wrong and complete deprecated on almost every recent Ubuntu or Debian version I’ve used ! Contents of resolv.conf on my Raspberry Pi running Raspbian Stretch :

    # Generated by resolvconf
    domain LOCAL

    looking at the contents /etc/resolv.conf may have been true 10+ years ago – on a UNIX system like Solaris…

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.