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)
You should be able to get some reasonable information in:
$ cat /etc/resolv.conf
Here's how I do it:
nmcli dev show | grep DNS
This worked previous to the way above:
nm-tool | grep DNS
I think you can also query DNS and it will show you what server returned the result. Try this:
And the response should tell you what server(s) returned the result. The output you're interested in will look something like this:
;; Query time: 91 msec ;; SERVER: 172.xxx.xxx.xxx#53(172.xxx.xxx.xxx) ;; WHEN: Tue Apr 02 09:03:41 EDT 2019 ;; MSG SIZE rcvd: 207
You can also tell
dig to query a specific DNS server by using
Just do an,
nslookup. Part of its results include the server that it's using.
In the example below, it shows that the DNS server used is at 188.8.131.52.
$ nslookup google.com Server: 184.108.40.206 Address: 220.127.116.11#53 Non-authoritative answer: Name: google.com Address: 18.104.22.168
On systems running systemd use:
With the new
nmcli, do this:
nmcli --fields ipv4.dns,ipv6.dns con show <connection_name>
On newer versions of network-manager (such as in Ubuntu 16.04), the field names are slightly different:
nmcli --fields ip4.dns,ip6.dns con show <connection_name>
If you don't know the connection name, use:
nmcli -t --fields NAME con show --active
$ nmcli --fields ip4.dns,ip6.dns con show 'Wired connection 1' IP4.DNS: 172.21.0.13 IP4.DNS: 172.21.0.4
to get the first DNS SERVER (IP only) :
cat /etc/resolv.conf |grep -i '^nameserver'|head -n1|cut -d ' ' -f2
catwill output DNS config
grepfilters only nameserver
headwill keep only the first row/instance
cuttake the ip part of the row (second column with ' ' as separator)
To put DNS ip in an environment variable, you could use as follow:
export THEDNSSERVER=$(cat /etc/resolv.conf |grep -i '^nameserver'|head -n1|cut -d ' ' -f2)
If you are using network manager probably you get all network parameters from your dhcp server at your university.
If you don't want use your shell to check your dns settings (as described by hesse and Alexios), you can see them from the panel "Network information".
You can reach this panel by pressing right mouse button on network manager icon and selecting "Connection Information" from the menu.
nmcli dev list iface <interfacename> | grep IP4
Replace "interfacename" with yours.
nmcli dev list iface eth0 | grep IP4
This will list all DNS servers(If you use more than one).
I have Fedora 25 and also had similar slow response on command line to sudo commands.
nmcli dev show | grep DNS
showed that only one of my 3 adapters (two active) had DNS entries. By adding DNS entries to the one active card that didn't have an entry - presto! All is good and response time is immediate.
$ resolvectl status | grep -1 'DNS Server' DNSSEC supported: no Current DNS Server: 22.214.171.124 DNS Servers: 126.96.36.199 188.8.131.52
systemd-resolve is a symbolic link to
resolvectl on many distros as for Ubuntu 18.10:
$ type -a systemd-resolve systemd-resolve is /usr/bin/systemd-resolve $ ll /usr/bin/systemd-resolve lrwxrwxrwx 1 root root 10 nov. 15 21:42 /usr/bin/systemd-resolve -> resolvectl $ type -a resolvectl resolvectl is /usr/bin/resolvectl $ file /usr/bin/resolvectl /usr/bin/resolvectl: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=09e488e849e3b988dd2ac93b024bbba18bb71814, stripped
In CentOS, you can use:
protected by Community♦ Sep 6 '18 at 23:49
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?