Hot answers tagged

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 ...
user avatar
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 ...
user avatar
  • 14.6k
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 ...
user avatar
  • 181
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. ...
user avatar
  • 486
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 ...
user avatar
  • 1,599
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 ...
user avatar
  • 7,868
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 ...
user avatar
  • 369
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 ...
user avatar
  • 1,901
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 ...
user avatar
  • 1,853
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 ...
user avatar
  • 3,742
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 ...
user avatar
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 ...
user avatar
  • 274
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.
user avatar
  • 15.1k
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
user avatar
  • 1,994
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 ...
user avatar
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 +...
user avatar
  • 379
5 votes

How to install dig on CentOS?

On legacy systems you'll have to use yum instead: $ yum install bind-utils
user avatar
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 ...
user avatar
  • 67.6k
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.
user avatar
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 ...
user avatar
  • 67.9k
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 ...
user avatar
  • 30.2k
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:...
user avatar
  • 67.9k
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-...
user avatar
  • 776
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 ...
user avatar
  • 6,983
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....
user avatar
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 ...
user avatar
  • 9,154
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 ...
user avatar
  • 4,959
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 ...
user avatar
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 ...
user avatar
  • 25.8k
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" && $...
user avatar
  • 2,937

Only top scored, non community-wiki answers of a minimum length are eligible