]> git.saurik.com Git - apple/xnu.git/blame - bsd/man/man4/ipsec.4
xnu-6153.141.1.tar.gz
[apple/xnu.git] / bsd / man / man4 / ipsec.4
CommitLineData
9bccf70c
A
1.\" $FreeBSD: src/share/man/man4/ipsec.4,v 1.3.2.10 2001/12/17 11:30:12 ru Exp $
2.\" $KAME: ipsec.4,v 1.17 2001/06/27 15:25:10 itojun Exp $
3.\"
4.\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5.\" All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\" notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\" notice, this list of conditions and the following disclaimer in the
14.\" documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the project nor the names of its contributors
16.\" may be used to endorse or promote products derived from this software
17.\" without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.Dd January 29, 1999
32.Dt IPSEC 4
33.Os
34.Sh NAME
35.Nm ipsec
36.Nd IP security protocol
37.Sh SYNOPSIS
38.In sys/types.h
39.In netinet/in.h
40.In netinet6/ipsec.h
41.Sh DESCRIPTION
42.Nm
43is a security protocol in Internet Protocol layer.
44.Nm
45is defined for both IPv4 and IPv6
46.Xr ( inet 4
47and
48.Xr inet6 4 ) .
49.Nm
50consists of two sub-protocols, namely
51ESP
52(encapsulated security payload)
53and AH
54(authentication header).
55ESP protects IP payload from wire-tapping by encrypting it by
56secret key cryptography algorithms.
57AH guarantees integrity of IP packet
58and protects it from intermediate alteration or impersonation,
59by attaching cryptographic checksum computed by one-way hash functions.
60.Nm
61has two operation modes: transport mode and tunnel mode.
62Transport mode is for protecting peer-to-peer communication between end nodes.
63Tunnel mode includes IP-in-IP encapsulation operation
64and is designed for security gateways, like VPN configurations.
65.\"
66.Ss Kernel interface
67.Nm
68is controlled by key management engine and policy engine,
69in the operating system kernel.
70.Pp
71Key management engine can be accessed from the userland by using
72.Dv PF_KEY
73sockets.
74The
75.Dv PF_KEY
76socket API is defined in RFC2367.
77.Pp
78Policy engine can be controlled by extended part of
79.Dv PF_KEY
80API,
81.Xr setsockopt 2
82operations, and
83.Xr sysctl 3
84interface.
85The kernel implements
86extended version of
87.Dv PF_KEY
88interface, and allows you to define IPsec policy like per-packet filters.
89.Xr setsockopt 2
90interface is used to define per-socket behavior, and
91.Xr sysctl 3
92interface is used to define host-wide default behavior.
93.Pp
94The kernel code does not implement dynamic encryption key exchange protocol
95like IKE
96(Internet Key Exchange).
97That should be implemented as userland programs
98(usually as daemons),
99by using the above described APIs.
100.\"
101.Ss Policy management
102The kernel implements experimental policy management code.
103You can manage the IPsec policy in two ways.
104One is to configure per-socket policy using
105.Xr setsockopt 2 .
106The other is to configure kernel packet filter-based policy using
107.Dv PF_KEY
108interface, via
109.Xr setkey 8 .
110In both cases, IPsec policy must be specified with syntax described in
111.Xr ipsec_set_policy 3 .
112.Pp
113With
114.Xr setsockopt 2 ,
115you can define IPsec policy in per-socket basis.
116You can enforce particular IPsec policy onto packets that go through
117particular socket.
118.Pp
119With
120.Xr setkey 8
121you can define IPsec policy against packets,
122using sort of packet filtering rule.
123Refer to
124.Xr setkey 8
125on how to use it.
126.Pp
127In the latter case,
128.Dq Li default
129policy is allowed for use with
130.Xr setkey 8 .
131By configuring policy to
132.Li default ,
133you can refer system-wide
134.Xr sysctl 8
135variable for default settings.
136The following variables are available.
137.Li 1
138means
139.Dq Li use ,
140and
141.Li 2
142means
143.Dq Li require
144in the syntax.
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 kernel finds no matching policy system wide default value is applied.
158System wide default is specified by the following
159.Xr sysctl 8
160variables.
161.Li 0
162means
163.Dq Li discard
164which asks the kernel to drop the packet.
165.Li 1
166means
167.Dq Li none .
168.Bl -column net.inet6.ipsec6.def_policy integerxxx
169.It Sy "Name Type Changeable"
170.It "net.inet.ipsec.def_policy integer yes"
171.It "net.inet6.ipsec6.def_policy integer yes"
172.El
173.\"
174.Ss Miscellaneous sysctl variables
175The following variables are accessible via
176.Xr sysctl 8 ,
177for tweaking kernel IPsec behavior:
178.Bl -column net.inet6.ipsec6.inbonud_call_ike integerxxx
179.It Sy "Name Type Changeable"
180.It "net.inet.ipsec.ah_cleartos integer yes"
181.It "net.inet.ipsec.ah_offsetmask integer yes"
182.It "net.inet.ipsec.dfbit integer yes"
183.It "net.inet.ipsec.ecn integer yes"
184.It "net.inet.ipsec.debug integer yes"
185.It "net.inet6.ipsec6.ecn integer yes"
186.It "net.inet6.ipsec6.debug integer yes"
187.El
188.Pp
189The variables are interpreted as follows:
190.Bl -tag -width 6n
191.It Li ipsec.ah_cleartos
192If set to non-zero, the kernel clears type-of-service field in the IPv4 header
193during AH authentication data computation.
194The variable is for tweaking AH behavior to interoperate with devices that
195implement RFC1826 AH.
196It should be set to non-zero
197(clear the type-of-service field)
198for RFC2402 conformance.
199.It Li ipsec.ah_offsetmask
200During AH authentication data computation, the kernel will include
20116bit fragment offset field
202(including flag bits)
203in IPv4 header, after computing logical AND with the variable.
204The variable is for tweaking AH behavior to interoperate with devices that
205implement RFC1826 AH.
206It should be set to zero
207(clear the fragment offset field during computation)
208for RFC2402 conformance.
209.It Li ipsec.dfbit
210The variable configures the kernel behavior on IPv4 IPsec tunnel encapsulation.
211If set to 0, DF bit on the outer IPv4 header will be cleared.
2121 means that the outer DF bit is set regardless from the inner DF bit.
2132 means that the DF bit is copied from the inner header to the outer.
214The variable is supplied to conform to RFC2401 chapter 6.1.
215.It Li ipsec.ecn
216If set to non-zero, IPv4 IPsec tunnel encapsulation/decapsulation behavior will
217be friendly to ECN
218(explicit congestion notification),
219as documented in
220.Li draft-ietf-ipsec-ecn-02.txt .
221.Xr gif 4
222talks more about the behavior.
223.It Li ipsec.debug
224If set to non-zero, debug messages will be generated via
225.Xr syslog 3 .
226.El
227.Pp
228Variables under
229.Li net.inet6.ipsec6
230tree has similar meaning as the
231.Li net.inet.ipsec
232counterpart.
233.\"
234.Sh PROTOCOLS
235The
236.Nm
237protocol works like plug-in to
238.Xr inet 4
239and
240.Xr inet6 4
241protocols.
242Therefore,
243.Nm
244supports most of the protocols defined upon those IP-layer protocols.
245Some of the protocols, like
246.Xr icmp 4
247or
248.Xr icmp6 4 ,
249may behave differently with
250.Nm .
251This is because
252.Nm
253can prevent
254.Xr icmp 4
255or
256.Xr icmp6 4
257routines from looking into IP payload.
258.\"
259.Sh SEE ALSO
260.Xr ioctl 2 ,
261.Xr socket 2 ,
262.Xr ipsec_set_policy 3 ,
263.Xr icmp6 4 ,
264.Xr intro 4 ,
265.Xr ip6 4 ,
266.Xr setkey 8 ,
267.Xr sysctl 8
268.\".Xr racoon 8
269.Sh STANDARDS
270.Rs
271.%A Daniel L. McDonald
272.%A Craig Metz
273.%A Bao G. Phan
274.%T "PF_KEY Key Management API, Version 2"
275.%R RFC
276.%N 2367
277.Re
278.Pp
279.Rs
280.%A "D. L. McDonald"
281.%T "A Simple IP Security API Extension to BSD Sockets"
282.%R internet draft
283.%N "draft-mcdonald-simple-ipsec-api-03.txt"
284.%O work in progress material
285.Re
286.Sh HISTORY
287The implementation described herein appeared in WIDE/KAME IPv6/IPsec stack.
288.Sh BUGS
289The IPsec support is subject to change as the IPsec protocols develop.
290.Pp
291There is no single standard for policy engine API,
292so the policy engine API described herein is just for KAME implementation.
293.Pp
294AH and tunnel mode encapsulation may not work as you might expect.
295If you configure inbound
296.Dq require
297policy against AH tunnel or any IPsec encapsulating policy with AH
298(like
299.Dq Li esp/tunnel/A-B/use ah/transport/A-B/require ) ,
300tunnelled packets will be rejected.
301This is because we enforce policy check on inner packet on reception,
302and AH authenticates encapsulating
303(outer)
304packet, not the encapsulated
305(inner)
306packet
307(so for the receiving kernel there's no sign of authenticity).
308The issue will be solved when we revamp our policy engine to keep all the
309packet decapsulation history.
310.Pp
311Under certain condition,
312truncated result may be raised from the kernel
313against
314.Dv SADB_DUMP
315and
316.Dv SADB_SPDDUMP
317operation on
318.Dv PF_KEY
319socket.
320This occurs if there are too many database entries in the kernel
321and socket buffer for the
322.Dv PF_KEY
323socket is insufficient.
324If you manipulate many IPsec key/policy database entries,
325increase the size of socket buffer.