Created
June 10, 2022 18:10
-
-
Save darrenpmeyer/8d1c1ccf59a94adc10ca524434c15342 to your computer and use it in GitHub Desktop.
Perl one-liner to get IP address from mDNS/DNS/Bonjour/whatever - works on any *nix that supports getHostByName
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
# usage: `ip4 HOSTNAME` | |
alias ip4='perl -MSocket -e '\''$pack=gethostbyname($ARGV[0]); print inet_ntoa($pack)'\''' |
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
# 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