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