Skip to content

Userspace utility for running getaddrinfo. Useful for figuring out if your changes to /etc/hosts and dnsmasq are being picked up by programs.

License

Notifications You must be signed in to change notification settings

atorstling/getaddrinfo

Repository files navigation

getaddrinfo

When changing /etc/hosts or meddling with dnsmasq, I often wished that there was a userspace equivalent of getaddrinfo(3), gethostbyname(3) and gethostbyname2(3). Now there is!

examples

Get IPv4 TCP address and canonical hostname of mail.google.com:

$getaddrinfo -f AF_INET -s SOCK_STREAM -l AI_CANONNAME mail.google.com
AF_INET SOCK_STREAM IPPROTO_TCP 172.217.22.165  googlemail.l.google.com

Simply run gethostbyname:

$gethostbyname dropbox.com
hostname: dropbox.com
address: 108.160.172.238
address: 108.160.172.206

Simply run gethostbyname2:

$gethostbyname2 -f AF_INET6 google.com
hostname: google.com
address: 2a00:1450:400f:807::200e

Find out which address to listen to (AI_PASSIVE) ssh traffic (port 22) on IPv4 (AF_INET) TCP (SOCK_STREAM):

$getaddrinfo -e 22 -f AF_INET -s SOCK_STREAM -l AI_PASSIVE
AF_INET SOCK_STREAM IPPROTO_TCP 0.0.0.0

About

Userspace utility for running getaddrinfo. Useful for figuring out if your changes to /etc/hosts and dnsmasq are being picked up by programs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published