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: head/share/man/man4/ipsec.4 171696 2007-08-02 08:04:48Z bz $
|
30.\" $FreeBSD: head/share/man/man4/ipsec.4 171732 2007-08-05 16:16:15Z bz $ |
31.\"
|
32.Dd August 1, 2007
|
32.Dd August 5, 2007 |
33.Dt IPSEC 4 34.Os 35.Sh NAME 36.Nm IPsec 37.Nd Internet Protocol Security protocol 38.Sh SYNOPSIS 39.Cd "options IPSEC"
|
40.Cd "options IPSEC_FILTERGIF"
|
40.Cd "options IPSEC_FILTERTUNNEL" |
41.Cd "device crypto" 42.Pp 43.In sys/types.h 44.In netinet/in.h 45.In netipsec/ipsec.h 46.In netipsec/ipsec6.h 47.Sh DESCRIPTION 48.Nm 49is a security protocol implemented within the Internet Protocol layer 50of the networking stack. 51.Nm 52is defined for both IPv4 and IPv6 53.Xr ( inet 4 54and 55.Xr inet6 4 ) . 56.Nm 57is a set of protocols, 58.Tn ESP 59(for Encapsulating Security Payload) 60.Tn AH 61(for Authentication Header), 62and 63.Tn IPComp 64(for IP Payload Compression Protocol) 65that provide security services for IP datagrams. 66AH both authenticates and guarantees the integrity of an IP packet 67by attaching a cryptographic checksum computed using one-way hash functions. 68ESP, in addition, prevents unauthorized parties from reading the payload of 69an IP packet by also encrypting it. 70IPComp tries to increase communication performance by compressing IP payload, 71thus reducing the amount of data sent. 72This will help nodes on slow links but with enough computing power. 73.Nm 74operates in one of two modes: transport mode or tunnel mode. 75Transport mode is used to protect peer-to-peer communication between end nodes. 76Tunnel mode encapsulates IP packets within other IP packets 77and is designed for security gateways such as VPN endpoints. 78.Pp 79System configuration requires the 80.Xr crypto 4 81subsystem. 82.Pp 83The packets can be passed to a virtual 84.Xr enc 4 85interface, 86to perform packet filtering before outbound encryption and after decapsulation 87inbound. 88.Pp 89To properly filter on the inner packets of an 90.Nm 91tunnel with firewalls, add
|
92.Cd "options IPSEC_FILTERGIF"
|
92.Cd "options IPSEC_FILTERTUNNEL" |
93to the kernel configuration file. 94.\" 95.Ss Kernel interface 96.Nm 97is controlled by a key management and policy engine, 98that reside in the operating system kernel. 99Key management 100is the process of associating keys with security associations, also 101know as SAs. 102Policy management dictates when new security 103associations created or destroyed. 104.Pp 105The key management engine can be accessed from userland by using 106.Dv PF_KEY 107sockets. 108The 109.Dv PF_KEY 110socket API is defined in RFC2367. 111.Pp 112The policy engine is controlled by an extension to the 113.Dv PF_KEY 114API, 115.Xr setsockopt 2 116operations, and 117.Xr sysctl 3 118interface. 119The kernel implements 120an extended version of the 121.Dv PF_KEY 122interface and allows the programmer to define IPsec policies 123which are similar to the per-packet filters. 124The 125.Xr setsockopt 2 126interface is used to define per-socket behavior, and 127.Xr sysctl 3 128interface is used to define host-wide default behavior. 129.Pp 130The kernel code does not implement a dynamic encryption key exchange protocol 131such as IKE 132(Internet Key Exchange). 133Key exchange protocols are beyond what is necessary in the kernel and 134should be implemented as daemon processes which call the 135.Nm APIs. 136.\" 137.Ss Policy management 138IPsec policies can be managed in one of two ways, either by 139configuring per-socket policies using the 140.Xr setsockopt 2 141system calls, or by configuring kernel level packet filter-based 142policies using the 143.Dv PF_KEY 144interface, via the 145.Xr setkey 8 146you can define IPsec policies against packets using rules similar to packet 147filtering rules. 148Refer to 149.Xr setkey 8 150on how to use it. 151.Pp 152When setting policies using the 153.Xr setkey 8 154command, the 155.Dq Li default 156option instructs the system to use its default policy, as 157explained below, for processing packets. 158The following sysctl variables are available for configuring the 159system's IPsec behavior. 160The variables can have one of two values. 161A 162.Li 1 163means 164.Dq Li use , 165which means that if there is a security association then use it but if 166there is not then the packets are not processed by IPsec. 167The value 168.Li 2 169is synonymous with 170.Dq Li require , 171which requires that a security association must exist for the packets 172to move, and not be dropped. 173These terms are defined in 174.Xr ipsec_set_policy 8 . 175.Bl -column net.inet6.ipsec6.esp_trans_deflev integerxxx 176.It Sy "Name Type Changeable" 177.It "net.inet.ipsec.esp_trans_deflev integer yes" 178.It "net.inet.ipsec.esp_net_deflev integer yes" 179.It "net.inet.ipsec.ah_trans_deflev integer yes" 180.It "net.inet.ipsec.ah_net_deflev integer yes" 181.It "net.inet6.ipsec6.esp_trans_deflev integer yes" 182.It "net.inet6.ipsec6.esp_net_deflev integer yes" 183.It "net.inet6.ipsec6.ah_trans_deflev integer yes" 184.It "net.inet6.ipsec6.ah_net_deflev integer yes" 185.El 186.Pp 187If the kernel does not find a matching, system wide, policy then the 188default value is applied. 189The system wide default policy is specified 190by the following 191.Xr sysctl 8 192variables. 193.Li 0 194means 195.Dq Li discard 196which asks the kernel to drop the packet. 197.Li 1 198means 199.Dq Li none . 200.Bl -column net.inet6.ipsec6.def_policy integerxxx 201.It Sy "Name Type Changeable" 202.It "net.inet.ipsec.def_policy integer yes" 203.It "net.inet6.ipsec6.def_policy integer yes" 204.El 205.\" 206.Ss Miscellaneous sysctl variables 207When the 208.Nm 209protocols are configured for use, all protocols are included in the system. 210To selectively enable/disable protocols, use 211.Xr sysctl 8 . 212.Bl -column net.inet.ipcomp.ipcomp_enable 213.It Sy "Name Default" 214.It "net.inet.esp.esp_enable On" 215.It "net.inet.ah.ah_enable On" 216.It "net.inet.ipcomp.ipcomp_enable Off" 217.El 218.Pp 219In addition the following variables are accessible via 220.Xr sysctl 8 , 221for tweaking the kernel's IPsec behavior: 222.Bl -column net.inet6.ipsec6.inbonud_call_ike integerxxx 223.It Sy "Name Type Changeable" 224.It "net.inet.ipsec.ah_cleartos integer yes" 225.It "net.inet.ipsec.ah_offsetmask integer yes" 226.It "net.inet.ipsec.dfbit integer yes" 227.It "net.inet.ipsec.ecn integer yes" 228.It "net.inet.ipsec.debug integer yes" 229.It "net.inet6.ipsec6.ecn integer yes" 230.It "net.inet6.ipsec6.debug integer yes" 231.El 232.Pp 233The variables are interpreted as follows: 234.Bl -tag -width 6n 235.It Li ipsec.ah_cleartos 236If set to non-zero, the kernel clears the type-of-service field in the IPv4 header 237during AH authentication data computation. 238This variable is used to get current systems to inter-operate with devices that 239implement RFC1826 AH. 240It should be set to non-zero 241(clear the type-of-service field) 242for RFC2402 conformance. 243.It Li ipsec.ah_offsetmask 244During AH authentication data computation, the kernel will include a 24516bit fragment offset field 246(including flag bits) 247in the IPv4 header, after computing logical AND with the variable. 248The variable is used for inter-operating with devices that 249implement RFC1826 AH. 250It should be set to zero 251(clear the fragment offset field during computation) 252for RFC2402 conformance. 253.It Li ipsec.dfbit 254This variable configures the kernel behavior on IPv4 IPsec tunnel encapsulation. 255If set to 0, the DF bit on the outer IPv4 header will be cleared while 2561 means that the outer DF bit is set regardless from the inner DF bit and 2572 indicates that the DF bit is copied from the inner header to the 258outer one. 259The variable is supplied to conform to RFC2401 chapter 6.1. 260.It Li ipsec.ecn 261If set to non-zero, IPv4 IPsec tunnel encapsulation/decapsulation behavior will 262be friendly to ECN 263(explicit congestion notification), 264as documented in 265.Li draft-ietf-ipsec-ecn-02.txt . 266.Xr gif 4 267talks more about the behavior. 268.It Li ipsec.debug 269If set to non-zero, debug messages will be generated via 270.Xr syslog 3 . 271.El 272.Pp 273Variables under the 274.Li net.inet6.ipsec6 275tree have similar meanings to those described above. 276.\" 277.Sh PROTOCOLS 278The 279.Nm 280protocol acts as a plug-in to the 281.Xr inet 4 282and 283.Xr inet6 4 284protocols and therefore supports most of the protocols defined upon 285those IP-layer protocols. 286The 287.Xr icmp 4 288and 289.Xr icmp6 4 290protocols may behave differently with 291.Nm 292because 293.Nm 294can prevent 295.Xr icmp 4 296or 297.Xr icmp6 4 298routines from looking into the IP payload. 299.\" 300.Sh SEE ALSO 301.Xr ioctl 2 , 302.Xr socket 2 , 303.Xr ipsec_set_policy 3 , 304.Xr crypto 4 , 305.Xr enc 4 , 306.Xr icmp6 4 , 307.Xr intro 4 , 308.Xr ip6 4 , 309.Xr setkey 8 , 310.Xr sysctl 8 311.\".Xr racoon 8 312.Rs 313.%A "S. Kent" 314.%A "R. Atkinson" 315.%T "IP Authentication Header" 316.%O "RFC 2404" 317.Re 318.Rs 319.%A "S. Kent" 320.%A "R. Atkinson" 321.%T "IP Encapsulating Security Payload (ESP)" 322.%O "RFC 2406" 323.Re 324.Sh STANDARDS 325.Rs 326.%A Daniel L. McDonald 327.%A Craig Metz 328.%A Bao G. Phan 329.%T "PF_KEY Key Management API, Version 2" 330.%R RFC 331.%N 2367 332.Re 333.Pp 334.Rs 335.%A "D. L. McDonald" 336.%T "A Simple IP Security API Extension to BSD Sockets" 337.%R internet draft 338.%N "draft-mcdonald-simple-ipsec-api-03.txt" 339.%O work in progress material 340.Re 341.Sh HISTORY 342The original 343.Nm 344implementation appeared in the WIDE/KAME IPv6/IPsec stack. 345.Pp 346For 347.Fx 5.0 348a fully locked IPsec implementation called fast_ipsec was brought in. 349The protocols drew heavily on the 350.Ox 351implementation of the 352.Tn IPsec 353protocols. 354The policy management code was derived from the 355.Tn KAME 356implementation found 357in their 358.Tn IPsec 359protocols. 360The fast_ipsec implementation lacked 361.Xr ip6 4 362support but made use of the 363.Xr crypto 4 364subsystem. 365.Pp 366For 367.Fx 7.0 368.Xr ip6 4 369support was added to fast_ipsec. 370After this the old KAME IPsec implementation was dropped and fast_ipsec 371became what now is the only 372.Nm 373implementation in 374.Fx . 375.Sh BUGS 376There is no single standard for the policy engine API, 377so the policy engine API described herein is just for this implementation. 378.Pp 379AH and tunnel mode encapsulation may not work as you might expect. 380If you configure inbound 381.Dq require 382policy with an AH tunnel or any IPsec encapsulating policy with AH 383(like 384.Dq Li esp/tunnel/A-B/use ah/transport/A-B/require ) , 385tunnelled packets will be rejected. 386This is because the policy check is enforced on the inner packet on reception, 387and AH authenticates encapsulating 388(outer) 389packet, not the encapsulated 390(inner) 391packet 392(so for the receiving kernel there is no sign of authenticity). 393The issue will be solved when we revamp our policy engine to keep all the 394packet decapsulation history. 395.Pp 396When a large database of security associations or policies is present 397in the kernel the 398.Dv SADB_DUMP 399and 400.Dv SADB_SPDDUMP 401operations on 402.Dv PF_KEY 403sockets may fail due to lack of space. 404Increasing the socket buffer 405size may alleviate this problem. 406.Pp 407The 408.Tn IPcomp 409protocol support is currently broken. 410.Pp 411This documentation needs more review.
|