1 .\" $NetBSD: getaddrinfo.1,v 1.5 2014/04/22 06:02:06 wiz Exp $
3 .\" Copyright (c) 2013 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This documentation is derived from text contributed to The NetBSD
7 .\" Foundation by Taylor R. Campbell.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
18 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGE.
35 .Nd resolve names to socket addresses
41 .Op Fl s Ar service Ns Op Ns / Ns Ar protocol
47 utility resolves host and service names to socket addresses with
49 and prints them to standard output in a user-friendly format.
51 The output is a sequence of lines with space-separated fields:
53 .Dl socket-type address-family protocol [af-specific data ...]
59 address families, the af-specific data are the IP/IPv6 address and port
62 Depending on the settings in
65 might query DNS for answers.
66 However, it is not intended to be a general-purpose DNS query utility.
71 These options are available:
74 Look up a canonical name as if with the
78 and print it on the first line before the socket addresses.
80 Specify an address family.
81 Address families are named like the
83 constants for address family numbers in the
85 header file but without the
93 Treat the service as numeric and do not attempt service name
94 resolution, as if with the
99 Treat the hostname as a numeric address and do not attempt name
100 resolution, as if with the
105 Return socket addresses intended for use with
111 By default, the socket addresses are intended for use with
118 Protocols are numeric or symbolic as listed in
120 .It Fl s Ar service Ns Op Ns / Ns Ar protocol
121 Specify a service to look up.
122 Services are symbolic or numeric with an optional
123 protocol suffix as listed in
125 If a service is not specified, a hostname is required.
127 Specify a socket type.
128 Socket types are named like the
130 constants for socket type numbers in the
132 header file but without the
134 prefix and lowercase.
145 .Bd -literal -offset indent
146 $ getaddrinfo www.NetBSD.org
147 dgram inet6 udp 2001:4f8:3:7:2e0:81ff:fe52:9ab6 0
148 dgram inet udp 149.20.53.67 0
149 stream inet6 tcp 2001:4f8:3:7:2e0:81ff:fe52:9ab6 0
150 stream inet tcp 149.20.53.67 0
153 The port number here is zero because no service was specified.
156 .Dq morden.NetBSD.org
157 for stream sockets on port 80, and show the canonical name:
158 .Bd -literal -offset indent
159 $ getaddrinfo -c -t stream -s 80 morden.NetBSD.org
160 canonname ftp.NetBSD.org
161 stream inet6 tcp 2001:470:1f05:3d::21 80
162 stream inet tcp 199.233.217.249 80
171 .Xr nsswitch.conf 5 ,
178 command first appeared in