0

We use a security rating service which among other things, searches the world for imposter domains that resemble our domains. So it does find some of those but also finds ones that don't exist. It finds a lot of them.

  • In the 5th line of a dig response, there is the term Answer: then a number.

  • I would like to run dig with a text file of hostnames, and for the results to be two columns only:

    Column 1: the hostname for that row

    Column 2: either Answer: x or just x, the value of Answer.

So far I can run dig with a bulk input file, but can't figure out how to filter the results and get them to display like that.

If anyone could point me in the right direction I'd be grateful.

1
  • Are you sure that your methodology is sound? Because I would assume that a professional service would not present you a list with domains that don't exist. -|- Running dig [some typo domain] is a request for the A record of the apex of that domain. And for example that will not result in an answer from a domain that is genuinely registered, but for which the owner has not has simply not set up that apex A record or no DNS at all. -|- stackoverflow.com/q/1780598/2952385 Commented Aug 17, 2023 at 14:56

1 Answer 1

0

You can use dig hostname +short to get answer in one line and also when you do bulk dig remember to use sleep between iterations else you might be get temporary blocked/rate limited from Nameserver. Here is the full one liner that might help you out

 cat input_file | while read -r line; do ans=$(dig $line +short); echo "$line $ans"; sleep 3; done

I did not get what you want exactly but you can post an example or use grep command in above line as per your need.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.