summaryrefslogtreecommitdiff
path: root/static/freebsd/man1/getaddrinfo.1
blob: fa9e8adce6a22866100e4ee88c68c0c5d5f95fab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
.\"	$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 ,
.Xr ip6addrctl 8
.Sh HISTORY
The
.Nm
command first appeared in
.Nx 7.0 .