1

I currently have to find the IP-Adresses of a lot of servers.

I have written a bash script on linux that creates all the server names.

When I write it like this, I get all servernames, even if there no longer have an IP.

host $f$n$d >> IPs.txt

Is there a way to only write the servers into the file, that still have an IP, together with the servername.

Kind regards Elias

Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74

1 Answers1

0

I think the local DNS resolver caches the IP addresses, so you will get the corresponding IPs even in the scenario you described.

I suggest you to start the script with a full local DNS flush, depending on your distribution and DNS client: Here are son techinques to flush it.

Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74
  • This will sadly not work, because those IPs where created as "support-IPs" for servers, and when these servers where removed those IPs where left over. I also have to operate from a server with this script, on which I am probably not allowed to do such things... –  Mar 14 '22 at 09:40
  • 1
    I understand. I suggest you to post this questo on **UnixStackExchange** for a better support. – Antonio Petricca Mar 14 '22 at 09:43