- 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
- 3 Ways to check DNS server IP in Linux
- Check DNS server IP with Dig command in Linux
- Check DNS server IP with nslookup command in Linux
- Check DNS server IP with /etc/resolv.conf file in Linux
- Как посмотреть DNS в Linux
- Как посмотреть DNS в Linux
- Get The Active DNS Servers On 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.
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 ;; 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: 78Check 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.9Check 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.248We 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!
Как посмотреть 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.
Get The Active DNS Servers On Linux
The Domain Name System (DNS for short) is one of the most important parts of the internet infrastructure. It converts the easy to remember domain names, into IP (and IPv6) addresses, that aren’t so friendly to the end user.
Regardless of the distribution of Linux that you are using (such as Ubuntu, CentOS, Debian, Arch, Redhat, etc), the process of determining what DNS servers are currently being used for domain name resolution is the same.
To determine what DNS servers are being used, you simply need to view the contents of the “/etc/resolv.conf” file. This can be done via a graphical editing tool such as gedit, or can easily be viewed from the command line with a simple “cat” of the file, to show the contents. The command below will outline how to determine the DNS servers in use.
Show the active DNS servers on Linux:You will end up with some output like this:
# 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 8.8.8.8 nameserver 8.8.4.4You may or may not have the comments at the top of the file, as that will depend on your distribution, but you should have at least one or more “nameserver” records. These will be the name server IP’s that your system will currently be using. In this example, 8.8.8.8 and 8.8.4.4.
Note that this must be an IP address, and cant be a domain name.