bcdbf395bf
Submitted by: Lohith Bellad <lohithbsd@gmail.com> Reviewed by: hiren (earlier rev), ae Obtained from: NetBSD MFC after: 1 week Relnotes: yes Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D9365
181 lines
4.8 KiB
Groff
181 lines
4.8 KiB
Groff
.\" $FreeBSD$
|
|
.\" $NetBSD: getaddrinfo.1,v 1.5 2014/04/22 06:02:06 wiz Exp $
|
|
.\"
|
|
.\" Copyright (c) 2013 The NetBSD Foundation, Inc.
|
|
.\" All rights reserved.
|
|
.\"
|
|
.\" This documentation is derived from text contributed to The NetBSD
|
|
.\" Foundation by Taylor R. Campbell.
|
|
.\"
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
.\" modification, are permitted provided that the following conditions
|
|
.\" are met:
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
.\"
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
.\" POSSIBILITY OF SUCH DAMAGE.
|
|
.\"
|
|
.Dd March 20, 2017
|
|
.Dt GETADDRINFO 1
|
|
.Os
|
|
.Sh NAME
|
|
.Nm getaddrinfo
|
|
.Nd resolve names to socket addresses
|
|
.Sh SYNOPSIS
|
|
.Nm
|
|
.Op Fl cNnP
|
|
.Op Fl f Ar family
|
|
.Op Fl p Ar protocol
|
|
.Op Fl s Ar service Ns Op Ns / Ns Ar protocol
|
|
.Op Fl t Ar socktype
|
|
.Op Ar hostname
|
|
.Sh DESCRIPTION
|
|
The
|
|
.Nm
|
|
utility resolves host and service names to socket addresses with
|
|
.Xr getaddrinfo 3
|
|
and prints them to standard output in a user-friendly format.
|
|
.Pp
|
|
The output is a sequence of lines with space-separated fields:
|
|
.Pp
|
|
.Dl socket-type address-family protocol [af-specific data ...]
|
|
.Pp
|
|
For the
|
|
.Dq inet
|
|
and
|
|
.Dq inet6
|
|
address families, the af-specific data are the IP/IPv6 address and port
|
|
number.
|
|
.Pp
|
|
Depending on the settings in
|
|
.Xr nsswitch.conf 5 ,
|
|
.Nm
|
|
might query DNS for answers.
|
|
However, it is not intended to be a general-purpose DNS query utility.
|
|
Use
|
|
.Xr drill 1
|
|
for that.
|
|
.Pp
|
|
These options are available:
|
|
.Bl -tag -width Ds
|
|
.It Fl c
|
|
Look up a canonical name as if with the
|
|
.Dv AI_CANONNAME
|
|
flag to
|
|
.Xr getaddrinfo 3
|
|
and print it on the first line before the socket addresses.
|
|
.It Fl f Ar family
|
|
Specify an address family.
|
|
Address families are named like the
|
|
.Dv AF_...
|
|
constants for address family numbers in the
|
|
.Aq Pa sys/socket.h
|
|
header file but without the
|
|
.Dv AF_
|
|
prefix and lowercase.
|
|
For example,
|
|
.Dq inet
|
|
corresponds with
|
|
.Dv AF_INET .
|
|
.It Fl N
|
|
Treat the service as numeric and do not attempt service name
|
|
resolution, as if with the
|
|
.Dv AI_NUMERICSERV
|
|
flag to
|
|
.Xr getaddrinfo 3 .
|
|
.It Fl n
|
|
Treat the hostname as a numeric address and do not attempt name
|
|
resolution, as if with the
|
|
.Dv AI_NUMERICHOST
|
|
flag to
|
|
.Xr getaddrinfo 3 .
|
|
.It Fl P
|
|
Return socket addresses intended for use with
|
|
.Xr bind 2 ,
|
|
as if with the
|
|
.Dv AI_PASSIVE
|
|
flag to
|
|
.Xr getaddrinfo 3 .
|
|
By default, the socket addresses are intended for use with
|
|
.Xr connect 2 ,
|
|
.Xr sendto 2 ,
|
|
or
|
|
.Xr sendmsg 2 .
|
|
.It Fl p Ar protocol
|
|
Specify a protocol.
|
|
Protocols are numeric or symbolic as listed in
|
|
.Xr protocols 5 .
|
|
.It Fl s Ar service Ns Op Ns / Ns Ar protocol
|
|
Specify a service to look up.
|
|
Services are symbolic or numeric with an optional
|
|
protocol suffix as listed in
|
|
.Xr services 5 .
|
|
If a service is not specified, a hostname is required.
|
|
.It Fl t Ar socktype
|
|
Specify a socket type.
|
|
Socket types are named like the
|
|
.Dv SOCK_...
|
|
constants for socket type numbers in the
|
|
.Aq Pa sys/socket.h
|
|
header file but without the
|
|
.Dv SOCK_
|
|
prefix and lowercase.
|
|
For example,
|
|
.Dq dgram
|
|
corresponds with
|
|
.Dv SOCK_DGRAM .
|
|
.El
|
|
.Sh EXIT STATUS
|
|
.Ex -std getaddrinfo
|
|
.Sh EXAMPLES
|
|
Look up
|
|
.Dq www.NetBSD.org :
|
|
.Bd -literal -offset indent
|
|
$ 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
|
|
.Ed
|
|
.Pp
|
|
The port number here is zero because no service was specified.
|
|
.Pp
|
|
Look up
|
|
.Dq morden.NetBSD.org
|
|
for stream sockets on port 80, and show the canonical name:
|
|
.Bd -literal -offset indent
|
|
$ 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
|
|
.Ed
|
|
.Sh SEE ALSO
|
|
.Xr drill 1 ,
|
|
.Xr getent 1 ,
|
|
.Xr getaddrinfo 3 ,
|
|
.Xr getnameinfo 3 ,
|
|
.Xr resolver 3 ,
|
|
.Xr hosts 5 ,
|
|
.Xr nsswitch.conf 5 ,
|
|
.Xr protocols 5 ,
|
|
.Xr resolv.conf 5 ,
|
|
.Xr services 5
|
|
.Sh HISTORY
|
|
The
|
|
.Nm
|
|
command first appeared in
|
|
.Nx 7.0 .
|