]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man4/ipsec.4
This commit was generated by cvs2svn to compensate for changes in r161651,
[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 August 24, 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 .Cd "options IPSEC"
43 .Cd "options IPSEC_DEBUG"
44 .Cd "options IPSEC_ESP"
45 .Cd "options IPSEC_FILTERGIF"
46 .Sh DESCRIPTION
47 .Nm
48 is a security protocol implemented within the Internet Protocol layer
49 of the TCP/IP stack.
50 .Nm
51 is defined for both IPv4 and IPv6
52 .Xr ( inet 4
53 and
54 .Xr inet6 4 ) .
55 .Nm
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.
64 .Nm
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.
69 .\"
70 .Ss Kernel interface
71 .Nm
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.
77 .Pp
78 The key management engine can be accessed from userland by using
79 .Dv PF_KEY
80 sockets.
81 The
82 .Dv PF_KEY
83 socket API is defined in RFC2367.
84 .Pp
85 The policy engine is controlled by an extension to the
86 .Dv PF_KEY
87 API,
88 .Xr setsockopt 2
89 operations, and
90 .Xr sysctl 3
91 interface.
92 The kernel implements
93 an extended version of the
94 .Dv PF_KEY
95 interface, and allows the programmer to define IPsec policies
96 which are similar to the per-packet filters.  The
97 .Xr setsockopt 2
98 interface is used to define per-socket behavior, and
99 .Xr sysctl 3
100 interface is used to define host-wide default behavior.
101 .Pp
102 The kernel code does not implement a dynamic encryption key exchange protocol
103 such as IKE
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
107 .Nm APIs.
108 .\"
109 .Ss Policy management
110 IPsec policies can be managed in one of two ways, either by 
111 configuring per-socket policies using the
112 .Xr setsockopt 2 
113 system calls, or by configuring kernel level packet filter-based
114 policies using the
115 .Dv PF_KEY
116 interface, via the
117 .Xr setkey 8 
118 command.
119 In either case, IPsec policies must be specified using the syntax described in
120 .Xr ipsec_set_policy 3 .
121 Please refer to the
122 .Xr setkey 8
123 man page for instructions on its use.
124 .Pp
125 When setting policies using the
126 .Xr setkey 8
127 command the
128 .Dq Li default
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.
133 A
134 .Li 1
135 means
136 .Dq Li use ,
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
139 .Li 2
140 is synonymous with
141 .Dq Li require ,
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"
155 .El
156 .Pp
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
159 by the following
160 .Xr sysctl 8
161 variables.
162 .Li 0
163 means
164 .Dq Li discard
165 which asks the kernel to drop the packet.
166 .Li 1
167 means
168 .Dq Li none .
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"
173 .El
174 .\"
175 .Ss Miscellaneous sysctl variables
176 The following variables are accessible via
177 .Xr sysctl 8 ,
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"
188 .El
189 .Pp
190 The variables are interpreted as follows:
191 .Bl -tag -width 6n
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.
210 .It Li ipsec.dfbit
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
215 outer one.
216 The variable is supplied to conform to RFC2401 chapter 6.1.
217 .It Li ipsec.ecn
218 If set to non-zero, IPv4 IPsec tunnel encapsulation/decapsulation behavior will
219 be friendly to ECN
220 (explicit congestion notification),
221 as documented in
222 .Li draft-ietf-ipsec-ecn-02.txt .
223 .Xr gif 4
224 talks more about the behavior.
225 .It Li ipsec.debug
226 If set to non-zero, debug messages will be generated via
227 .Xr syslog 3 .
228 .El
229 .Pp
230 Variables under the
231 .Li net.inet6.ipsec6
232 tree have similar meanings to those described above.
233 .\"
234 .Sh PROTOCOLS
235 The
236 .Nm
237 protocol acts as a plug-in to the
238 .Xr inet 4
239 and
240 .Xr inet6 4
241 protocols and therefore supports most of the protocols defined upon
242 those IP-layer protocols.  The
243 .Xr icmp 4
244 and
245 .Xr icmp6 4 
246 protocols may behave differently with
247 .Nm 
248 because
249 .Nm
250 can prevent
251 .Xr icmp 4
252 or
253 .Xr icmp6 4
254 routines from looking into the IP payload.
255 .\"
256 .Sh SEE ALSO
257 .Xr ioctl 2 ,
258 .Xr socket 2 ,
259 .Xr ipsec_set_policy 3 ,
260 .Xr fast_ipsec 4 ,
261 .Xr icmp6 4 ,
262 .Xr intro 4 ,
263 .Xr ip6 4 ,
264 .Xr setkey 8 ,
265 .Xr sysctl 8
266 .\".Xr racoon 8
267 .Rs
268 .%A "S. Kent"
269 .%A "R. Atkinson"
270 .%T "IP Authentication Header"
271 .%O "RFC 2404"
272 .Re
273 .Rs
274 .%A "S. Kent"
275 .%A "R. Atkinson"
276 .%T "IP Encapsulating Security Payload (ESP)"
277 .%O "RFC 2406"
278 .Re
279 .Sh STANDARDS
280 .Rs
281 .%A Daniel L. McDonald
282 .%A Craig Metz
283 .%A Bao G. Phan
284 .%T "PF_KEY Key Management API, Version 2"
285 .%R RFC
286 .%N 2367
287 .Re
288 .Pp
289 .Rs
290 .%A "D. L. McDonald"
291 .%T "A Simple IP Security API Extension to BSD Sockets"
292 .%R internet draft
293 .%N "draft-mcdonald-simple-ipsec-api-03.txt"
294 .%O work in progress material
295 .Re
296 .Sh HISTORY
297 The implementation described herein appeared in WIDE/KAME IPv6/IPsec stack.
298 .Sh BUGS
299 The IPsec support is subject to change as the IPsec protocols develop.
300 .Pp
301 There is no single standard for the policy engine API,
302 so the policy engine API described herein is just for KAME implementation.
303 .Pp
304 AH and tunnel mode encapsulation may not work as you might expect.
305 If you configure inbound
306 .Dq require
307 policy with an AH tunnel or any IPsec encapsulating policy with AH
308 (like
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
313 (outer)
314 packet, not the encapsulated
315 (inner)
316 packet
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.
320 .Pp
321 When a large database of security associations or policies is present
322 in the kernel the
323 .Dv SADB_DUMP
324 and
325 .Dv SADB_SPDDUMP
326 operations on
327 .Dv PF_KEY
328 sockets may fail due to lack of space.  Increasing the socket buffer
329 size may alleviate this problem.