o .Xr inet 4 and .Xr inet6 4
c . .Nm consists of two sub-protocols, namely ESP
q encapsulated security payload and AH
q 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 or impersonation,
by attaching cryptographic checksum computed by one-way hash functions.
.Nm
has two operation modes: transport mode and tunnel mode.
Transport mode is for protecting peer-to-peer commuication between end nodes.
Tunnel mode includes IP-in-IP encapsulation operation
and is designed for security gateways, like VPN configurations.
.Ss Kernel interface
.Nm
is controlled by key management engine and policy engine,
in the operating system kernel.
p Key management engine can be accessed from the userland by using .Dv PF_KEY sockets. The .Dv PF_KEY socket API is defined in RFC2367.
p Policy engine can be controlled by extended part of .Dv PF_KEY API, .Xr setsockopt 2 operations, and .Xr sysctl 3 interface. The kernel implements extended version of .Dv PF_KEY interface, and allows you to define IPsec policy like per-packet filters. .Xr setsockopt 2 interface is used to define per-socket behavior, and .Xr sysctl 3 interface is used to define host-wide default behavior.
p The kernel code does not implement dynamic encryption key exchange protocol like IKE
q Internet Key Exchange . That should be implemented as userland programs
q usually as daemons ,
by using the above described APIs.
.Ss Policy management
The kernel implements experimental policy management code.
You can manage the IPsec policy in two ways.
One is to configure per-socket policy using
.Xr setsockopt 3 .
The other is to configure kernel packet filter-based policy using
.Dv PF_KEY
interface, via
.Xr setkey 8 .
In both cases, IPsec policy must be specified with syntax described in
.Xr ipsec_set_policy 3 .
p With .Xr setsockopt 3 , you can define IPsec policy in per-socket basis. You can enforce particular IPsec policy onto packets that go through particular socket.
p With .Xr setkey 8 you can define IPsec policy against packets, using sort of packet filtering rule. Refer to .Xr setkey 8 on how to use it.
p In the latter case, .Dq Li default policy is allowed for use with .Xr setkey 8 . By configuring policy to .Li default , you can refer system-wide .Xr sysctl 8 variable for default settings. The following variables are available. .Li 1 means .Dq Li use , and .Li 2 means .Dq Li require in the syntax. l -column net.inet6.ipsec6.esp_trans_deflev integerxxx t Sy Name Type Changeable t net.inet.ipsec.esp_trans_deflev integer yes t net.inet.ipsec.esp_net_deflev integer yes t net.inet.ipsec.ah_trans_deflev integer yes t net.inet.ipsec.ah_net_deflev integer yes t net.inet6.ipsec6.esp_trans_deflev integer yes t net.inet6.ipsec6.esp_net_deflev integer yes t net.inet6.ipsec6.ah_trans_deflev integer yes t net.inet6.ipsec6.ah_net_deflev integer yes .El
p
If kernel finds no matching policy system wide default value is applied.
System wide default is specified by the following
.Xr sysctl 8
variables.
.Li 0
means
.Dq Li discard
which asks the kernel to drop the packet.
.Li 1
means
.Dq Li none .
l -column net.inet6.ipsec6.def_policy integerxxx t Sy Name Type Changeable t net.inet.ipsec.def_policy integer yes t net.inet6.ipsec6.def_policy integer yes .El
.Sh PROTOCOLS
The
.Nm
protocol works like plug-in to
.Xr inet 4
and
.Xr inet6 4
protocols.
Therefore,
.Nm
supports most of the protocols defined upon those IP-layer protocols.
Some of the protocols, like
.Xr icmp 4
or
.Xr icmp6 4 ,
may behave differently with
.Nm ipsec .
This is because
.Nm
can prevent
.Xr icmp 4
or
.Xr icmp6 4
routines from looking into IP payload.
.Sh SEE ALSO
.Xr ioctl 2 ,
.Xr socket 2 ,
.Xr ipsec_set_policy 3 ,
.Xr icmp6 4 ,
.Xr intro 4 ,
.Xr ip6 4 ,
.Xr setkey 8 ,
.Xr sysctl 8 ,
.Xr racoon 8
p .Rs .%A Daniel L. McDonald .%A Craig Metz .%A Bao G. Phan .%T "PF_KEY Key Management API, Version 2" .%R RFC .%N 2367 .Re .Rs .%A "D. L. McDonald" .%T "A Simple IP Security API Extension to BSD Sockets" .%R internet draft .%N "draft-mcdonald-simple-ipsec-api-03.txt" .%O work in progress material .Re .Sh CAVEAT The IPsec support is subject to change as the IPsec protocols develop.
p There is no single standard for policy engine API, so the policy engine API described herein is just for KAME implementation.
p
AH tunnel may not work as you might expect.
Packets will be exchanged just fine, however,
policy engine will not consider the encapsulated packet to be authentic.
.Sh HISTORY
The implementation described herein appeared in WIDE/KAME IPv6/IPsec stack.