NAME
iippsseecc - IP security protocol
SYNOPSIS
##iinncclluuddee <
> ##iinncclluuddee <
> ##iinncclluuddee <
> DESCRIPTION
iippsseecc is a security protocol in Internet Protocol layer. iippsseecc is defined for both IPv4 and IPv6 (inet(4) and inet6(4)). iippsseecc consists oftwo sub-protocols, namely ESP (encapsulated security payload) and AH
(authentication header). ESP protects IP payload from wire-tapping by
encrypting it by secret key cryptography algorithms. AH guarantees integrity of IP packet and protects it from intermediate alteration orimpersonation, by attaching cryptographic checksum computed by one-way
hash functions. iippsseecc has two operation modes: transport mode and tunnelmode. Transport mode is for protecting peer-to-peer communication
between end nodes. Tunnel mode includes IP-in-IP encapsulation operation
and is designed for security gateways, like VPN configurations. KKeerrnneell iinntteerrffaaccee iippsseecc is controlled by key management engine and policy engine, in the operating system kernel. Key management engine can be accessed from the userland by using PFKEY sockets. The PFKEY socket API is defined in RFC2367. Policy engine can be controlled by extended part of PFKEY API, setsockopt(2) operations, and sysctl(3) interface. The kernel implementsextended version of PFKEY interface, and allows you to define IPsec pol-
icy like per-packet filters. setsockopt(2) interface is used to define
per-socket behavior, and sysctl(3) interface is used to define host-wide
default behavior.The kernel code does not implement dynamic encryption key exchange proto-
col like IKE (Internet Key Exchange). That should be implemented as userland programs (usually as daemons), by using the above described APIs. PPoolliiccyy mmaannaaggeemmeennttThe kernel implements experimental policy management code. You can man-
age the IPsec policy in two ways. One is to configure per-socket policy
using setsockopt(2). The other is to configure kernel packet filter-
based policy using PFKEY interface, via setkey(8). In both cases, IPsecpolicy must be specified with syntax described in ipsecsetpolicy(3).
With setsockopt(2), you can define IPsec policy in per-socket basis. You
can enforce particular IPsec policy onto packets that go through particu-
lar socket. With setkey(8) you can define IPsec policy against packets, using sort of packet filtering rule. Refer to setkey(8) on how to use it. In the latter case, ``default'' policy is allowed for use with setkey(8).By configuring policy to default, you can refer system-wide sysctl(8)
variable for default settings. The following variables are available. 1 means ``use'', and 2 means ``require'' in the syntax. NNaammee TTyyppee CChhaannggeeaabblleenet.inet.ipsec.esptransdeflev integer yes
net.inet.ipsec.espnetdeflev integer yes
net.inet.ipsec.ahtransdeflev integer yes
net.inet.ipsec.ahnetdeflev integer yes
net.inet6.ipsec6.esptransdeflev integer yes
net.inet6.ipsec6.espnetdeflev integer yes
net.inet6.ipsec6.ahtransdeflev integer yes
net.inet6.ipsec6.ahnetdeflev integer yes
If kernel finds no matching policy system wide default value is applied. System wide default is specified by the following sysctl(8) variables. 0 means ``discard'' which asks the kernel to drop the packet. 1 means ``none''. NNaammee TTyyppee CChhaannggeeaabblleenet.inet.ipsec.defpolicy integer yes
net.inet6.ipsec6.defpolicy integer yes
MMiisscceellllaanneeoouuss ssyyssccttll vvaarriiaabblleess The following variables are accessible via sysctl(8), for tweaking kernel IPsec behavior: NNaammee TTyyppee CChhaannggeeaabblleenet.inet.ipsec.ahcleartos integer yes
net.inet.ipsec.ahoffsetmask integer yes
net.inet.ipsec.dfbit integer yes
net.inet.ipsec.ecn integer yes
net.inet.ipsec.debug integer yes
net.inet6.ipsec6.ecn integer yes
net.inet6.ipsec6.debug integer yes
The variables are interpreted as follows:ipsec.ahcleartos
If set to non-zero, the kernel clears type-of-service field in
the IPv4 header during AH authentication data computation. The variable is for tweaking AH behavior to interoperate with devicesthat implement RFC1826 AH. It should be set to non-zero (clear
the type-of-service field) for RFC2402 conformance.
ipsec.ahoffsetmask
During AH authentication data computation, the kernel will include 16bit fragment offset field (including flag bits) in IPv4header, after computing logical AND with the variable. The vari-
able is for tweaking AH behavior to interoperate with devices that implement RFC1826 AH. It should be set to zero (clear thefragment offset field during computation) for RFC2402 confor-
mance.ipsec.dfbit
The variable configures the kernel behavior on IPv4 IPsec tunnel encapsulation. If set to 0, DF bit on the outer IPv4 header will be cleared. 1 means that the outer DF bit is set regardless from the inner DF bit. 2 means that the DF bit is copied from the inner header to the outer. The variable is supplied to conform to RFC2401 chapter 6.1.ipsec.ecn
If set to non-zero, IPv4 IPsec tunnel encapsulation/decapsulation
behavior will be friendly to ECN (explicit congestion notifica-
tion), as documented in draft-ietf-ipsec-ecn-02.txt. gif(4)
talks more about the behavior.ipsec.debug
If set to non-zero, debug messages will be generated via
syslog(3).Variables under net.inet6.ipsec6 tree has similar meaning as the
net.inet.ipsec counterpart.
PPRROOTTOOCCOOLLSSThe iippsseecc protocol works like plug-in to inet(4) and inet6(4) protocols.
Therefore, iippsseecc supports most of the protocols defined upon those IP-
layer protocols. Some of the protocols, like icmp(4) or icmp6(4), may behave differently with iippsseecc. This is because iippsseecc can prevent icmp(4) or icmp6(4) routines from looking into IP payload.SEE ALSO
ioctl(2), socket(2), ipsecsetpolicy(3), icmp6(4), intro(4), ip6(4),
setkey(8), sysctl(8) STANDARDS Daniel L. McDonald, Craig Metz, and Bao G. Phan, PFKEY Key Management API, Version 2, RFC, 2367. D. L. McDonald, A Simple IP Security API Extension to BSD Sockets,internet draft, draft-mcdonald-simple-ipsec-api-03.txt, work in progress
material. HISTORY The implementation described herein appeared in WIDE/KAME IPv6/IPsec stack.BUGS
The IPsec support is subject to change as the IPsec protocols develop. There is no single standard for policy engine API, so the policy engine API described herein is just for KAME implementation. AH and tunnel mode encapsulation may not work as you might expect. If you configure inbound ``require'' policy against AH tunnel or any IPsecencapsulating policy with AH (like ``esp/tunnel/A-B/use
ah/transport/A-B/require''), tunnelled packets will be rejected. This is
because we enforce policy check on inner packet on reception, and AH authenticates encapsulating (outer) packet, not the encapsulated (inner) packet (so for the receiving kernel there's no sign of authenticity). The issue will be solved when we revamp our policy engine to keep all the packet decapsulation history. Under certain condition, truncated result may be raised from the kernel against SADBDUMP and SADBSPDDUMP operation on PFKEY socket. This occurs if there are too many database entries in the kernel and socket buffer for the PFKEY socket is insufficient. If you manipulate many IPsec key/policy database entries, increase the size of socket buffer. BSD January 29, 1999 BSD