xref: /openbsd-src/share/man/man4/inet6.4 (revision f0e35aeda4632cb0cf13bc6e2b5d1365995c5d50)
1.\"	$OpenBSD: inet6.4,v 1.46 2022/10/10 00:12:45 jsg Exp $
2.\"	$KAME: inet6.4,v 1.19 2000/11/24 10:13:18 itojun Exp $
3.\"
4.\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5.\" All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the project nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.Dd $Mdocdate: October 10 2022 $
32.Dt INET6 4
33.Os
34.Sh NAME
35.Nm inet6
36.Nd Internet protocol version 6 family
37.Sh SYNOPSIS
38.In sys/types.h
39.In netinet/in.h
40.Sh DESCRIPTION
41The Internet Protocol version 6 family
42is an updated version of the Internet Protocol version 4 family.
43It comprises Internet Protocol version 6
44.Pq IPv6 ,
45Internet Control Message Protocol version 6
46.Pq ICMPv6 ,
47Transmission Control Protocol
48.Pq TCP ,
49and User Datagram Protocol
50.Pq UDP .
51.Xr tcp 4
52is used to support the
53.Dv SOCK_STREAM
54abstraction while
55.Xr udp 4
56is used to support the
57.Dv SOCK_DGRAM
58abstraction.
59A raw interface to IPv6 is available by creating an Internet socket of type
60.Dv SOCK_RAW .
61The ICMPv6 message protocol is accessible from a raw socket.
62.Pp
63IPv6 addresses are 128-bit quantities,
64stored in network standard byteorder.
65The include file
66.In netinet/in.h
67defines this address
68as a discriminated union.
69.Pp
70Sockets bound to the
71.Nm
72family utilize the following addressing structure:
73.Bd -literal -offset indent
74struct sockaddr_in6 {
75	u_int8_t	sin6_len;
76	sa_family_t	sin6_family;
77	in_port_t	sin6_port;
78	u_int32_t	sin6_flowinfo;
79	struct in6_addr	sin6_addr;
80	u_int32_t	sin6_scope_id;
81};
82.Ed
83.Pp
84Sockets may be created with the local address
85.Dq ::
86(which is equal to IPv6 address
87.Dv 0:0:0:0:0:0:0:0 )
88to effect
89.Dq wildcard
90matching on incoming messages.
91.Pp
92For security reasons,
93.Ox
94does not route IPv4 traffic to an
95.Dv AF_INET6
96socket,
97and does not support IPv4 mapped addresses,
98where IPv4 traffic is seen as if it comes from an IPv6 address like
99.Dq ::ffff:10.1.1.1 .
100Where both IPv4 and IPv6 traffic need to be accepted,
101bind and listen on two sockets.
102.Pp
103Global addresses utilise the first 48 bits of the address
104for the routing prefix.
105The next 16 bits designate the subnet,
106and the final 64 bits are used as a host identifier.
107.Pp
108The IPv6 specification also defines link-local addresses,
109which are scoped.
110A scoped address is ambiguous to the kernel
111if it is specified without a scope identifier.
112To manipulate scoped addresses properly from userland,
113programs must use the advanced API defined in RFC 3542.
114A compact description of the advanced API is available in
115.Xr ip6 4 .
116If scoped addresses are specified without explicit scope,
117the kernel may raise an error.
118.Pp
119KAME supports an extended numeric IPv6 address notation
120for link-local addresses,
121such as
122.Dq fe80::1%de0
123to specify
124.Dq fe80::1
125on the
126.Dq de0
127interface.
128This notation is supported by
129.Xr getaddrinfo 3
130and
131.Xr getnameinfo 3 ,
132as well as userland programs such as
133.Xr telnet 1
134and
135.Xr ftp 1 .
136.Pp
137Scoped addresses are handled specially in the kernel.
138In kernel structures like routing tables or interface structures,
139scoped addresses have their interface index embedded into the address.
140Therefore
141the address on some kernel structures is not the same as that on the wire.
142The embedded index will be visible on
143.Dv PF_ROUTE
144sockets, kernel memory access via
145.Xr kvm 3 ,
146and some other occasions.
147HOWEVER, users should never use the embedded form.
148.Sh IPv6 SETUP
149Generally speaking,
150IPv6 connectivity is achieved in a fashion similar to that for IPv4.
151For native IPv6 setup,
152routers attach to the network either manually or using
153.Cm autoconf
154to connect to an ISP;
155hosts receive an address prefix from a router advertisement daemon such as
156.Xr rad 8
157and use
158.Cm autoconf
159for stateless address configuration (SLAAC).
160For setups which tunnel IPv6 over IPv4,
161see
162.Xr gif 4 .
163.Pp
164The INET6 and TUNNEL sections of
165.Xr ifconfig 8
166contain information relevant to IPv6 setups;
167settings can be made permanent using
168.Xr hostname.if 5
169files.
170Routers need to set the
171.Va net.inet6.ip6.forwarding
172.Xr sysctl 2 .
173.Sh SEE ALSO
174.Xr socket 2 ,
175.Xr icmp6 4 ,
176.Xr ip6 4 ,
177.Xr tcp 4 ,
178.Xr udp 4 ,
179.Xr hostname.if 5 ,
180.Xr ifconfig 8 ,
181.Xr rad 8
182.Sh STANDARDS
183.Rs
184.%A Tatsuya Jinmei
185.%A Atsushi Onoe
186.%D June 2000
187.%N draft-ietf-ipngwg-scopedaddr-format-02.txt
188.%O work in progress material
189.%R internet draft
190.%T "An Extension of Format for IPv6 Scoped Addresses"
191.Re
192.Pp
193.Rs
194.%A R. Gilligan
195.%A S. Thomson
196.%A J. Bound
197.%A J. McCann
198.%A W. Stevens
199.%D February 2003
200.%R RFC 3493
201.%T Basic Socket Interface Extensions for IPv6
202.Re
203.Pp
204.Rs
205.%A W. Stevens
206.%A M. Thomas
207.%A E. Nordmark
208.%A T. Jinmei
209.%D May 2003
210.%R RFC 3542
211.%T Advanced Sockets Application Programming Interface (API) for IPv6
212.Re
213.Sh HISTORY
214The implementation described herein appeared in WIDE/KAME project.
215.Sh CAVEATS
216It is advisable to explicitly reject all packets to your network
217not used by any of your interface prefixes.
218Otherwise packets that have a destination address belonging to your network
219may be routed back to your provider via the default route.
220Set a reject route for your assigned prefix:
221.Pp
222.Dl # route add -net 2001:db8::/48 ::1 -reject
223