p The output is a single line of space-separated fields:
p .Dl hostname service
p Depending on the flags specified, the output may consist only of the hostname or service name, or their numeric representations. By default, both are shown.
p Although .Nm may query the DNS or other sources for name resolution depending on the system's .Xr nsswitch.conf 5 configuration, it is not intended to replace DNS-specific tools like .Xr dig 1 .
p The following options are available: l -tag -width Fl t Fl 4 Restrict the lookup to IPv4 addresses only. t Fl 6 Restrict the lookup to IPv6 addresses only. t Fl F Suppress the fully-qualified domain name (FQDN). This is equivalent to the .Dv NI_NOFQDN flag in .Xr getnameinfo 3 . t Fl f Specify an address family numerically or as a name, eg. .Dq inet . t Fl H Display only the hostname, omitting the service name. t Fl N Display the numeric service name instead of resolving to a service name. This is equivalent to the .Dv NI_NUMERICSERV flag in .Xr getnameinfo 3 . t Fl n Display the numeric host address instead of resolving to a hostname. This is equivalent to the .Dv NI_NUMERICHOST flag in .Xr getnameinfo 3 . t Fl p Ar port Specify the port number to be used in the lookup. t Fl r Ensure that a name is returned. If no name can be resolved, an error is reported. This is equivalent to the .Dv NI_NAMEREQD flag in .Xr getnameinfo 3 . t Fl S Display only the service name, omitting the hostname. t Fl u Use UDP instead of the default TCP. This is equivalent to the .Dv NI_DGRAM flag in .Xr getnameinfo 3 . .El .Sh EXIT STATUS .Ex -std getnameinfo .Sh EXAMPLES Look up the hostname and service name for an IPv4 address: d -literal -offset indent $ getnameinfo -4 -p 80 93.184.216.34 example.com http .Ed
p Look up the numeric host and service for an IPv6 address: d -literal -offset indent $ getnameinfo -nN -p 443 2606:2800:220:1:248:1893:25c8:1946 2606:2800:220:1:248:1893:25c8:1946 443 .Ed
p Resolve an address to its hostname but suppress the service name: d -literal -offset indent $ getnameinfo -H -p 22 192.0.2.1 example-host .Ed
p Resolve a hostname and service for a UDP connection: d -literal -offset indent $ getnameinfo -u -p 53 198.51.100.2 example-dns-server domain .Ed .Sh SEE ALSO .Xr dig 1 , .Xr getaddrinfo 1 , .Xr getaddrinfo 3 , .Xr getnameinfo 3 , .Xr inet 3 , .Xr hosts 5 , .Xr nsswitch.conf 5