How to Find DNS Server on Linux
Finding the DNS server on your Linux system is easier than you might think. Whether you’re troubleshooting network issues or configuring your system, knowing how to locate your DNS server is essential. In this guide, I’ll walk you through several straightforward methods to find your DNS server on Linux.
You don’t need to be a network expert to follow along. I’ll explain each step clearly and provide examples to make it simple. By the end, you’ll know exactly where to look and how to interpret the information you find.
What Is a DNS Server and Why It Matters on Linux
A DNS (Domain Name System) server translates website names into IP addresses. When you type a URL like www.example.com, the DNS server tells your computer the IP address to connect to. Without it, your system wouldn’t know where to go on the internet.
On Linux, the DNS server settings control how your system resolves domain names. Sometimes, you need to check these settings to:
- Fix internet connection problems
- Configure custom DNS servers for privacy or speed
- Understand your network setup
Knowing how to find your DNS server helps you manage your Linux system better.
Checking DNS Server Using the /etc/resolv.conf File
The simplest way to find your DNS server on Linux is by looking at the /etc/resolv.conf file. This file usually contains the DNS server addresses your system is using.
To check it, open a terminal and type:
cat /etc/resolv.conf
You’ll see lines like:
nameserver 8.8.8.8
nameserver 8.8.4.4
These IP addresses are your DNS servers. In this example, Google’s public DNS servers are used.
Important Notes About /etc/resolv.conf
- Some Linux distributions use systemd-resolved or NetworkManager, which can overwrite this file.
- If you see a line like
nameserver 127.0.0.53, it means your system uses a local DNS stub resolver. - In such cases, you’ll need to check other tools to find the actual DNS servers.
Using systemd-resolved to Find DNS Servers
Many modern Linux systems use systemd-resolved to manage DNS. To check DNS servers with this service, run:
systemd-resolve --status
Look for the “DNS Servers” section under your network interface. It will list the IP addresses of your DNS servers.
For example:
Link 2 (eth0)
Current Scopes: DNS
DNS Servers: 192.168.1.1
8.8.8.8
This shows your system is using a local router DNS and Google DNS.
How to Query systemd-resolved Directly
You can also use:
resolvectl status
This command provides similar information in a user-friendly format.
Finding DNS Servers with NetworkManager
If your Linux system uses NetworkManager, you can find DNS information using the nmcli tool.
Run:
nmcli device show
Look for the IP4.DNS entries under your active network device. For example:
IP4.DNS[1]: 192.168.0.1
IP4.DNS[2]: 1.1.1.1
This means your DNS servers are your router and Cloudflare DNS.
Alternatively, use:
nmcli device show eth0 | grep IP4.DNS
Replace eth0 with your network interface name.
Using the dig Command to Identify DNS Server
The dig command is a powerful DNS lookup tool. You can use it to find which DNS server your system queries by default.
Run:
dig google.com
At the end of the output, look for the “SERVER” line. It shows the IP address of the DNS server used for the query.
Example output snippet:
;; Query time: 30 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
This tells you the DNS server IP and port.
Checking DNS Server via /etc/network/interfaces or Netplan
On some Linux systems, DNS servers are configured in network configuration files.
For systems using /etc/network/interfaces:
Open the file with:
cat /etc/network/interfaces
Look for lines like:
dns-nameservers 8.8.8.8 8.8.4.4
These specify the DNS servers.
For systems using Netplan (common in Ubuntu):
Check YAML files in /etc/netplan/ directory:
cat /etc/netplan/*.yaml
Look for nameservers under your network interface section:
nameservers:
addresses:
- 1.1.1.1
- 8.8.8.8
This shows the DNS servers configured.
How to Find Your Network Interface Name
Sometimes, you need your network interface name to check DNS settings. Use:
ip link show
This lists all network interfaces, such as eth0, wlan0, or enp3s0.
Knowing your interface name helps when using commands like nmcli or systemd-resolve.
Using the host Command to Test DNS Resolution
The host command can test DNS resolution and show which server is used.
Run:
host google.com
It will display the IP address and the DNS server queried.
Example output:
Using domain server:
Name: 192.168.1.1
Address: 192.168.1.1#53
Aliases:
google.com has address 142.250.190.14
This confirms your DNS server IP.
Troubleshooting When You Can’t Find DNS Server
If none of the above methods show your DNS server, try these steps:
- Check if your system uses a VPN or proxy that changes DNS.
Restart your network service or systemd-resolved with:
sudo systemctl restart systemd-resolvedVerify your router’s DNS settings if you use DHCP.
- Look for custom DNS settings in your desktop environment’s network settings.
Why You Might Want to Change Your DNS Server on Linux
Sometimes, you want to switch DNS servers for:
- Faster browsing speeds
- Better privacy (e.g., using Cloudflare or OpenDNS)
- Bypassing regional restrictions
You can change DNS servers by editing /etc/resolv.conf (if not managed by systemd or NetworkManager) or configuring your network manager tools.
Summary Table of Commands to Find DNS Server on Linux
| Method | Command/Location | Notes |
| Check resolv.conf | cat /etc/resolv.conf | Basic DNS info, may be overwritten |
| systemd-resolved status | systemd-resolve --status or resolvectl status | Shows DNS per interface |
| NetworkManager info | nmcli device show | Lists DNS for active devices |
| dig command | dig google.com | Shows DNS server used for queries |
| Network config files | /etc/network/interfaces or /etc/netplan/*.yaml | DNS servers set in config files |
| host command | host google.com | Tests DNS resolution and server used |
Conclusion
Finding your DNS server on Linux is straightforward once you know where to look. Whether you check the /etc/resolv.conf file, use systemd-resolved commands, or query NetworkManager, you have many options. Each method gives you insight into how your system resolves domain names.
Understanding your DNS setup helps you troubleshoot network issues and customize your internet experience. Next time you need to find your DNS server on Linux, you’ll know exactly what to do.
FAQs
How do I find my DNS server IP on Linux?
You can check the /etc/resolv.conf file by running cat /etc/resolv.conf or use systemd-resolve --status to see DNS servers assigned to your network interfaces.
What if /etc/resolv.conf shows 127.0.0.53?
This means your system uses a local DNS stub resolver managed by systemd-resolved. Use systemd-resolve --status or resolvectl status to find the actual DNS servers.
Can I use dig to find my DNS server?
Yes, running dig google.com shows the DNS server IP under the “SERVER” line in the output.
How do I find DNS servers if I use NetworkManager?
Run nmcli device show and look for IP4.DNS entries under your active network device.
Where are DNS servers configured on Ubuntu with Netplan?
Check YAML files in /etc/netplan/ for the nameservers section under your network interface configuration.
