2

The dig command is deprecated. I'm using drill from ldns. Drill doesn't seem to have a short option to show only the ip. Does anyone know how I can make it show only the ip and not the other text.

3

3 Answers 3

0

Found a way to do it with curl and cloudflare

curl -fSs https://1.1.1.1/cdn-cgi/trace | awk -F= '/ip/ { print $2 }'
0

dig with+short look like this:

$ dig +short example.com
XXX.XX.XX.XXX

So, you could simply do:

$ drill example.com | awk '{if(NF > 0 && substr($1,1,1) != ";") print $NF }'
XXX.XX.XX.XXX

Understanding my awk

if (NF > 0)  # If the line is not empty
if (substr($1,1,1) != ";") # If the first character is not `;`
print $NF # Print the last column.
0

A little late the party here, but it looks like drill ~now~ has a -Q ("quiet") flag that does the same as dig's +short:

$ drill -Q superuser.com
104.18.8.56
104.18.9.56

UPDATE: Looks like the feature has been in ldns since at least the 1.0.0 release. You probably just missed it in your research because drill doesn't aim to be a 100% drop-in replacement for dig?


Previous Answer

What's a little surprising is, that feature was apparently committed in 2005, but not in a released version until Nov 2021.

I'm not sure what caused it (and other commits) to sit in limbo for 16 years, but at least you have a drill-native solution now!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .