What DNS servers am I using?

  • How can I check which DNS server am I using (in Linux)? I am using network manager and a wired connection to my university's LAN. (I am trying to find out why my domain doesn't get resolved)

  • Correct answer

    9 years ago

    You should be able to get some reasonable information in:

    $ cat /etc/resolv.conf 

    However, please be aware that (on modern Linuxen) the contents of `/etc/nsswitch.conf` dictate what name services are used (DNS, LDAP, etc) and in what order. Say `fgrep hosts: /etc/nsswitch.conf`. If it only references DNS, `/etc/resolv.conf` is the right place to look for your nameservers. But chances are you're also using mDNS (aka ZeroConf, aka Avahi, aka Bonjour, etc), etc. In that case, things depend on what you're using.

    This file typically points at on Ubuntu - it's the local DNS cache server, not the actual upstream.

    @BarryKelly Check what your router uses, then

    And if you have several upstream server configured ? How to know which one is currently used ?

    I would suggest to mention that file is a link and dynamically generated for systems using resovconf (like Ubuntu). I've seen this answer millions of times and until today is that I think it is correct, because I understand now that it is actually a dynamically generated file.

    See the answers by @G32RW or @Lonniebiz for a more robust approach under various circumstances, e.g. when you get an answer like ``

    @Geremia router? I'm on office wifi and I want to verify which DNS server I'm using. Or I'm on VPN and want to verify, similarly. Usually I don't have access to the router.

    This solution is no more up to date. I find the `systemd-resolve --status` suggested by @G32RW most up-to-date solution for this problem.

License under CC-BY-SA with attribution

Content dated before 6/26/2020 9:53 AM