1 .\" $NetBSD: ipsec.4,v 1.30 2006/10/11 10:14:31 hubertf Exp $
2 .\" $KAME: ipsec.4,v 1.17 2001/06/27 15:25:10 itojun Exp $
4 .\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5 .\" All rights reserved.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
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.
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
36 .Nd IP security protocol
44 .Cd options IPSEC_NAT_T
45 .Cd options IPSEC_DEBUG
48 is a security protocol in Internet Protocol (IP) layer.
50 is defined for both IPv4 and IPv6
57 consists of two sub-protocols:
60 .It Em Encapsulated Security Payload Pq ESP
61 protects IP payload from wire-tapping (interception) by encrypting it with
62 secret key cryptography algorithms.
63 .It Em Authentication Header Pq AH
64 guarantees integrity of IP packet
65 and protects it from intermediate alteration or impersonation,
66 by attaching cryptographic checksum computed by one-way hash functions.
70 has two operation modes:
74 is for protecting peer-to-peer communication between end nodes.
76 includes IP-in-IP encapsulation operation
77 and is designed for security gateways, as in Virtual Private Network
82 The following kernel options are available:
85 Includes support for the
90 secret key management part,
91 policy management part,
95 Kernel binary will not be subject to export control in most of countries,
98 For example, it should be okay to export it from the United States of America.
102 are orthogonal so you can get IPv4-only kernel with IPsec support,
103 IPv4/v6 dual support kernel without IPsec, and so forth.
106 at this moment, but it should not.
107 .It Cd options IPSEC_DEBUG
108 Enables debugging code in
113 .It Cd options IPSEC_ESP
119 will enable source code that is subject to export control in some countries
120 .Pq including the United States ,
121 and compiled kernel binary will be subject to certain restriction.
124 .It Cd options IPSEC_NAT_T
127 Network Address Translator Traversal (NAT-T), as described in RFCs 3947
129 This feature might be patent-encumbered in some countries.
138 is controlled by key management engine and policy engine,
139 in the operating system kernel.
141 Key management engine can be accessed from the userland by using
146 socket API is defined in RFC2367.
148 Policy engine can be controlled by extended part of
155 The kernel implements
158 interface, and allows you to define IPsec policy like per-packet filters.
160 interface is used to define per-socket behavior, and
162 interface is used to define host-wide default behavior.
164 The kernel code does not implement dynamic encryption key exchange protocol
166 .Pq Internet Key Exchange .
167 That should be implemented as userland programs
168 .Pq usually as daemons ,
169 by using the above described APIs.
171 .Ss Policy management
172 The kernel implements experimental policy management code.
173 You can manage the IPsec policy in two ways.
174 One is to configure per-socket policy using
176 The other is to configure kernel packet filter-based policy using
180 In both cases, IPsec policy must be specified with syntax described in
181 .Xr ipsec_set_policy 3 .
185 you can define IPsec policy in per-socket basis.
186 You can enforce particular IPsec policy onto packets that go through
191 you can define IPsec policy against packets,
192 using sort of packet filtering rule.
199 policy is allowed for use with
201 By configuring policy to
203 you can refer system-wide
205 variable for default settings.
206 The following variables are available.
215 .Bl -column net.inet6.ipsec6.esp_trans_deflev integerxxx
216 .It Sy Name Ta Sy Type Ta Sy Changeable
217 .It net.inet.ipsec.esp_trans_deflev Ta integer Ta yes
218 .It net.inet.ipsec.esp_net_deflev Ta integer Ta yes
219 .It net.inet.ipsec.ah_trans_deflev Ta integer Ta yes
220 .It net.inet.ipsec.ah_net_deflev Ta integer Ta yes
221 .It net.inet6.ipsec6.esp_trans_deflev Ta integer Ta yes
222 .It net.inet6.ipsec6.esp_net_deflev Ta integer Ta yes
223 .It net.inet6.ipsec6.ah_trans_deflev Ta integer Ta yes
224 .It net.inet6.ipsec6.ah_net_deflev Ta integer Ta yes
227 If kernel finds no matching policy system wide default value is applied.
228 System wide default is specified by the following
234 which asks the kernel to drop the packet.
238 .Bl -column net.inet6.ipsec6.esp_trans_deflev integerxxx
239 .It Sy Name Ta Sy Type Ta Sy Changeable
240 .It net.inet.ipsec.def_policy Ta integer Ta yes
241 .It net.inet6.ipsec6.def_policy Ta integer Ta yes
244 .Ss Miscellaneous sysctl variables
245 The following variables are accessible via
247 for tweaking kernel IPsec behavior:
248 .Bl -column net.inet6.ipsec6.esp_trans_deflev integerxxx
249 .It Sy Name Ta Sy Type Ta Sy Changeable
250 .It net.inet.ipsec.ah_cleartos Ta integer Ta yes
251 .It net.inet.ipsec.ah_offsetmask Ta integer Ta yes
252 .It net.inet.ipsec.dfbit Ta integer Ta yes
253 .It net.inet.ipsec.ecn Ta integer Ta yes
254 .It net.inet.ipsec.debug Ta integer Ta yes
255 .It net.inet6.ipsec6.ecn Ta integer Ta yes
256 .It net.inet6.ipsec6.debug Ta integer Ta yes
259 The variables are interpreted as follows:
260 .Bl -tag -width "123456"
261 .It Li ipsec.ah_cleartos
262 If set to non-zero, the kernel clears type-of-service field in the IPv4 header
263 during AH authentication data computation.
264 The variable is for tweaking AH behavior to interoperate with devices that
265 implement RFC1826 AH.
266 It should be set to non-zero
267 .Pq clear the type-of-service field
268 for RFC2402 conformance.
269 .It Li ipsec.ah_offsetmask
270 During AH authentication data computation, the kernel will include
271 16bit fragment offset field
272 .Pq including flag bits
273 in IPv4 header, after computing logical AND with the variable.
274 The variable is for tweaking AH behavior to interoperate with devices that
275 implement RFC1826 AH.
276 It should be set to zero
277 .Pq clear the fragment offset field during computation
278 for RFC2402 conformance.
280 The variable configures the kernel behavior on IPv4 IPsec tunnel encapsulation.
281 If set to 0, DF bit on the outer IPv4 header will be cleared.
282 1 means that the outer DF bit is set regardless from the inner DF bit.
283 2 means that the DF bit is copied from the inner header to the outer.
284 The variable is supplied to conform to RFC2401 chapter 6.1.
286 If set to non-zero, IPv4 IPsec tunnel encapsulation/decapsulation behavior will
288 .Pq explicit congestion notification ,
290 .Li draft-ietf-ipsec-ecn-02.txt .
292 talks more about the behavior.
294 If set to non-zero, debug messages will be generated via
300 tree has similar meaning as the
307 protocol works like plug-in to
314 supports most of the protocols defined upon those IP-layer protocols.
315 Some of the protocols, like
319 may behave differently with
327 routines from looking into IP payload.
332 .Xr ipsec_set_policy 3 ,
342 .%A Daniel L. McDonald
345 .%T "PF_KEY Key Management API, Version 2"
350 The implementation described herein appeared in WIDE/KAME IPv6/IPsec stack.
352 The IPsec support is subject to change as the IPsec protocols develop.
354 There is no single standard for policy engine API,
355 so the policy engine API described herein is just for KAME implementation.
357 AH and tunnel mode encapsulation may not work as you might expect.
358 If you configure inbound
360 policy against AH tunnel or any IPsec encapsulating policy with AH
363 .Dq Li esp/tunnel/A-B/use ah/transport/A-B/require
365 tunneled packets will be rejected.
366 This is because we enforce policy check on inner packet on reception,
367 and AH authenticates encapsulating
369 packet, not the encapsulated
373 so for the receiving kernel there's no sign of authenticity
375 The issue will be solved when we revamp our policy engine to keep all the
376 packet decapsulation history.
378 Under certain condition,
379 truncated result may be raised from the kernel
387 This occurs if there are too many database entries in the kernel
388 and socket buffer for the
390 socket is insufficient.
391 If you manipulate many IPsec key/policy database entries,
392 increase the size of socket buffer or use