ipsec(4)
- NetBSD Manual Pages
IPSEC(4) NetBSD Kernel Interfaces Manual IPSEC(4)
NAME
ipsec -- IP security protocol
SYNOPSIS
options IPSEC
options IPSEC_DEBUG
DESCRIPTION
This manual pages describes the IPsec protocol. For the network device
driver please see ipsecif(4).
ipsec is a security protocol in the Internet Protocol (IP) layer. ipsec
is defined for both IPv4 and IPv6 (inet(4) and inet6(4)). ipsec consists
of three sub-protocols:
Encapsulated Security Payload (ESP) protects IP payloads from wire-tap-
ping (interception) by encrypting them with secret key cryptogra-
phy algorithms.
Authentication Header (AH) guarantees the integrity of IP packets and
protects them from intermediate alteration or impersonation, by
attaching cryptographic checksums computed by one-way hash func-
tions.
IP Payload Compression Protocol (IPComp) increases the communication per-
formance by compressing the datagrams.
ipsec has two operation modes:
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, as in Virtual Private Network (VPN) configura-
tions.
Kernel interface
ipsec is controlled by two engines in the kernel: one for key management
and one for policy.
The key management engine can be accessed from userland by using PF_KEY
sockets. The PF_KEY socket API is defined in RFC2367.
The policy engine can be controlled through the PF_KEY API, setsockopt(2)
operations, and the sysctl(3) interface. The kernel implements an
extended version of the PF_KEY interface and allows you to define IPsec
policy like per-packet filters. setsockopt(2) is used to define per-
socket behavior, and sysctl(3) is used to define host-wide default behav-
ior.
The kernel does not implement dynamic encryption key exchange protocols
like IKE (Internet Key Exchange). That should be done in userland
(usually as a daemon), using the APIs described above.
Policy management
The 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 the PF_KEY interface, via setkey(8). In both cases,
IPsec policy must be specified with syntax described in
ipsec_set_policy(3).
With setsockopt(2), you can define IPsec policy on a per-socket basis.
You can enforce particular IPsec policy on packets that go through a par-
ticular socket.
With setkey(8) you can define IPsec policy for packets using a form of
packet filtering rules. See setkey(8) for details.
In the latter case, ``default'' policy is allowed for use with setkey(8).
By configuring policy to default, you can refer to system-wide sysctl(8)
variables for default settings. The following variables are available.
1 means ``use'', and 2 means ``require'' in the syntax.
Name Type Changeable
net.inet.ipsec.esp_trans_deflev integer yes
net.inet.ipsec.esp_net_deflev integer yes
net.inet.ipsec.ah_trans_deflev integer yes
net.inet.ipsec.ah_net_deflev integer yes
net.inet6.ipsec6.esp_trans_deflev integer yes
net.inet6.ipsec6.esp_net_deflev integer yes
net.inet6.ipsec6.ah_trans_deflev integer yes
net.inet6.ipsec6.ah_net_deflev integer yes
If the kernel finds no matching policy, the system-wide default value is
applied. System-wide defaults are specified by the following sysctl(8)
variables. 0 means ``discard'' which asks the kernel to drop the packet.
1 means ``none''.
Name Type Changeable
net.inet.ipsec.def_policy integer yes
net.inet6.ipsec6.def_policy integer yes
Miscellaneous sysctl variables
The following variables are accessible via sysctl(8), for tweaking kernel
IPsec behavior:
Name Type Changeable
net.inet.ipsec.ah_cleartos integer yes
net.inet.ipsec.ah_offsetmask integer yes
net.inet.ipsec.crypto_support 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.ah_cleartos
If set to non-zero, the kernel clears the type-of-service field
in the IPv4 header during AH authentication data computation.
The variable is for tweaking AH behavior to interoperate with
devices that implement RFC1826 AH. It should be set to non-zero
(clear the type-of-service field) for RFC2402 conformance.
ipsec.ah_offsetmask
During AH authentication data computation, the kernel will
include a 16 bit fragment offset field (including flag bits) in
the IPv4 header, after computing logical AND with the variable.
The variable is for tweaking AH behavior to interoperate with
devices that implement RFC1826 AH. It should be set to zero
(clear the fragment offset field during computation) for RFC2402
conformance.
ipsec.crypto_support
This variable configures the kernel behavior for selecting
encryption drivers. If set to > 0, the kernel will select a
hardware encryption driver first. If set to < 0, the kernel will
select a software encryption driver first. If set to 0, the ker-
nel will select either a hardware or software driver.
ipsec.dfbit
This variable configures the kernel behavior on IPv4 IPsec tunnel
encapsulation. If set to 0, the DF bit on the outer IPv4 header
will be cleared. 1 means that the outer DF bit is set 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
notification), 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 the net.inet6.ipsec6 tree have similar meanings to their
net.inet.ipsec counterparts.
Cryptographic operations
The current IPsec implementation, formerly called Fast IPsec, uses the
opencrypto(9) subsystem to carry out cryptographic operations. This
means, in particular, that cryptographic hardware devices are employed
whenever possible to optimize the performance of sub-protocols.
System configuration requires the opencrypto(9) subsystem. When the Fast
IPsec protocols are configured for use, all protocols are included in the
system. To selectively enable/disable protocols, use sysctl(8).
PROTOCOLS
The ipsec protocol works like a plug-in to inet(4) and inet6(4) proto-
cols. Therefore, ipsec 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 ipsec. This is because ipsec can prevent icmp(4)
or icmp6(4) routines from looking into IP payload.
SEE ALSO
ioctl(2), socket(2), ipsec_set_policy(3), icmp6(4), intro(4), ip6(4),
ipsecif(4), racoon(8), setkey(8), sysctl(8)
STANDARDS
Daniel L. McDonald, Craig Metz, and Bao G. Phan, PF_KEY Key Management
API, Version 2, RFC, 2367.
HISTORY
The protocols draw heavily on the OpenBSD implementation of the IPsec
protocols. The policy management code is derived from the KAME implemen-
tation found in their IPsec protocols. The Fast IPsec protocols are
based on code which appeared in FreeBSD 4.7. The NetBSD version is a
close copy of the FreeBSD original, and first appeared in NetBSD 2.0.
Support for IPv6 and IPcomp protocols has been added in NetBSD 4.0.
Support for Network Address Translator Traversal as described in RFCs
3947 and 3948 has been added in NetBSD 5.0.
Since NetBSD 6.0, the IPsec implementation formerly known as Fast IPsec
is used.
BUGS
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 the version introduced by KAME.
AH and tunnel mode encapsulation may not work as you might expect. If
you configure inbound ``require'' policy against AH tunnel or any IPsec
encapsulating policy with AH (like ``esp/tunnel/A-B/use
ah/transport/A-B/require''), tunneled 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 SADB_DUMP and SADB_SPDDUMP operation on PF_KEY socket. This
occurs if there are too many database entries in the kernel and socket
buffer for the PF_KEY socket is insufficient. If you manipulate many
IPsec key/policy database entries, increase the size of socket buffer or
use sysctl(8) interface.
Certain legacy authentication algorithms are not supported because of
issues with the opencrypto(9) subsystem.
NetBSD 10.99 June 13, 2018 NetBSD 10.99
Powered by man-cgi (2021-06-01).
Maintained for NetBSD
by Kimmo Suominen.
Based on man-cgi by Panagiotis Christias.