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 Internet Protocol Security protocol
40 .Cd "options IPSEC_FILTERTUNNEL"
49 is a security protocol implemented within the Internet Protocol layer
50 of the networking stack.
52 is defined for both IPv4 and IPv6
57 is a set of protocols,
59 (for Encapsulating Security Payload)
61 (for Authentication Header),
64 (for IP Payload Compression Protocol)
65 that provide security services for IP datagrams.
66 AH both authenticates and guarantees the integrity of an IP packet
67 by attaching a cryptographic checksum computed using one-way hash functions.
68 ESP, in addition, prevents unauthorized parties from reading the payload of
69 an IP packet by also encrypting it.
70 IPComp tries to increase communication performance by compressing IP payload,
71 thus reducing the amount of data sent.
72 This will help nodes on slow links but with enough computing power.
74 operates in one of two modes: transport mode or tunnel mode.
75 Transport mode is used to protect peer-to-peer communication between end nodes.
76 Tunnel mode encapsulates IP packets within other IP packets
77 and is designed for security gateways such as VPN endpoints.
79 System configuration requires the
83 The packets can be passed to a virtual
86 to perform packet filtering before outbound encryption and after decapsulation
89 To properly filter on the inner packets of an
91 tunnel with firewalls, add
92 .Cd "options IPSEC_FILTERTUNNEL"
93 to the kernel configuration file.
97 is controlled by a key management and policy engine,
98 that reside in the operating system kernel.
100 is the process of associating keys with security associations, also
102 Policy management dictates when new security
103 associations created or destroyed.
105 The key management engine can be accessed from userland by using
110 socket API is defined in RFC2367.
112 The policy engine is controlled by an extension to the
119 The kernel implements
120 an extended version of the
122 interface and allows the programmer to define IPsec policies
123 which are similar to the per-packet filters.
126 interface is used to define per-socket behavior, and
128 interface is used to define host-wide default behavior.
130 The kernel code does not implement a dynamic encryption key exchange protocol
132 (Internet Key Exchange).
133 Key exchange protocols are beyond what is necessary in the kernel and
134 should be implemented as daemon processes which call the
137 .Ss Policy management
138 IPsec policies can be managed in one of two ways, either by
139 configuring per-socket policies using the
141 system calls, or by configuring kernel level packet filter-based
146 you can define IPsec policies against packets using rules similar to packet
152 When setting policies using the
156 option instructs the system to use its default policy, as
157 explained below, for processing packets.
158 The following sysctl variables are available for configuring the
159 system's IPsec behavior.
160 The variables can have one of two values.
165 which means that if there is a security association then use it but if
166 there is not then the packets are not processed by IPsec.
171 which requires that a security association must exist for the packets
172 to move, and not be dropped.
173 These terms are defined in
174 .Xr ipsec_set_policy 8 .
175 .Bl -column net.inet6.ipsec6.esp_trans_deflev integerxxx
176 .It Sy "Name Type Changeable"
177 .It "net.inet.ipsec.esp_trans_deflev integer yes"
178 .It "net.inet.ipsec.esp_net_deflev integer yes"
179 .It "net.inet.ipsec.ah_trans_deflev integer yes"
180 .It "net.inet.ipsec.ah_net_deflev integer yes"
181 .It "net.inet6.ipsec6.esp_trans_deflev integer yes"
182 .It "net.inet6.ipsec6.esp_net_deflev integer yes"
183 .It "net.inet6.ipsec6.ah_trans_deflev integer yes"
184 .It "net.inet6.ipsec6.ah_net_deflev integer yes"
187 If the kernel does not find a matching, system wide, policy then the
188 default value is applied.
189 The system wide default policy is specified
196 which asks the kernel to drop the packet.
200 .Bl -column net.inet6.ipsec6.def_policy integerxxx
201 .It Sy "Name Type Changeable"
202 .It "net.inet.ipsec.def_policy integer yes"
203 .It "net.inet6.ipsec6.def_policy integer yes"
206 .Ss Miscellaneous sysctl variables
209 protocols are configured for use, all protocols are included in the system.
210 To selectively enable/disable protocols, use
212 .Bl -column net.inet.ipcomp.ipcomp_enable
213 .It Sy "Name Default"
214 .It "net.inet.esp.esp_enable On"
215 .It "net.inet.ah.ah_enable On"
216 .It "net.inet.ipcomp.ipcomp_enable Off"
219 In addition the following variables are accessible via
221 for tweaking the kernel's IPsec behavior:
222 .Bl -column net.inet6.ipsec6.inbonud_call_ike integerxxx
223 .It Sy "Name Type Changeable"
224 .It "net.inet.ipsec.ah_cleartos integer yes"
225 .It "net.inet.ipsec.ah_offsetmask integer yes"
226 .It "net.inet.ipsec.dfbit integer yes"
227 .It "net.inet.ipsec.ecn integer yes"
228 .It "net.inet.ipsec.debug integer yes"
229 .It "net.inet6.ipsec6.ecn integer yes"
230 .It "net.inet6.ipsec6.debug integer yes"
233 The variables are interpreted as follows:
235 .It Li ipsec.ah_cleartos
236 If set to non-zero, the kernel clears the type-of-service field in the IPv4 header
237 during AH authentication data computation.
238 This variable is used to get current systems to inter-operate with devices that
239 implement RFC1826 AH.
240 It should be set to non-zero
241 (clear the type-of-service field)
242 for RFC2402 conformance.
243 .It Li ipsec.ah_offsetmask
244 During AH authentication data computation, the kernel will include a
245 16bit fragment offset field
246 (including flag bits)
247 in the IPv4 header, after computing logical AND with the variable.
248 The variable is used for inter-operating with devices that
249 implement RFC1826 AH.
250 It should be set to zero
251 (clear the fragment offset field during computation)
252 for RFC2402 conformance.
254 This variable configures the kernel behavior on IPv4 IPsec tunnel encapsulation.
255 If set to 0, the DF bit on the outer IPv4 header will be cleared while
256 1 means that the outer DF bit is set regardless from the inner DF bit and
257 2 indicates that the DF bit is copied from the inner header to the
259 The variable is supplied to conform to RFC2401 chapter 6.1.
261 If set to non-zero, IPv4 IPsec tunnel encapsulation/decapsulation behavior will
263 (explicit congestion notification),
265 .Li draft-ietf-ipsec-ecn-02.txt .
267 talks more about the behavior.
269 If set to non-zero, debug messages will be generated via
275 tree have similar meanings to those described above.
280 protocol acts as a plug-in to the
284 protocols and therefore supports most of the protocols defined upon
285 those IP-layer protocols.
290 protocols may behave differently with
298 routines from looking into the IP payload.
303 .Xr ipsec_set_policy 3 ,
315 .%T "IP Authentication Header"
321 .%T "IP Encapsulating Security Payload (ESP)"
326 .%A Daniel L. McDonald
329 .%T "PF_KEY Key Management API, Version 2"
336 .%T "A Simple IP Security API Extension to BSD Sockets"
338 .%N "draft-mcdonald-simple-ipsec-api-03.txt"
339 .%O work in progress material
344 implementation appeared in the WIDE/KAME IPv6/IPsec stack.
348 a fully locked IPsec implementation called fast_ipsec was brought in.
349 The protocols drew heavily on the
351 implementation of the
354 The policy management code was derived from the
360 The fast_ipsec implementation lacked
362 support but made use of the
369 support was added to fast_ipsec.
370 After this the old KAME IPsec implementation was dropped and fast_ipsec
371 became what now is the only
376 There is no single standard for the policy engine API,
377 so the policy engine API described herein is just for this implementation.
379 AH and tunnel mode encapsulation may not work as you might expect.
380 If you configure inbound
382 policy with an AH tunnel or any IPsec encapsulating policy with AH
384 .Dq Li esp/tunnel/A-B/use ah/transport/A-B/require ) ,
385 tunnelled packets will be rejected.
386 This is because the policy check is enforced on the inner packet on reception,
387 and AH authenticates encapsulating
389 packet, not the encapsulated
392 (so for the receiving kernel there is no sign of authenticity).
393 The issue will be solved when we revamp our policy engine to keep all the
394 packet decapsulation history.
396 When a large database of security associations or policies is present
403 sockets may fail due to lack of space.
404 Increasing the socket buffer
405 size may alleviate this problem.
409 protocol support is currently broken.
411 This documentation needs more review.