Resolve names to socket addresses.
getaddrinfo [-cNnP] [-f family] [-p protocol] [-s service[/protocol]] [-t socktype] [hostname]
The getaddrinfo utility resolves host and service names to socket addresses with getaddrinfo(3) and prints them to standard output in a user-friendly format.
The output is a sequence of lines with space-separated fields:
socket-type address-family protocol [af-specific data ...]
For the "inet" and "inet6" address families, the af-specific data are the IP/IPv6 address and port number.
Depending on the settings in nsswitch.conf(5), getaddrinfo might query DNS for answers. However, it is not intended to be a general-purpose DNS query utility. Use drill(1) for that.
These options are available:
The getaddrinfo utility exits 0 on success, and >0 if an error occurs.
Look up "www.NetBSD.org":
$ getaddrinfo www.NetBSD.org
dgram inet6 udp 2001:4f8:3:7:2e0:81ff:fe52:9ab6 0
dgram inet udp 149.20.53.67 0
stream inet6 tcp 2001:4f8:3:7:2e0:81ff:fe52:9ab6 0
stream inet tcp 149.20.53.67 0
The port number here is zero because no service was specified.
Look up "morden.NetBSD.org" for stream sockets on port 80, and show the canonical name:
$ getaddrinfo -c -t stream -s 80 morden.NetBSD.org
canonname ftp.NetBSD.org
stream inet6 tcp 2001:470:1f05:3d::21 80
stream inet tcp 199.233.217.249 80
The getaddrinfo command first appeared in NetBSD 7.0.
Versions |
---|
INtime 7.1 |