]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man4/ipsec.4
This commit was generated by cvs2svn to compensate for changes in r159825,
[FreeBSD/FreeBSD.git] / share / man / man4 / ipsec.4
1 .\"     $KAME: ipsec.4,v 1.17 2001/06/27 15:25:10 itojun Exp $
2 .\"
3 .\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
4 .\" All rights reserved.
5 .\"
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
8 .\" are met:
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.
17 .\"
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
28 .\" SUCH DAMAGE.
29 .\"
30 .\" $FreeBSD$
31 .\"
32 .Dd February 14, 2006
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 implemented within the Internet Protocol layer
45 of the TCP/IP stack.
46 .Nm
47 is defined for both IPv4 and IPv6
48 .Xr ( inet 4
49 and
50 .Xr inet6 4 ) .
51 .Nm
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.
60 .Nm
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.
65 .\"
66 .Ss Kernel interface
67 .Nm
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.
73 .Pp
74 The key management engine can be accessed from userland by using
75 .Dv PF_KEY
76 sockets.
77 The
78 .Dv PF_KEY
79 socket API is defined in RFC2367.
80 .Pp
81 The policy engine is controlled by an extension to the
82 .Dv PF_KEY
83 API,
84 .Xr setsockopt 2
85 operations, and
86 .Xr sysctl 3
87 interface.
88 The kernel implements
89 an extended version of the
90 .Dv PF_KEY
91 interface, and allows the programmer to define IPsec policies
92 which are similar to the per-packet filters.  The
93 .Xr setsockopt 2
94 interface is used to define per-socket behavior, and
95 .Xr sysctl 3
96 interface is used to define host-wide default behavior.
97 .Pp
98 The kernel code does not implement a dynamic encryption key exchange protocol
99 such as IKE
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
103 .Nm APIs.
104 .\"
105 .Ss Policy management
106 IPsec policies can be managed in one of two ways, either by 
107 configuring per-socket policies using the
108 .Xr setsockopt 2 
109 system calls, or by configuring kernel level packet filter-based
110 policies using the
111 .Dv PF_KEY
112 interface, via the
113 .Xr setkey 8 
114 command.
115 In either case, IPsec policies must be specified using the syntax described in
116 .Xr ipsec_set_policy 3 .
117 Please refer to the
118 .Xr setkey 8
119 man page for instructions on its use.
120 .Pp
121 When setting policies using the
122 .Xr setkey 8
123 command the
124 .Dq Li default
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.
129 A
130 .Li 1
131 means
132 .Dq Li use ,
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
135 .Li 2
136 is synonymous with
137 .Dq Li require ,
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"
151 .El
152 .Pp
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
155 by the following
156 .Xr sysctl 8
157 variables.
158 .Li 0
159 means
160 .Dq Li discard
161 which asks the kernel to drop the packet.
162 .Li 1
163 means
164 .Dq Li none .
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"
169 .El
170 .\"
171 .Ss Miscellaneous sysctl variables
172 The following variables are accessible via
173 .Xr sysctl 8 ,
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"
184 .El
185 .Pp
186 The variables are interpreted as follows:
187 .Bl -tag -width 6n
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.
206 .It Li ipsec.dfbit
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
211 outer one.
212 The variable is supplied to conform to RFC2401 chapter 6.1.
213 .It Li ipsec.ecn
214 If set to non-zero, IPv4 IPsec tunnel encapsulation/decapsulation behavior will
215 be friendly to ECN
216 (explicit congestion notification),
217 as documented in
218 .Li draft-ietf-ipsec-ecn-02.txt .
219 .Xr gif 4
220 talks more about the behavior.
221 .It Li ipsec.debug
222 If set to non-zero, debug messages will be generated via
223 .Xr syslog 3 .
224 .El
225 .Pp
226 Variables under the
227 .Li net.inet6.ipsec6
228 tree have similar meanings to those described above.
229 .\"
230 .Sh PROTOCOLS
231 The
232 .Nm
233 protocol acts as a plug-in to the
234 .Xr inet 4
235 and
236 .Xr inet6 4
237 protocols and therefore supports most of the protocols defined upon
238 those IP-layer protocols.  The
239 .Xr icmp 4
240 and
241 .Xr icmp6 4 
242 protocols may behave differently with
243 .Nm 
244 because
245 .Nm
246 can prevent
247 .Xr icmp 4
248 or
249 .Xr icmp6 4
250 routines from looking into the IP payload.
251 .\"
252 .Sh SEE ALSO
253 .Xr ioctl 2 ,
254 .Xr socket 2 ,
255 .Xr ipsec_set_policy 3 ,
256 .Xr icmp6 4 ,
257 .Xr intro 4 ,
258 .Xr ip6 4 ,
259 .Xr setkey 8 ,
260 .Xr sysctl 8
261 .\".Xr racoon 8
262 .Rs
263 .%A "S. Kent"
264 .%A "R. Atkinson"
265 .%T "IP Authentication Header"
266 .%O "RFC 2404"
267 .Re
268 .Rs
269 .%A "S. Kent"
270 .%A "R. Atkinson"
271 .%T "IP Encapsulating Security Payload (ESP)"
272 .%O "RFC 2406"
273 .Re
274 .Sh STANDARDS
275 .Rs
276 .%A Daniel L. McDonald
277 .%A Craig Metz
278 .%A Bao G. Phan
279 .%T "PF_KEY Key Management API, Version 2"
280 .%R RFC
281 .%N 2367
282 .Re
283 .Pp
284 .Rs
285 .%A "D. L. McDonald"
286 .%T "A Simple IP Security API Extension to BSD Sockets"
287 .%R internet draft
288 .%N "draft-mcdonald-simple-ipsec-api-03.txt"
289 .%O work in progress material
290 .Re
291 .Sh HISTORY
292 The implementation described herein appeared in WIDE/KAME IPv6/IPsec stack.
293 .Sh BUGS
294 The IPsec support is subject to change as the IPsec protocols develop.
295 .Pp
296 There is no single standard for the policy engine API,
297 so the policy engine API described herein is just for KAME implementation.
298 .Pp
299 AH and tunnel mode encapsulation may not work as you might expect.
300 If you configure inbound
301 .Dq require
302 policy with an AH tunnel or any IPsec encapsulating policy with AH
303 (like
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
308 (outer)
309 packet, not the encapsulated
310 (inner)
311 packet
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.
315 .Pp
316 When a large database of security associations or policies is present
317 in the kernel the
318 .Dv SADB_DUMP
319 and
320 .Dv SADB_SPDDUMP
321 operations on
322 .Dv PF_KEY
323 sockets may fail due to lack of space.  Increasing the socket buffer
324 size may alleviate this problem.