- Command-line to list DNS servers used by my system
- 13 Answers 13
- How to Find My DNS Server IP Address in Linux
- How to Find My DNS Server IP Address
- How to Find My Website DNS Server IP Address
- 6 Useful Tools to Troubleshoot DNS Name Resolution Problems
- 1. Nslookup Command
- 2. dig Command
- 3. host Command
- 4. ping Command
- 5. MXToolBox
- 6. IntoDNS
- Как посмотреть DNS в Linux
- Как посмотреть DNS в Linux
Command-line to list DNS servers used by my system
But it doesn’t list any servers, if I go to «Network Manager GUI Tool», in Wireless section it lists «DNS 192.168.1.1 8.8.8.8 8.8.4.4» Can I get same information from command line? I am using Ubuntu 12.04 LTS
What are you trying to find? the DNS servers being used by your system? or are you trying to do a DNS lookup?
13 Answers 13
resolv.conf isn’t really used anymore, unless you implement it yourself. The network manager does it now. I created an alias to list the DNS servers on my system, as I sometimes switch from OpenDNS to Google’s open DNS.
nmcli device show | grep IP4.DNS
nmcli dev list iface | grep IP4
In my case, is eth0 , which is common, but not always the case. You can see your interfaces with
See if this is what you want.
I think resolv.conf is actually used indirectly, because the network manager creates the server that listens on 127.0.0.1, but I was told that this is an implementation detail that should not be counted on. I think that if you enter DNS addresses before this entry, they might get used, but I’m not sure exactly how this works. I think it’s best to use the network manager in most cases, when possible.
thanks, yes that seems to be working, ubuntu networking seems to be confusing, so I can set dns servers in resolve.conf/base or in /etc/network/interfaces or in network manager, is there a definitive guide for ubuntu networking?
@vcardillo: the original question stated: «I am using Ubuntu 12.04 LTS». It’s been 5 years since I posted my answer. Nothing lasts forever.
I would like to warn readers that the information provided by nmcli and nm-tool might not be correct. In testing my router setup, I changed the DHCP server to configure a DNS. On my client (linux mint 17.3) I did sudo dhclient -r; sudo dhclient to renew IP configuration. At this point both commands I mentioned showed the old DNS, not the new one. cat /etc/resolv.conf did work for me, but according to op it did not work for him. The only reliable way to figure out which DNS is used appears to be to a lookup with for example dig, but I doubt dig will show you all configured DNS.
In Ubuntu 18.04 and 20.04 you can use systemd-resolve —status . In newer versions use resolvectl status .
IMO this should be the accepted answer. Also, it’s worth pointing out that systemd-resolve mydomain.com outputs which DNS server exactly is being queried (very useful if e.g. you have set up a VPN and so on).
This is valid for Ubuntu 13.10 and earlier. For Ubuntu 14.04 and above, see Koala Yeung’s answer to: How to know what DNS am I using in Ubuntu from 14.04 onwards
You will get an output similar to
NetworkManager Tool State: connected (global) - Device: eth0 [Wired connection 1] ------------------------------------------- Type: Wired Driver: e1000e State: connected Default: yes HW Address: 00:11:22:33:44:55 Capabilities: Carrier Detect: yes Speed: 1000 Mb/s Wired Properties Carrier: on IPv4 Settings: Address: 10.21.6.13 Prefix: 24 (255.255.255.0) Gateway: 10.21.6.1 DNS: 10.22.5.133 DNS: 10.22.5.3
Or to see just the DNS do
yeah this doesn’t work anymore. no nm-tool in 16.x either. nmcli (in Marty Fried’s answer) is the way to go
The two top-scoring answers, nmcli dev list iface | grep IP4 and nm-tool both assume that network-manager is in control. Which it is — on desktop machines most of the time at least. But the fuller answer is that sometimes network-manager is not in control. E.g. vpnc messes with /etc/resolv.conf directly.
So: First check if 127.0.0.1/localhost is used. This could be done with dig :
> dig something.unknown | grep SERVER: ;; SERVER: 127.0.0.1#53(127.0.0.1)
Now you know that we are using localhost. Go ahead with one of the popular answers. I like:
> nm-tool | grep DNS: DNS: 8.8.8.8
But if 127.0.0.1/localhost is not used, then nm-tool ‘s and nmcli ‘s output will be misleading:
> dig something.unknown | grep SERVER: ;; SERVER: 172.22.216.251#53(172.22.216.251) > nm-tool | grep DNS: DNS: 8.8.8.8
Here, dig is correct and nm-tool ‘s information is misleading. In reality addresses local to the environment I’ve VPN-ed into are resolved correctly. All of which Google’s DNS 8.8.8.8 doesn’t know about.
This is because after connecting to a VPN with vpnc , it puts a line in /etc/resolv.conf so it looks like:
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN nameserver 1.2.3.4 nameserver 127.0.0.1 search MyDomain
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.
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 OR $ less /etc/resolv.conf
2. Another way is to use the following grep command.
$ grep "nameserver" /etc/resolv.conf nameserver 109.78.164.20
Here, nameserver 109.78.164.20 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.
Sample Output
; > DiG 9.8.2rc1-RedHat-9.8.2-0.68.rc1.el6_10.1 > tecmint.com ;; global options: +cmd ;; Got answer: ;; ->>HEADEREasy 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.
6 Useful Tools to Troubleshoot DNS Name Resolution Problems
DNS (Domain Name System) is the phonebook of the internet. A Domain name is a unique alphanumeric address that users type in the URL bar in the browser in order to access a website.
Domain names enable users to access a website instead of using an IP address that maps onto every domain name. Sometimes, you may encounter DNS issues such as a misconfigured DNS server which might lead to downtime.
In this guide, we look at 6 tools you can leverage to troubleshoot DNS Name resolution problems in Linux.
1. Nslookup Command
The good old nslookup command has been around for a while. It’s a command-line tool that queries and provides detailed information about the internet domain name servers.
You would typically use the nslookup tool to obtain DNS records of a domain name such as the mapping between a domain name and its associated IP address. The information obtained from querying a DNS record is valuable in troubleshooting DNS-related issues.
To retrieve information about a DNS record, use the following syntax:
For example, to check the DNS record of a domain called linuxtechwhiz.info, run the command:
$ nslookup linuxtechwhiz.infoIf everything is okay, you should get output that resembles what we have here.
The first section displays information about the server used to obtain the DNS records. In this case, it is the local DNS server on my local network. Sometimes, this might be your router or an internal corporate server.
The second section displays the Fully Qualified Domain name and its corresponding IP address (Both IPv4 and IPv6). In some cases, like ours, IPv4 is the only active protocol.
For some domain names, both protocols are enabled. For example, if you query google.com, you find that the domain name maps to multiple IP addresses, both IPv4 and IPv6.
2. dig Command
Short for Domain Information Groper, dig is yet another command-line tool for querying Domain Name System (DNS) name servers. It’s a better DNS query tool and replaced the nslookup command.
The dig command allows you to perform DNS lookups and provide intricate details about various DNS records including A, MX, and SOA records.
The most straightforward way of probing a DNS record is by typing the dig command followed by the domain name and pressing ENTER.
The output of the dig command is quite verbose. To display the IP address mapping include the +short suffix as shown.
$ dig linuxtechwhiz.info +short 74.207.227.363. host Command
The host command is another handy tool you can use to handle manual DNS resolution. For example, you can perform a DNS forward lookup as shown.
You can also perform a reverse lookup as follows.
The -C option lets you query for the SOA records.
In addition, you can query for the MX records using the -t mx flags as shown.
To display all the information about a domain, pass the -a flag as shown.
4. ping Command
The ping command is mostly used to check the availability or reachability of a system or node.
You can test the connectivity of a domain name by pinging the domain as shown.
$ ping linuxtechwhiz.info -c 4A positive response implies that the name resolution is working as expected. An error points to a DNS resolution issue.
Moreover, you can ping the remote IP associated with the domain name to check if the system hosting your name is up and reachable.
The command-line tools that we have just looked at only provide limited information about your DNS records and cannot adequately be used to troubleshoot complex DNS issues.
5. MXToolBox
MXToolBox is a free online tool (paid for extra features) that provides fast and accurate network diagnostic and DNS lookup tools.
It provides you with a comprehensive outlook of your domain health, which includes monitoring your domain, displaying information about any DNS or IP blacklists, probing the email server for any issues, checking the web server, and running over 15 tests on your DNS server.
It’s a highly recommended tool if your sole purpose is to get to the bottom of any DNS-related issue.
6. IntoDNS
IntoDNS is another valuable tool that you can use to check and troubleshoot any DNS-related issues. In just a few seconds, it generates a detailed report about NS records, nameservers, SOA and MX records, TTL, refresh interval, and much more.
In addition, it provides information about mail servers’ IP address and their validity and any possible problem with your domain name.
Closing Thoughts
These are just a few tools that provide insights into your DNS records which come in handy in troubleshooting any faults or errors associated with your domain. We hope you found this guide insightful. Feel free to reach out with any comments or feedback.
Как посмотреть DNS в Linux
Служба DNS или Domain Name System позволяет превращать легко читаемый адрес сайта в ip адрес сервера на котором расположен этот сайт. Для этого используются DNS серверы, которые содержат таблицы соответствия ip адресов их доменным именам. По умолчанию система получает адрес DNS сервера автоматически по DHCP при подключении к сети.
В этой статье мы разберемся как посмотреть какие DNS серверы используются в Linux.
Как посмотреть DNS в Linux
Если вы уже имели опыт настройки сети в Linux, то знаете, что DNS серверы, используемые для резолвинга доменных имен указаны в файле /etc/resolv.conf:
Но в современных дистрибутивах Linux с системой инициализации systemd обычно запущен локальный DNS сервер, адрес которого и прописан в этом файле, а какие сервера используются на самом деле непонятно. В таком случае можно воспользоваться утилитой systemd-resolve:
В самом низу вывода утилиты можно посмотреть DNS в Linux, которые сейчас используются. Информация выводится по каждому сетевому интерфейсу отдельно.
Также для решения подобной задачи можно использовать утилиту nmcli:
Как видите, все очень просто. А чтобы изменить DNS сервер тоже трогать /etc/resolv.conf не желательно, так как он будет автоматически обновляться после перезагрузки. Если вы используете NetworkManager, то можно настроить DNS для сетевого подключения в интерфейсе программы. Или же можно отредактировать файл /etc/systemd/resolved.conf и добавить нужные адреса в секцию Resolve:
sudo vi /etc/systemd/resolved.conf
Как видите, все очень просто. Надеюсь, эта информация была вам полезной.
Обнаружили ошибку в тексте? Сообщите мне об этом. Выделите текст с ошибкой и нажмите Ctrl+Enter.