Узнать свой днс 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).

Читайте также:  Linux автоматический перезапуск службы

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.

Читайте также:  Linux info about so file

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: ;; ->>HEADER

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.

Источник

Как узнать IP DNS сервера в Linux

DNS (Domain Name System — система доменных имён) является важным элементом сети. Без DNS не работали бы Интернет-браузер, почтовые сервера, стриминговые сервисы и другие.

Задача DNS сообщать IP адрес запрошенного имени хоста (обычно домена веб-сайта).

Эта служба работает на специальных компьютерах, называемых DNS сервер — они хранят базу данных записей, включающей в себя имена хостов и соответствующие им IP адреса. DNS серверы представляют собой иерархическую структуру, но нам важно только то, что на наш запрос с именем хоста DNS сервер отвечает, какой у этого хоста IP адрес.

То есть DNS решает проблему, что нам не нужно помнить/знать IP адреса всех сайтов, которые мы посещаем.

DNS это обширная и интересная тема, но в этой заметке мы только поговорим, как узнать, к какому именно DNS серверу делаются запросы с данного компьютера на Linux? То есть мы научимся определять IP адрес используемого DNS сервера.

Имеется несколько способов сделать это, мы рассмотрим самые универсальные, подходящие для Linux, BSD, и других Unix-подобных систем.

Как узнать какой DNS сервер используется

1. Настройки DNS в системе хранятся в файле /etc/resolv.conf, то есть IP адрес DNS сервера можно узнать просто посмотрев этот файл.

С помощью команды cat:

С помощью команды less:

Или с помощью команды grep:

grep "nameserver" /etc/resolv.conf

Все эти команды выведут одинаковые результаты, например в моём случае это:

nameserver 8.8.8.8 nameserver 8.8.4.4

Запись может быть только одна или их может быть несколько. В первую очередь используется первый указанный DNS сервер, если к нему не удаётся получить доступ, то используются запасные DNS (если они указаны).

2. Если вам нужен альтернативный метод (например, вы предполагаете, что настройки DNS изменены сетевым подключением), то вы можете использовать программу dig:

Используемый сервер имён показан в строке начинающейся с ;; SERVER:

А в этом разделе, кстати, вы можете узнать IP адрес любого сайта:

;; ANSWER SECTION: zalinux.ru. 3799 IN A 185.26.122.38

3. Ещё один способ узнать IP адрес сайта, а заодно и IP DNS сервера к которому делаются запросы — с помощью команды nslookup:

В этих строках показан IP используемого DNS сервера:

Server: 8.8.8.8 Address: 8.8.8.8#53

А в этой строке IP адрес интересующего сайта:

Источник

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: 78

Check 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.9

Check 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.248

We 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!

Источник

Оцените статью
Adblock
detector