GETNAMEINFO(1) | General Commands Manual | GETNAMEINFO(1) |
getnameinfo
—
getnameinfo |
[-46fHNnrSu ] [-p
port] IP-address |
getnameinfo
utility resolves IP addresses and port
numbers to hostnames and service names as if with the
getnameinfo(3) library
routine and formats them to standard output.
The output is a single line of space-separated fields:
hostname service
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.
Although getnameinfo
may query the DNS or
other sources for name resolution depending on the system's
nsswitch.conf(5)
configuration, it is not intended to replace DNS-specific tools like
dig(1).
The following options are available:
-4
-6
-f
NI_NOFQDN
flag in
getnameinfo(3).-H
-N
NI_NUMERICSERV
flag in
getnameinfo(3).-n
NI_NUMERICHOST
flag in
getnameinfo(3).-p
port-r
NI_NAMEREQD
flag in
getnameinfo(3).-S
-u
NI_DGRAM
flag in
getnameinfo(3).getnameinfo
utility exits 0 on success,
and >0 if an error occurs.
$ getnameinfo -4 -p 80 93.184.216.34 example.com http
Look up the numeric host and service for an IPv6 address:
$ getnameinfo -nN -p 443 2606:2800:220:1:248:1893:25c8:1946 2606:2800:220:1:248:1893:25c8:1946 443
Resolve an address to its hostname but suppress the service name:
$ getnameinfo -H -p 22 192.0.2.1 example-host
Resolve a hostname and service for a UDP connection:
$ getnameinfo -u -p 53 198.51.100.2 example-dns-server domain
January 16, 2025 | NetBSD 10.99 |