is a security protocol implemented within the Internet Protocol layer
of the networking stack.
is defined for both IPv4 and IPv6
is a set of protocols,
(for Encapsulating Security Payload)
(for Authentication Header),
(for IP Payload Compression Protocol)
that provide security services for IP datagrams.
AH both authenticates and guarantees the integrity of an IP packet
by attaching a cryptographic checksum computed using one-way hash functions.
ESP, in addition, prevents unauthorized parties from reading the payload of
an IP packet by also encrypting it.
IPComp tries to increase communication performance by compressing IP payload,
thus reducing the amount of data sent.
This will help nodes on slow links but with enough computing power.
operates in one of two modes: transport mode or tunnel mode.
Transport mode is used to protect peer-to-peer communication between end nodes.
Tunnel mode encapsulates IP packets within other IP packets
and is designed for security gateways such as VPN endpoints.
System configuration requires the
The packets can be passed to a virtual
to perform packet filtering before outbound encryption and after decapsulation
To properly filter on the inner packets of an
tunnel with firewalls, add
to the kernel configuration file.
is controlled by a key management and policy engine,
that reside in the operating system kernel.
is the process of associating keys with security associations, also
know as SAs.
Policy management dictates when new security
associations created or destroyed.
The key management engine can be accessed from userland by using
socket API is defined in RFC2367.
The policy engine is controlled by an extension to the
The kernel implements
an extended version of the
interface and allows the programmer to define IPsec policies
which are similar to the per-packet filters.
interface is used to define per-socket behavior, and
interface is used to define host-wide default behavior.
The kernel code does not implement a dynamic encryption key exchange protocol
such as IKE
(Internet Key Exchange).
Key exchange protocols are beyond what is necessary in the kernel and
should be implemented as daemon processes which call the
IPsec policies can be managed in one of two ways, either by
configuring per-socket policies using the
system calls, or by configuring kernel level packet filter-based
policies using the
interface, via the
you can define IPsec policies against packets using rules similar to packet
on how to use it.
When setting policies using the
option instructs the system to use its default policy, as
explained below, for processing packets.
The following sysctl variables are available for configuring the
system's IPsec behavior.
The variables can have one of two values.
which means that if there is a security association then use it but if
there is not then the packets are not processed by IPsec.
is synonymous with
which requires that a security association must exist for the packets
to move, and not be dropped.
These terms are defined in
If the kernel does not find a matching, system wide, policy then the
default value is applied.
The system wide default policy is specified
by the following
which asks the kernel to drop the packet.
Miscellaneous sysctl variables
protocols are configured for use, all protocols are included in the system.
To selectively enable/disable protocols, use
In addition the following variables are accessible via sysctl(8),
for tweaking the kernel's IPsec behavior:
The variables are interpreted as follows:
If set to non-zero, the kernel clears the type-of-service field in the IPv4 header
during AH authentication data computation.
This variable is used to get current systems to inter-operate with devices that
implement RFC1826 AH.
It should be set to non-zero
(clear the type-of-service field)
for RFC2402 conformance.
During AH authentication data computation, the kernel will include a
16bit fragment offset field
(including flag bits)
in the IPv4 header, after computing logical AND with the variable.
The variable is used for inter-operating with devices that
implement RFC1826 AH.
It should be set to zero
(clear the fragment offset field during computation)
for RFC2402 conformance.
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 while
1 means that the outer DF bit is set regardless from the inner DF bit and
2 indicates that the DF bit is copied from the inner header to the
The variable is supplied to conform to RFC2401 chapter 6.1.
If set to non-zero, IPv4 IPsec tunnel encapsulation/decapsulation behavior will
be friendly to ECN
(explicit congestion notification),
as documented in
talks more about the behavior.
If set to non-zero, debug messages will be generated via
Variables under the
tree have similar meanings to those described above.
protocol acts as a plug-in to the
protocols and therefore supports most of the protocols defined upon
those IP-layer protocols.
protocols may behave differently with
routines from looking into the IP payload.
Daniel L. McDonald
Bao G. Phan
"PF_KEY Key Management API, Version 2"RFC
"D. L. McDonald"
"A Simple IP Security API Extension to BSD Sockets"internet draft
work in progress material
implementation appeared in the WIDE/KAME IPv6/IPsec stack.
a fully locked IPsec implementation called fast_ipsec was brought in.
The protocols drew heavily on the
Ox implementation of the
The policy management code was derived from the
The fast_ipsec implementation lacked
support but made use of the
support was added to fast_ipsec.
After this the old KAME IPsec implementation was dropped and fast_ipsec
became what now is the only
There is no single standard for the policy engine API,
so the policy engine API described herein is just for this implementation.
AH and tunnel mode encapsulation may not work as you might expect.
If you configure inbound
policy with an AH tunnel or any IPsec encapsulating policy with AH
tunnelled packets will be rejected.
This is because the policy check is enforced on the inner packet on reception,
and AH authenticates encapsulating
packet, not the encapsulated
(so for the receiving kernel there is no sign of authenticity).
The issue will be solved when we revamp our policy engine to keep all the
packet decapsulation history.
When a large database of security associations or policies is present
in the kernel the
sockets may fail due to lack of space.
Increasing the socket buffer
size may alleviate this problem.