Last active
June 12, 2019 00:43
-
-
Save b4hand/6178703 to your computer and use it in GitHub Desktop.
Resolve a hostname to all IPs via command line (IPv4 or IPV6)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| perl -e 'use Socket qw(getaddrinfo getnameinfo NI_NUMERICSERV NI_NUMERICHOST); my ($err, @res) = getaddrinfo($ARGV[0], "www", {socktype => SOCK_STREAM}); for my $r (@res) { my ($err, $ip) = getnameinfo($r->{addr}, NI_NUMERICHOST | NI_NUMERICSERV); print "$ip\n";}' |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You may also be interested in ip_to_name which does a reverse DNS lookup in a one-liner.