61
votes
Is `dig ptr` a valid way to perform a reverse DNS query?
dig -x is a form of "syntactic sugar" that was added to the program later.
Reverse DNS records, or PTR records, for IPv4 addresses are stored in the DNS in the reversed format that you see in the ...
22
votes
Accepted
how to extract just the IP address from a DNS query
I believe dig +short outputs two lines for you because the domain
you query, smtp.mydomain.net is a CNAME for smtp.ggs.mydomain.net,
and dig prints the intermediate resolution step.
You can probably ...
18
votes
How does dig find my WAN-IP-address? What is "myip.opendns.com" doing?
Google provides the same service.
For IPv4:
dig -4 TXT +short o-o.myaddr.l.google.com @ns1.google.com
For IPv6:
dig -6 TXT +short o-o.myaddr.l.google.com @ns1.google.com
where TXT is a DNS record ...
18
votes
Accepted
How does dig find my WAN-IP-address? What is "myip.opendns.com" doing?
First to summarize the general usage of dig: it requests the IP assigned to the given domain from the default DNS server. So e.g. dig google.de would request the IP assigned to the domain google.de. ...
15
votes
Accepted
Why does dig -6 google.com not work for me?
-4/-6 tells dig to only use IPv4/IPv6 connectivity to carry your query to the nameserver - it doesn't change whether to query for A records(IPv4) or AAAA records(IPv6) if that's what you intended. If ...
10
votes
Why does dig -6 google.com not work for me?
Yes, that suggests that you do not have IPv6 connectivity.
If you want to obtain an IPv6 address for google rather than using IPv6 to obtain an address for google, you want
dig -t aaaa google.com
...
10
votes
Accepted
Why doesn't systemd-resolved use my local DNS server?
So, changing my wired eth0 interface to be managed solved this issue for me.
Changing ifupdown to managed=true in /etc/NetworkManager/NetworkManager.conf
[ifupdown]
managed=true
Then restart ...
9
votes
Accepted
How to enable nameserver recursion?
The DNS resolver will only move onto the other name servers if the first one returns an error (i.e SERVFAIL) or can't be reached. If the DNS server returns NXDOMAIN then the resolver considers that ...
8
votes
Accepted
Force dig to forget records
dig doesn’t remember queries. But it makes use of name servers listed in /etc/resolv.conf, unless the server to be queried is specified explicitly. Such servers normally accept recursive queries and ...
8
votes
Why doesn't systemd-resolved use my local DNS server?
My guess is that your systemd-resolved service is configured correctly, but it never gets to see the request. The .local domain is treated specially by systems running mDNS. avahi-daemon, which ...
7
votes
Accepted
How do I figure out where wrong local dns results are coming from?
Resolvconf is pointing it out to a local software running in port 53 in the local machine.
To find it out which one:
sudo netstat -anlp | grep :53
As we have found out, it is the avahi daemon.
To ...
7
votes
how to extract just the IP address from a DNS query
@dhag's answer sounds good; if you do not want to “rely on the last line from dig's output being the IP” you can use grep to extract just the numerical IP address:
dig +short smtp.mydomain.net | grep ...
6
votes
Accepted
Finding out what DNS server are being used
You can use the +trace option to dig to see the entire sequence of queries, from your system to root servers, all the way down to the authoritative servers.
6
votes
Force dig to forget records
If you don't want a cached answer, ask directly the authoritative DNS serveur with @.
Example: dig yahoo.com @ns1.yahoo.com
6
votes
Accepted
resolve my ip with dig returns empty string
For some reason opendns is also not working for me at work. e.g. your command is not at fault, it is simply that opendns is not answering to that specific query to find the public IP address in some ...
5
votes
Accepted
dig does not resolve unqualified domain names, but nslookup does
Does dig +search dns01 give you what you want? If so, it it possible that +nosearch somehow got added to your ~/.digrc ?
ETA: Or, if you're like me, maybe the dig fairies failed to come and add +...
5
votes
How to install dig on CentOS?
On legacy systems you'll have to use yum instead:
$ yum install bind-utils
5
votes
Accepted
dig -x www.google.com
Notice in the response that you got back status: NXDOMAIN and ANSWER: 0. This means there was no record found matching your query.
The -x option to dig is merely a convenience for constructing a PTR ...
5
votes
How to install dig on Cygwin?
The correct package name for Cygwin at least is: bind-utils:
As you can see I've already installed it. Also to note, there was nothing to configure for dig to work right after installation.
4
votes
Accepted
How can I get my bash script to remove the first n and last n lines from a variable?
sed takes its input from stdin, not from the command line, so your script won't work either theoretically or practically. sed -i 1,10d $dr does not do what you think it does...sed will treat the ...
4
votes
Accepted
dig / nslookup cannot resolve, but ping can
This is not a problem of a more basic protocol not working, but rather that there are multiple name service resolution protocols being used; ping here understands multicast DNS (mDNS) and is able to ...
4
votes
Accepted
How does root(DNS) server could answer about twitter.com?
Unable to replicate:
$ dig @a.root-servers.net twitter.com +norecurse
; <<>> DiG 9.8.3-P1 <<>> @a.root-servers.net twitter.com +norecurse
; (1 server found)
;; global options:...
4
votes
Accepted
How to install dig on Cygwin?
To find the proper package that contains a specific file, you can always use cygcheck -p to ask the Cygwin server:
$ cygcheck -p bin/dig
Found 6 matches for bin/dig
bind-debuginfo-9.11.5-2.P4 - bind-...
3
votes
DNS caching problem
DNS is cached by design. When you update a record, you need to set a new serial number, and then servers with the old one will notice once the old TTL expires.
Your question demonstrates no ...
3
votes
Accepted
Bash print current line, line's output, and linebreak to file
To avoid running one dig and read per line of the file, you could do:
dig -f domains.txt mx +noall +answer
Which would give an output like:
stackexchange.com. 300 IN MX 5 alt1....
3
votes
Accepted
Dig command: Is the output guaranteed to be sorted?
dig does not reorder the results, it shows them in the order that the nameserver returns them. Nameservers normally shuffle the results (either randomly or round-robin) each time they're queried for a ...
3
votes
Resolve local host without any DNS server?
You're using /etc/hosts correctly but nslookup ignores the hosts file. It is doing a DNS lookup not a lookup of how the hostname resolves in your configured environment. Try pinging the hostname ...
3
votes
Why does dig utility hang indefinitely even with timeout specified?
As for using aplicational timeouts in some utilities, when there are connectivity issues, it is not always guaranteed the application will stop on it's own with some outside "coercion".
I would use ...
3
votes
How to get dig without bind
You can install the dnsutils package containing dig or nslookup, and leave alone the bind9 package containing the BIND daemon which you do not need. (Thanks to @telcoM for adding this info in a ...
3
votes
Extract A record and query time from dig output
Pretty trivial with awk, the exact matching conditions may be tweaked based on the possible patterns that may appear:
dig @1.1.1.1 google.com +noall +answer +stats | \
awk '$3 == "IN" && $...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
dig × 78dns × 41
nslookup × 15
bash × 10
networking × 8
linux × 7
debian × 5
scripting × 5
bind × 5
dnsmasq × 5
ip × 4
ubuntu × 3
shell × 3
command-line × 3
ipv6 × 3
ping × 3
shell-script × 2
cache × 2
hosts × 2
timeout × 2
domain × 2
resolv.conf × 2
systemd-resolved × 2
centos × 1
text-processing × 1