1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
.\" $OpenBSD: sec.4,v 1.6 2024/09/20 01:15:53 dlg Exp $
.\"
.\" Copyright (c) 2023 David Gwynne <dlg@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: September 20 2024 $
.Dt SEC 4
.Os
.Sh NAME
.Nm sec
.Nd route based IPsec VPN tunnel interface pseudo-device
.Sh SYNOPSIS
.Cd "pseudo-device sec"
.Sh DESCRIPTION
The
.Nm
driver provides point-to-point tunnel interfaces for IPv4 and IPv6
protected by the
.Xr ipsec 4
Encapsulating Security Payload (ESP)
protocol.
.Pp
Traffic is encapsulated in the ESP protocol and forwarded to the
remote endpoint by routing over a
.Nm
interface rather than matching policy in the IPsec Security Policy
Database (SPD).
.Nm
interfaces require the configuration of IPsec Security Associations (SAs)
.\" with the interface extension
between the local and remote endpoints.
Negotiation of interface SAs is supported by
.Xr iked 8
and
.Xr isakmpd 8
(the latter via
.Xr ipsecctl 8 ) .
.\" These IPsec IKE daemons negotiate ESP tunnel mode between 0.0.0.0/0
.\" and 0.0.0.0/0.
.Pp
.Nm
interfaces can be created at runtime using the
.Ic ifconfig sec Ns Ar N Ic create
command or by setting up a
.Xr hostname.if 5
configuration file for
.Xr netstart 8 .
The interface itself can be configured with
.Xr ifconfig 8 ;
see its manual page for more information.
.Sh EXAMPLES
.Nm
can be used to provide secure and confidential IP connectivity
between sites over the public internet.
For example, a cloud provider may provide connectivity between
networks they host for a customer, and that customers own
.Dq on premises
networks using IPsec tunnels.
.Ox
can be set up on the customer side given the following parameters:
.Pp
.Bl -tag -width Customer-Gateway -offset indent -compact
.It Pre-Shared Key
7kA7evdkd50Q5YdCCF9t8eftgEgL4vk2
.El
.Pp
Outside IP Addresses:
.Bl -tag -width Customer-Gateway -offset indent -compact
.It Customer Gateway
192.0.2.8
.It Provider Gateway
198.51.100.14
.El
.Pp
Inside IP Addresses:
.Bl -tag -width Customer-Gateway -offset indent -compact
.It Customer Gateway
169.254.229.42/30
.It Provider Gateway
169.254.229.41/30
.El
.Pp
A
.Nm
interface can be configured on the customer gateway:
.Bd -literal -offset indent
# ifconfig sec0 create
# ifconfig sec0 inet 169.254.229.42/30 169.254.229.41
# ifconfig sec0 up
.Ed
.Pp
.Xr iked 8
can be used for IKEv2 negotiation of the IPsec tunnel with the following
.Xr iked.conf 5
configuration:
.Bd -literal -offset indent
ikev2 "s2s" active \\
from any to any \\
local 192.0.2.8 peer 198.51.100.14 \\
psk "7kA7evdkd50Q5YdCCF9t8eftgEgL4vk2" \\
iface sec0
.Ed
.Pp
Alternatively, IKEv1 negotiation of the IPsec tunnel SAs is supported by
.Xr isakmpd 8
and
.Xr ipsecctl 8 .
The equivalent
.Xr ipsec.conf 5
configuration for the given parameters follows:
.Bd -literal -offset indent
ike interface sec0 \\
local 192.0.2.8 peer 198.51.100.14 \\
psk "7kA7evdkd50Q5YdCCF9t8eftgEgL4vk2"
.Ed
.Pp
Once the Security Associations are established, communication between
the customer and provider gateways is enabled.
.Pp
Routes to networks hosted by the provider can be added using the
providers
.Dq inside IP
address as the gateway address, or negotiated using a dynamic routing
protocol.
Multiple
.Nm
interfaces may be configured to talk to separate provider gateways,
providing redundancy or multiple paths between sites.
.Sh SEE ALSO
.Xr ipsec 4 ,
.Xr netintro 4 ,
.Xr hostname.if 5 ,
.Xr pf.conf 5 ,
.Xr ifconfig 8 ,
.Xr iked 8 ,
.Xr ipsecctl 8 ,
.Xr isakmpd 8 ,
.Xr netstart 8
.Sh HISTORY
The
.Nm
driver first appeared in
.Ox 7.4 .
.Sh AUTHORS
.An David Gwynne Aq Mt dlg@openbsd.org .
|