I have a list of domains that I would like to convert to their IP. Let them talk:
domain1.com
domain2.com
domain3.com
I would like to get the IP address of each of these domains, for example:
domain1.com → 111.111.111.111
domain2.com → 222.222.222.222
domain3.com → 333.333.333.333
I use the Perl script that I found online and add my list of domains where it says:
echo "
<insert_list>
" | perl -MSocket -lne'
my $address = ( split /:/ )[ 0 ] or next;
my $number = inet_aton $address;
my $ip = inet_ntoa $number;
print "$address -> $ip";
'
This works, but some of the domains on my list have expired and no longer have IP addresses, in which case I get the following error message:
Bad arg length for Socket::inet_ntoa, length is 0, should be 4 at -e line 4, <> line 9.
I would like to have a printed list that also tells me if a domain is not assigned. Example:
domain1.com → 111.111.111.111
domain2.com → 222.222.222.222
domain3.com → 333.333.333.333
domain4.com →
: 500 . IP- ?
. !