1 .\" $KAME: ipsec.4,v 1.17 2001/06/27 15:25:10 itojun Exp $
3 .\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. Neither the name of the project nor the names of its contributors
15 .\" may be used to endorse or promote products derived from this software
16 .\" without specific prior written permission.
18 .\" THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 .Nd IP security protocol
44 is a security protocol implemented within the Internet Protocol layer
47 is defined for both IPv4 and IPv6
52 contains two protocols,
53 ESP, the encapsulated security payload protocol and
54 AH, the authentication header protocol.
55 ESP prevents unauthorized parties from reading the payload of an IP packet
56 by encrypting it using
57 secret key cryptography algorithms.
58 AH both authenticates guarantees the integrity of an IP packet
59 by attaching a cryptographic checksum computed using one-way hash functions.
61 has operates in one of two modes: transport mode or tunnel mode.
62 Transport mode is used to protect peer-to-peer communication between end nodes.
63 Tunnel mode encapsulates IP packets within other IP packets
64 and is designed for security gateways such as VPN endpoints.
68 is controlled by a key management and policy engine,
69 that reside in the operating system kernel. Key management
70 is the process of associating keys with security associations, also
71 know as SAs. Policy management dictates when new security
72 associations created or destroyed.
74 The key management engine can be accessed from userland by using
79 socket API is defined in RFC2367.
81 The policy engine is controlled by an extension to the
89 an extended version of the
91 interface, and allows the programmer to define IPsec policies
92 which are similar to the per-packet filters. The
94 interface is used to define per-socket behavior, and
96 interface is used to define host-wide default behavior.
98 The kernel code does not implement a dynamic encryption key exchange protocol
100 (Internet Key Exchange).
101 Key exchange protocols are beyond what is necessary in the kernel and
102 should be implemented as daemon processes which call the
105 .Ss Policy management
106 IPsec policies can be managed in one of two ways, either by
107 configuring per-socket policies using the
109 system calls, or by configuring kernel level packet filter-based
115 In either case, IPsec policies must be specified using the syntax described in
116 .Xr ipsec_set_policy 3 .
119 man page for instructions on its use.
121 When setting policies using the
125 option you can have the system use its default policy, explained
126 below, for processing packets.
127 The following sysctl variables are available for configuring the
128 system's IPsec behavior. The variables can have one of two values.
133 which means that if there is a security association then use it but if
134 there is not then the packets are not processed by IPsec. The value
138 which requires that a security association must exist for the packets
139 to move, and not be dropped. These terms are defined in
140 .Xr ipsec_set_policy 8 .
141 .Bl -column net.inet6.ipsec6.esp_trans_deflev integerxxx
142 .It Sy "Name Type Changeable"
143 .It "net.inet.ipsec.esp_trans_deflev integer yes"
144 .It "net.inet.ipsec.esp_net_deflev integer yes"
145 .It "net.inet.ipsec.ah_trans_deflev integer yes"
146 .It "net.inet.ipsec.ah_net_deflev integer yes"
147 .It "net.inet6.ipsec6.esp_trans_deflev integer yes"
148 .It "net.inet6.ipsec6.esp_net_deflev integer yes"
149 .It "net.inet6.ipsec6.ah_trans_deflev integer yes"
150 .It "net.inet6.ipsec6.ah_net_deflev integer yes"
153 If the kernel does not find a matching, system wide, policy then the
154 default value is applied. The system wide default policy is specified
161 which asks the kernel to drop the packet.
165 .Bl -column net.inet6.ipsec6.def_policy integerxxx
166 .It Sy "Name Type Changeable"
167 .It "net.inet.ipsec.def_policy integer yes"
168 .It "net.inet6.ipsec6.def_policy integer yes"
171 .Ss Miscellaneous sysctl variables
172 The following variables are accessible via
174 for tweaking the kernel's IPsec behavior:
175 .Bl -column net.inet6.ipsec6.inbonud_call_ike integerxxx
176 .It Sy "Name Type Changeable"
177 .It "net.inet.ipsec.ah_cleartos integer yes"
178 .It "net.inet.ipsec.ah_offsetmask integer yes"
179 .It "net.inet.ipsec.dfbit integer yes"
180 .It "net.inet.ipsec.ecn integer yes"
181 .It "net.inet.ipsec.debug integer yes"
182 .It "net.inet6.ipsec6.ecn integer yes"
183 .It "net.inet6.ipsec6.debug integer yes"
186 The variables are interpreted as follows:
188 .It Li ipsec.ah_cleartos
189 If set to non-zero, the kernel clears the type-of-service field in the IPv4 header
190 during AH authentication data computation.
191 This variable is used to get current systems to inter-operate with devices that
192 implement RFC1826 AH.
193 It should be set to non-zero
194 (clear the type-of-service field)
195 for RFC2402 conformance.
196 .It Li ipsec.ah_offsetmask
197 During AH authentication data computation, the kernel will include a
198 16bit fragment offset field
199 (including flag bits)
200 in the IPv4 header, after computing logical AND with the variable.
201 The variable is used for inter-operating with devices that
202 implement RFC1826 AH.
203 It should be set to zero
204 (clear the fragment offset field during computation)
205 for RFC2402 conformance.
207 This variable configures the kernel behavior on IPv4 IPsec tunnel encapsulation.
208 If set to 0, the DF bit on the outer IPv4 header will be cleared while
209 1 means that the outer DF bit is set regardless from the inner DF bit and
210 2 indicates that the DF bit is copied from the inner header to the
212 The variable is supplied to conform to RFC2401 chapter 6.1.
214 If set to non-zero, IPv4 IPsec tunnel encapsulation/decapsulation behavior will
216 (explicit congestion notification),
218 .Li draft-ietf-ipsec-ecn-02.txt .
220 talks more about the behavior.
222 If set to non-zero, debug messages will be generated via
228 tree have similar meanings to those described above.
233 protocol acts as a plug-in to the
237 protocols and therefore supports most of the protocols defined upon
238 those IP-layer protocols. The
242 protocols may behave differently with
250 routines from looking into the IP payload.
255 .Xr ipsec_set_policy 3 ,
265 .%T "IP Authentication Header"
271 .%T "IP Encapsulating Security Payload (ESP)"
276 .%A Daniel L. McDonald
279 .%T "PF_KEY Key Management API, Version 2"
286 .%T "A Simple IP Security API Extension to BSD Sockets"
288 .%N "draft-mcdonald-simple-ipsec-api-03.txt"
289 .%O work in progress material
292 The implementation described herein appeared in WIDE/KAME IPv6/IPsec stack.
294 The IPsec support is subject to change as the IPsec protocols develop.
296 There is no single standard for the policy engine API,
297 so the policy engine API described herein is just for KAME implementation.
299 AH and tunnel mode encapsulation may not work as you might expect.
300 If you configure inbound
302 policy with an AH tunnel or any IPsec encapsulating policy with AH
304 .Dq Li esp/tunnel/A-B/use ah/transport/A-B/require ) ,
305 tunnelled packets will be rejected.
306 This is because the policy check is enforced on the inner packet on reception,
307 and AH authenticates encapsulating
309 packet, not the encapsulated
312 (so for the receiving kernel there is no sign of authenticity).
313 The issue will be solved when we revamp our policy engine to keep all the
314 packet decapsulation history.
316 When a large database of security associations or policies is present
323 sockets may fail due to lack of space. Increasing the socket buffer
324 size may alleviate this problem.