Perl still does my hostnames resolving

Again, I had a large list of hostnames which I needed resolved to their ip addresses.

  • nslookup: slow
  • ping -c 1: slow
  • getent hosts: “random” ipv6 addresses
  • no fping available

So I still use perl for gethostbyname() or getaddrinfo():

Example below takes input from stdin/pipe.

perl -MSocket -nwle'my @addresses = gethostbyname($_); my @ips = map { inet_ntoa($_) } @addresses[4 .. $#addresses]; print "@ips"'

Leave a Reply

Your email address will not be published. Required fields are marked *