Fix another path
[dragonfly.git] / share / man / man4 / ipsec.4
1 .\"     $FreeBSD: src/share/man/man4/ipsec.4,v 1.3.2.10 2001/12/17 11:30:12 ru Exp $
2 .\"     $DragonFly: src/share/man/man4/ipsec.4,v 1.3 2007/11/23 23:16:37 swildner Exp $
3 .\"     $KAME: ipsec.4,v 1.17 2001/06/27 15:25:10 itojun Exp $
4 .\"
5 .\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6 .\" All rights reserved.
7 .\"
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\"    notice, this list of conditions and the following disclaimer in the
15 .\"    documentation and/or other materials provided with the distribution.
16 .\" 3. Neither the name of the project nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .Dd January 29, 1999
33 .Dt IPSEC 4
34 .Os
35 .Sh NAME
36 .Nm ipsec
37 .Nd IP security protocol
38 .Sh SYNOPSIS
39 .In sys/types.h
40 .In netinet/in.h
41 .In netinet6/ipsec.h
42 .Sh DESCRIPTION
43 .Nm
44 is a security protocol in Internet Protocol layer.
45 .Nm
46 is defined for both IPv4 and IPv6
47 .Xr ( inet 4
48 and
49 .Xr inet6 4 ) .
50 .Nm
51 consists of two sub-protocols, namely
52 ESP
53 (encapsulated security payload)
54 and AH
55 (authentication header).
56 ESP protects IP payload from wire-tapping by encrypting it by
57 secret key cryptography algorithms.
58 AH guarantees integrity of IP packet
59 and protects it from intermediate alteration or impersonation,
60 by attaching cryptographic checksum computed by one-way hash functions.
61 .Nm
62 has two operation modes: transport mode and tunnel mode.
63 Transport mode is for protecting peer-to-peer communication between end nodes.
64 Tunnel mode includes IP-in-IP encapsulation operation
65 and is designed for security gateways, like VPN configurations.
66 .\"
67 .Ss Kernel interface
68 .Nm
69 is controlled by key management engine and policy engine,
70 in the operating system kernel.
71 .Pp
72 Key management engine can be accessed from the userland by using
73 .Dv PF_KEY
74 sockets.
75 The
76 .Dv PF_KEY
77 socket API is defined in RFC 2367.
78 .Pp
79 Policy engine can be controlled by extended part of
80 .Dv PF_KEY
81 API,
82 .Xr setsockopt 2
83 operations, and
84 .Xr sysctl 3
85 interface.
86 The kernel implements
87 extended version of
88 .Dv PF_KEY
89 interface, and allows you to define IPsec policy like per-packet filters.
90 .Xr setsockopt 2
91 interface is used to define per-socket behavior, and
92 .Xr sysctl 3
93 interface is used to define host-wide default behavior.
94 .Pp
95 The kernel code does not implement dynamic encryption key exchange protocol
96 like IKE
97 (Internet Key Exchange).
98 That should be implemented as userland programs
99 (usually as daemons),
100 by using the above described APIs.
101 .\"
102 .Ss Policy management
103 The kernel implements experimental policy management code.
104 You can manage the IPsec policy in two ways.
105 One is to configure per-socket policy using
106 .Xr setsockopt 2 .
107 The other is to configure kernel packet filter-based policy using
108 .Dv PF_KEY
109 interface, via
110 .Xr setkey 8 .
111 In both cases, IPsec policy must be specified with syntax described in
112 .Xr ipsec_set_policy 3 .
113 .Pp
114 With
115 .Xr setsockopt 2 ,
116 you can define IPsec policy in per-socket basis.
117 You can enforce particular IPsec policy onto packets that go through
118 particular socket.
119 .Pp
120 With
121 .Xr setkey 8
122 you can define IPsec policy against packets,
123 using sort of packet filtering rule.
124 Refer to
125 .Xr setkey 8
126 on how to use it.
127 .Pp
128 In the latter case,
129 .Dq Li default
130 policy is allowed for use with
131 .Xr setkey 8 .
132 By configuring policy to
133 .Li default ,
134 you can refer system-wide
135 .Xr sysctl 8
136 variable for default settings.
137 The following variables are available.
138 .Li 1
139 means
140 .Dq Li use ,
141 and
142 .Li 2
143 means
144 .Dq Li require
145 in the syntax.
146 .Bl -column net.inet6.ipsec6.esp_trans_deflev integerxxx
147 .It Sy "Name    Type    Changeable"
148 .It "net.inet.ipsec.esp_trans_deflev    integer yes"
149 .It "net.inet.ipsec.esp_net_deflev      integer yes"
150 .It "net.inet.ipsec.ah_trans_deflev     integer yes"
151 .It "net.inet.ipsec.ah_net_deflev       integer yes"
152 .It "net.inet6.ipsec6.esp_trans_deflev  integer yes"
153 .It "net.inet6.ipsec6.esp_net_deflev    integer yes"
154 .It "net.inet6.ipsec6.ah_trans_deflev   integer yes"
155 .It "net.inet6.ipsec6.ah_net_deflev     integer yes"
156 .El
157 .Pp
158 If kernel finds no matching policy system wide default value is applied.
159 System wide default is specified by the following
160 .Xr sysctl 8
161 variables.
162 .Li 0
163 means
164 .Dq Li discard
165 which asks the kernel to drop the packet.
166 .Li 1
167 means
168 .Dq Li none .
169 .Bl -column net.inet6.ipsec6.def_policy integerxxx
170 .It Sy "Name    Type    Changeable"
171 .It "net.inet.ipsec.def_policy  integer yes"
172 .It "net.inet6.ipsec6.def_policy        integer yes"
173 .El
174 .\"
175 .Ss Miscellaneous sysctl variables
176 The following variables are accessible via
177 .Xr sysctl 8 ,
178 for tweaking kernel IPsec behavior:
179 .Bl -column net.inet6.ipsec6.inbonud_call_ike integerxxx
180 .It Sy "Name    Type    Changeable"
181 .It "net.inet.ipsec.ah_cleartos integer yes"
182 .It "net.inet.ipsec.ah_offsetmask       integer yes"
183 .It "net.inet.ipsec.dfbit       integer yes"
184 .It "net.inet.ipsec.ecn integer yes"
185 .It "net.inet.ipsec.debug       integer yes"
186 .It "net.inet6.ipsec6.ecn       integer yes"
187 .It "net.inet6.ipsec6.debug     integer yes"
188 .El
189 .Pp
190 The variables are interpreted as follows:
191 .Bl -tag -width 6n
192 .It Li ipsec.ah_cleartos
193 If set to non-zero, the kernel clears type-of-service field in the IPv4 header
194 during AH authentication data computation.
195 The variable is for tweaking AH behavior to interoperate with devices that
196 implement RFC 1826 AH.
197 It should be set to non-zero
198 (clear the type-of-service field)
199 for RFC 2402 conformance.
200 .It Li ipsec.ah_offsetmask
201 During AH authentication data computation, the kernel will include
202 16bit fragment offset field
203 (including flag bits)
204 in IPv4 header, after computing logical AND with the variable.
205 The variable is for tweaking AH behavior to interoperate with devices that
206 implement RFC 1826 AH.
207 It should be set to zero
208 (clear the fragment offset field during computation)
209 for RFC 2402 conformance.
210 .It Li ipsec.dfbit
211 The variable configures the kernel behavior on IPv4 IPsec tunnel encapsulation.
212 If set to 0, DF bit on the outer IPv4 header will be cleared.
213 1 means that the outer DF bit is set regardless from the inner DF bit.
214 2 means that the DF bit is copied from the inner header to the outer.
215 The variable is supplied to conform to RFC 2401 chapter 6.1.
216 .It Li ipsec.ecn
217 If set to non-zero, IPv4 IPsec tunnel encapsulation/decapsulation behavior will
218 be friendly to ECN
219 (explicit congestion notification),
220 as documented in
221 .Li draft-ietf-ipsec-ecn-02.txt .
222 .Xr gif 4
223 talks more about the behavior.
224 .It Li ipsec.debug
225 If set to non-zero, debug messages will be generated via
226 .Xr syslog 3 .
227 .El
228 .Pp
229 Variables under
230 .Li net.inet6.ipsec6
231 tree has similar meaning as the
232 .Li net.inet.ipsec
233 counterpart.
234 .\"
235 .Sh PROTOCOLS
236 The
237 .Nm
238 protocol works like plug-in to
239 .Xr inet 4
240 and
241 .Xr inet6 4
242 protocols.
243 Therefore,
244 .Nm
245 supports most of the protocols defined upon those IP-layer protocols.
246 Some of the protocols, like
247 .Xr icmp 4
248 or
249 .Xr icmp6 4 ,
250 may behave differently with
251 .Nm .
252 This is because
253 .Nm
254 can prevent
255 .Xr icmp 4
256 or
257 .Xr icmp6 4
258 routines from looking into IP payload.
259 .\"
260 .Sh SEE ALSO
261 .Xr ioctl 2 ,
262 .Xr socket 2 ,
263 .Xr ipsec_set_policy 3 ,
264 .Xr icmp6 4 ,
265 .Xr intro 4 ,
266 .Xr ip6 4 ,
267 .Xr setkey 8 ,
268 .Xr sysctl 8
269 .\".Xr racoon 8
270 .Sh STANDARDS
271 .Rs
272 .%A Daniel L. McDonald
273 .%A Craig Metz
274 .%A Bao G. Phan
275 .%T "PF_KEY Key Management API, Version 2"
276 .%R RFC
277 .%N 2367
278 .Re
279 .Pp
280 .Rs
281 .%A "D. L. McDonald"
282 .%T "A Simple IP Security API Extension to BSD Sockets"
283 .%R internet draft
284 .%N "draft-mcdonald-simple-ipsec-api-03.txt"
285 .%O work in progress material
286 .Re
287 .Sh HISTORY
288 The implementation described herein appeared in WIDE/KAME IPv6/IPsec stack.
289 .Sh BUGS
290 The IPsec support is subject to change as the IPsec protocols develop.
291 .Pp
292 There is no single standard for policy engine API,
293 so the policy engine API described herein is just for KAME implementation.
294 .Pp
295 AH and tunnel mode encapsulation may not work as you might expect.
296 If you configure inbound
297 .Dq require
298 policy against AH tunnel or any IPsec encapsulating policy with AH
299 (like
300 .Dq Li esp/tunnel/A-B/use ah/transport/A-B/require ) ,
301 tunnelled packets will be rejected.
302 This is because we enforce policy check on inner packet on reception,
303 and AH authenticates encapsulating
304 (outer)
305 packet, not the encapsulated
306 (inner)
307 packet
308 (so for the receiving kernel there's no sign of authenticity).
309 The issue will be solved when we revamp our policy engine to keep all the
310 packet decapsulation history.
311 .Pp
312 Under certain condition,
313 truncated result may be raised from the kernel
314 against
315 .Dv SADB_DUMP
316 and
317 .Dv SADB_SPDDUMP
318 operation on
319 .Dv PF_KEY
320 socket.
321 This occurs if there are too many database entries in the kernel
322 and socket buffer for the
323 .Dv PF_KEY
324 socket is insufficient.
325 If you manipulate many IPsec key/policy database entries,
326 increase the size of socket buffer.