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
43 .Cd "options IPSEC_DEBUG"
44 .Cd "options IPSEC_ESP"
45 .Cd "options IPSEC_FILTERGIF"
48 is a security protocol implemented within the Internet Protocol layer
51 is defined for both IPv4 and IPv6
56 contains two protocols,
57 ESP, the encapsulated security payload protocol and
58 AH, the authentication header protocol.
59 ESP prevents unauthorized parties from reading the payload of an IP packet
60 by encrypting it using
61 secret key cryptography algorithms.
62 AH both authenticates guarantees the integrity of an IP packet
63 by attaching a cryptographic checksum computed using one-way hash functions.
65 has operates in one of two modes: transport mode or tunnel mode.
66 Transport mode is used to protect peer-to-peer communication between end nodes.
67 Tunnel mode encapsulates IP packets within other IP packets
68 and is designed for security gateways such as VPN endpoints.
72 is controlled by a key management and policy engine,
73 that reside in the operating system kernel. Key management
74 is the process of associating keys with security associations, also
75 know as SAs. Policy management dictates when new security
76 associations created or destroyed.
78 The key management engine can be accessed from userland by using
83 socket API is defined in RFC2367.
85 The policy engine is controlled by an extension to the
93 an extended version of the
95 interface, and allows the programmer to define IPsec policies
96 which are similar to the per-packet filters. The
98 interface is used to define per-socket behavior, and
100 interface is used to define host-wide default behavior.
102 The kernel code does not implement a dynamic encryption key exchange protocol
104 (Internet Key Exchange).
105 Key exchange protocols are beyond what is necessary in the kernel and
106 should be implemented as daemon processes which call the
109 .Ss Policy management
110 IPsec policies can be managed in one of two ways, either by
111 configuring per-socket policies using the
113 system calls, or by configuring kernel level packet filter-based
119 In either case, IPsec policies must be specified using the syntax described in
120 .Xr ipsec_set_policy 3 .
123 man page for instructions on its use.
125 When setting policies using the
129 option you can have the system use its default policy, explained
130 below, for processing packets.
131 The following sysctl variables are available for configuring the
132 system's IPsec behavior. The variables can have one of two values.
137 which means that if there is a security association then use it but if
138 there is not then the packets are not processed by IPsec. The value
142 which requires that a security association must exist for the packets
143 to move, and not be dropped. These terms are defined in
144 .Xr ipsec_set_policy 8 .
145 .Bl -column net.inet6.ipsec6.esp_trans_deflev integerxxx
146 .It Sy "Name Type Changeable"
147 .It "net.inet.ipsec.esp_trans_deflev integer yes"
148 .It "net.inet.ipsec.esp_net_deflev integer yes"
149 .It "net.inet.ipsec.ah_trans_deflev integer yes"
150 .It "net.inet.ipsec.ah_net_deflev integer yes"
151 .It "net.inet6.ipsec6.esp_trans_deflev integer yes"
152 .It "net.inet6.ipsec6.esp_net_deflev integer yes"
153 .It "net.inet6.ipsec6.ah_trans_deflev integer yes"
154 .It "net.inet6.ipsec6.ah_net_deflev integer yes"
157 If the kernel does not find a matching, system wide, policy then the
158 default value is applied. The system wide default policy is specified
165 which asks the kernel to drop the packet.
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"
175 .Ss Miscellaneous sysctl variables
176 The following variables are accessible via
178 for tweaking the kernel's 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"
190 The variables are interpreted as follows:
192 .It Li ipsec.ah_cleartos
193 If set to non-zero, the kernel clears the type-of-service field in the IPv4 header
194 during AH authentication data computation.
195 This variable is used to get current systems to inter-operate with devices that
196 implement RFC1826 AH.
197 It should be set to non-zero
198 (clear the type-of-service field)
199 for RFC2402 conformance.
200 .It Li ipsec.ah_offsetmask
201 During AH authentication data computation, the kernel will include a
202 16bit fragment offset field
203 (including flag bits)
204 in the IPv4 header, after computing logical AND with the variable.
205 The variable is used for inter-operating with devices that
206 implement RFC1826 AH.
207 It should be set to zero
208 (clear the fragment offset field during computation)
209 for RFC2402 conformance.
211 This variable configures the kernel behavior on IPv4 IPsec tunnel encapsulation.
212 If set to 0, the DF bit on the outer IPv4 header will be cleared while
213 1 means that the outer DF bit is set regardless from the inner DF bit and
214 2 indicates that the DF bit is copied from the inner header to the
216 The variable is supplied to conform to RFC2401 chapter 6.1.
218 If set to non-zero, IPv4 IPsec tunnel encapsulation/decapsulation behavior will
220 (explicit congestion notification),
222 .Li draft-ietf-ipsec-ecn-02.txt .
224 talks more about the behavior.
226 If set to non-zero, debug messages will be generated via
232 tree have similar meanings to those described above.
237 protocol acts as a plug-in to the
241 protocols and therefore supports most of the protocols defined upon
242 those IP-layer protocols. The
246 protocols may behave differently with
254 routines from looking into the IP payload.
259 .Xr ipsec_set_policy 3 ,
270 .%T "IP Authentication Header"
276 .%T "IP Encapsulating Security Payload (ESP)"
281 .%A Daniel L. McDonald
284 .%T "PF_KEY Key Management API, Version 2"
291 .%T "A Simple IP Security API Extension to BSD Sockets"
293 .%N "draft-mcdonald-simple-ipsec-api-03.txt"
294 .%O work in progress material
297 The implementation described herein appeared in WIDE/KAME IPv6/IPsec stack.
299 The IPsec support is subject to change as the IPsec protocols develop.
301 There is no single standard for the policy engine API,
302 so the policy engine API described herein is just for KAME implementation.
304 AH and tunnel mode encapsulation may not work as you might expect.
305 If you configure inbound
307 policy with an AH tunnel or any IPsec encapsulating policy with AH
309 .Dq Li esp/tunnel/A-B/use ah/transport/A-B/require ) ,
310 tunnelled packets will be rejected.
311 This is because the policy check is enforced on the inner packet on reception,
312 and AH authenticates encapsulating
314 packet, not the encapsulated
317 (so for the receiving kernel there is no sign of authenticity).
318 The issue will be solved when we revamp our policy engine to keep all the
319 packet decapsulation history.
321 When a large database of security associations or policies is present
328 sockets may fail due to lack of space. Increasing the socket buffer
329 size may alleviate this problem.