xref: /freebsd/share/man/man4/ipsec.4 (revision 99f3b482da15db6f2ae4702d592b53dd36d4cf55)
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
48is a security protocol implemented within the Internet Protocol layer
49of the TCP/IP stack.
50.Nm
51is defined for both IPv4 and IPv6
52.Xr ( inet 4
53and
54.Xr inet6 4 ) .
55.Nm
56contains two protocols,
57ESP, the encapsulated security payload protocol and
58AH, the authentication header protocol.
59ESP prevents unauthorized parties from reading the payload of an IP packet
60by encrypting it using
61secret key cryptography algorithms.
62AH both authenticates guarantees the integrity of an IP packet
63by attaching a cryptographic checksum computed using one-way hash functions.
64.Nm
65has operates in one of two modes: transport mode or tunnel mode.
66Transport mode is used to protect peer-to-peer communication between end nodes.
67Tunnel mode encapsulates IP packets within other IP packets
68and is designed for security gateways such as VPN endpoints.
69.\"
70.Ss Kernel interface
71.Nm
72is controlled by a key management and policy engine,
73that reside in the operating system kernel.  Key management
74is the process of associating keys with security associations, also
75know as SAs.  Policy management dictates when new security
76associations created or destroyed.
77.Pp
78The key management engine can be accessed from userland by using
79.Dv PF_KEY
80sockets.
81The
82.Dv PF_KEY
83socket API is defined in RFC2367.
84.Pp
85The policy engine is controlled by an extension to the
86.Dv PF_KEY
87API,
88.Xr setsockopt 2
89operations, and
90.Xr sysctl 3
91interface.
92The kernel implements
93an extended version of the
94.Dv PF_KEY
95interface, and allows the programmer to define IPsec policies
96which are similar to the per-packet filters.  The
97.Xr setsockopt 2
98interface is used to define per-socket behavior, and
99.Xr sysctl 3
100interface is used to define host-wide default behavior.
101.Pp
102The kernel code does not implement a dynamic encryption key exchange protocol
103such as IKE
104(Internet Key Exchange).
105Key exchange protocols are beyond what is necessary in the kernel and
106should be implemented as daemon processes which call the
107.Nm APIs.
108.\"
109.Ss Policy management
110IPsec policies can be managed in one of two ways, either by
111configuring per-socket policies using the
112.Xr setsockopt 2
113system calls, or by configuring kernel level packet filter-based
114policies using the
115.Dv PF_KEY
116interface, via the
117.Xr setkey 8
118command.
119In either case, IPsec policies must be specified using the syntax described in
120.Xr ipsec_set_policy 3 .
121Please refer to the
122.Xr setkey 8
123man page for instructions on its use.
124.Pp
125When setting policies using the
126.Xr setkey 8
127command the
128.Dq Li default
129option you can have the system use its default policy, explained
130below, for processing packets.
131The following sysctl variables are available for configuring the
132system's IPsec behavior.  The variables can have one of two values.
133A
134.Li 1
135means
136.Dq Li use ,
137which means that if there is a security association then use it but if
138there is not then the packets are not processed by IPsec.  The value
139.Li 2
140is synonymous with
141.Dq Li require ,
142which requires that a security association must exist for the packets
143to 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
157If the kernel does not find a matching, system wide, policy then the
158default value is applied.  The system wide default policy is specified
159by the following
160.Xr sysctl 8
161variables.
162.Li 0
163means
164.Dq Li discard
165which asks the kernel to drop the packet.
166.Li 1
167means
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
176The following variables are accessible via
177.Xr sysctl 8 ,
178for 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
190The variables are interpreted as follows:
191.Bl -tag -width 6n
192.It Li ipsec.ah_cleartos
193If set to non-zero, the kernel clears the type-of-service field in the IPv4 header
194during AH authentication data computation.
195This variable is used to get current systems to inter-operate with devices that
196implement RFC1826 AH.
197It should be set to non-zero
198(clear the type-of-service field)
199for RFC2402 conformance.
200.It Li ipsec.ah_offsetmask
201During AH authentication data computation, the kernel will include a
20216bit fragment offset field
203(including flag bits)
204in the IPv4 header, after computing logical AND with the variable.
205The variable is used for inter-operating with devices that
206implement RFC1826 AH.
207It should be set to zero
208(clear the fragment offset field during computation)
209for RFC2402 conformance.
210.It Li ipsec.dfbit
211This variable configures the kernel behavior on IPv4 IPsec tunnel encapsulation.
212If set to 0, the DF bit on the outer IPv4 header will be cleared while
2131 means that the outer DF bit is set regardless from the inner DF bit and
2142 indicates that the DF bit is copied from the inner header to the
215outer one.
216The variable is supplied to conform to RFC2401 chapter 6.1.
217.It Li ipsec.ecn
218If set to non-zero, IPv4 IPsec tunnel encapsulation/decapsulation behavior will
219be friendly to ECN
220(explicit congestion notification),
221as documented in
222.Li draft-ietf-ipsec-ecn-02.txt .
223.Xr gif 4
224talks more about the behavior.
225.It Li ipsec.debug
226If set to non-zero, debug messages will be generated via
227.Xr syslog 3 .
228.El
229.Pp
230Variables under the
231.Li net.inet6.ipsec6
232tree have similar meanings to those described above.
233.\"
234.Sh PROTOCOLS
235The
236.Nm
237protocol acts as a plug-in to the
238.Xr inet 4
239and
240.Xr inet6 4
241protocols and therefore supports most of the protocols defined upon
242those IP-layer protocols.  The
243.Xr icmp 4
244and
245.Xr icmp6 4
246protocols may behave differently with
247.Nm
248because
249.Nm
250can prevent
251.Xr icmp 4
252or
253.Xr icmp6 4
254routines 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
297The implementation described herein appeared in WIDE/KAME IPv6/IPsec stack.
298.Sh BUGS
299The IPsec support is subject to change as the IPsec protocols develop.
300.Pp
301There is no single standard for the policy engine API,
302so the policy engine API described herein is just for KAME implementation.
303.Pp
304AH and tunnel mode encapsulation may not work as you might expect.
305If you configure inbound
306.Dq require
307policy 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 ) ,
310tunnelled packets will be rejected.
311This is because the policy check is enforced on the inner packet on reception,
312and AH authenticates encapsulating
313(outer)
314packet, not the encapsulated
315(inner)
316packet
317(so for the receiving kernel there is no sign of authenticity).
318The issue will be solved when we revamp our policy engine to keep all the
319packet decapsulation history.
320.Pp
321When a large database of security associations or policies is present
322in the kernel the
323.Dv SADB_DUMP
324and
325.Dv SADB_SPDDUMP
326operations on
327.Dv PF_KEY
328sockets may fail due to lack of space.  Increasing the socket buffer
329size may alleviate this problem.
330