Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Perl one-liner to get IP address from mDNS/DNS/Bonjour/whatever - works on any *nix that supports getHostByName
# usage: `ip4 HOSTNAME`
alias ip4='perl -MSocket -e '\''$pack=gethostbyname($ARGV[0]); print inet_ntoa($pack)'\'''
# returns an IP address for HOSTNAME
perl -MSocket -e '$pack=gethostbyname($ARGV[0]); print inet_ntoa($pack)' HOSTNAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment