xref: /openbsd-src/sbin/ipsecctl/ipsec.conf.5 (revision 2c96ffb07232d88bbb63ea8371c25c6b30646dd7)
1*2c96ffb0Stb.\"	$OpenBSD: ipsec.conf.5,v 1.163 2022/02/04 07:59:54 tb Exp $
2f484f2cfShshoexer.\"
3f484f2cfShshoexer.\" Copyright (c) 2004 Mathieu Sauve-Frankel  All rights reserved.
4f484f2cfShshoexer.\"
5f484f2cfShshoexer.\" Redistribution and use in source and binary forms, with or without
6f484f2cfShshoexer.\" modification, are permitted provided that the following conditions
7f484f2cfShshoexer.\" are met:
8f484f2cfShshoexer.\" 1. Redistributions of source code must retain the above copyright
9f484f2cfShshoexer.\"    notice, this list of conditions and the following disclaimer.
10f484f2cfShshoexer.\" 2. Redistributions in binary form must reproduce the above copyright
11f484f2cfShshoexer.\"    notice, this list of conditions and the following disclaimer in the
12f484f2cfShshoexer.\"    documentation and/or other materials provided with the distribution.
13f484f2cfShshoexer.\"
14f484f2cfShshoexer.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15f484f2cfShshoexer.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16f484f2cfShshoexer.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17f484f2cfShshoexer.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18f484f2cfShshoexer.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19f484f2cfShshoexer.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20f484f2cfShshoexer.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21f484f2cfShshoexer.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22f484f2cfShshoexer.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23f484f2cfShshoexer.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24f484f2cfShshoexer.\"
25*2c96ffb0Stb.Dd $Mdocdate: February 4 2022 $
26f484f2cfShshoexer.Dt IPSEC.CONF 5
27f484f2cfShshoexer.Os
28f484f2cfShshoexer.Sh NAME
29f484f2cfShshoexer.Nm ipsec.conf
30f484f2cfShshoexer.Nd IPsec configuration file
31f484f2cfShshoexer.Sh DESCRIPTION
320919a08fShshoexerThe
33f380e337Sjmc.Nm
341baef1adSjmcfile specifies rules and definitions for IPsec,
351baef1adSjmcwhich provides security services for IP datagrams.
361baef1adSjmcIPsec itself is a pair of protocols:
371baef1adSjmcEncapsulating Security Payload (ESP),
381baef1adSjmcwhich provides integrity and confidentiality;
391baef1adSjmcand Authentication Header (AH),
401baef1adSjmcwhich provides integrity.
41fa7bea3cSjmcThe IPsec protocol itself is described in
42fa7bea3cSjmc.Xr ipsec 4 .
431baef1adSjmc.Pp
441baef1adSjmcIn its most basic form, a
451baef1adSjmc.Em flow
461baef1adSjmcis established between hosts and/or networks,
479772ab45Sjmcand then Security Associations (SAs) are established,
481baef1adSjmcwhich detail how the desired protection will be achieved.
492aa0310cSjmcIPsec uses flows
502aa0310cSjmcto determine whether to apply security services to an IP packet or not.
511baef1adSjmc.Pp
521baef1adSjmcGenerally speaking
531baef1adSjmcan automated keying daemon,
541baef1adSjmcsuch as
551baef1adSjmc.Xr isakmpd 8 ,
56fa7bea3cSjmcis used to set up flows and establish SAs,
57fa7bea3cSjmcby specifying an
58fa7bea3cSjmc.Sq ike
59fa7bea3cSjmcline in
60fa7bea3cSjmc.Nm
61fa7bea3cSjmc(see
62fa7bea3cSjmc.Sx AUTOMATIC KEYING ,
63fa7bea3cSjmcbelow).
64fa7bea3cSjmcAn authentication method,
65fa7bea3cSjmcsuch as public key authentication,
66fa7bea3cSjmcwill also have to be set up:
6760addc80Sjmcsee the PKI section of
68fa7bea3cSjmc.Xr isakmpd 8
69fa7bea3cSjmcfor information on the types of authentication available,
70fa7bea3cSjmcand the procedures for setting them up.
71f7eb6930Sjmc.Pp
72f7eb6930SjmcThe keying daemon,
73f7eb6930Sjmc.Xr isakmpd 8 ,
74f2cc1b42Slandrycan be enabled to run at boot time via
75f2cc1b42Slandry.Dq rcctl enable isakmpd .
76f2cc1b42SlandryNote that to avoid
771baef1adSjmc.Xr keynote 4
78f2cc1b42Slandrypolicy checking, it will probably need to be run with at least the
79f2cc1b42Slandry.Fl K
80f2cc1b42Slandryoption via the
81f2cc1b42Slandry.Dq rcctl set isakmpd flags -K
82f2cc1b42Slandrycommand which sets
83f2cc1b42Slandry.Pp
84f2cc1b42Slandry.Dl isakmpd_flags=\(dq-K\(dq
85f2cc1b42Slandry.Pp
86f2cc1b42Slandryin
87f2cc1b42Slandry.Xr rc.conf.local 8 .
88f7eb6930SjmcThe
89f7eb6930Sjmc.Nm
90f7eb6930Sjmcconfiguration itself is loaded at boot time
91f2cc1b42Slandryif IPsec is enabled by using
92f2cc1b42Slandry.Dq rcctl enable ipsec ,
93f2cc1b42Slandrywhich sets
94f2cc1b42Slandry.Pp
95f2cc1b42Slandry.Dl ipsec=YES
96f2cc1b42Slandry.Pp
97f7eb6930Sjmcin
98f7eb6930Sjmc.Xr rc.conf.local 8 .
99f7eb6930SjmcA utility called
100f7eb6930Sjmc.Xr ipsecctl 8
101f7eb6930Sjmcis also available to load
102f7eb6930Sjmc.Nm
103f7eb6930Sjmcconfigurations, and can additionally be used
104f7eb6930Sjmcto view and modify IPsec flows.
1051baef1adSjmc.Pp
1061baef1adSjmcAn alternative method of setting up SAs is also possible using
1071baef1adSjmcmanual keying.
108f7eb6930SjmcManual keying is not recommended,
109f7eb6930Sjmcbut can be convenient for quick setups and testing.
110f7eb6930SjmcThose procedures are documented within this page.
1112c86728eSjmc.Sh IPSEC.CONF FILE FORMAT
112eb8de641SsthenThe current line can be extended over multiple lines using a backslash
113eb8de641Ssthen.Pq Sq \e .
114eb8de641SsthenComments can be put anywhere in the file using a hash mark
115eb8de641Ssthen.Pq Sq # ,
116eb8de641Ssthenand extend to the end of the current line.
117eb8de641SsthenCare should be taken when commenting out multi-line text:
118eb8de641Ssthenthe comment is effective until the end of the entire block.
1193ec91679Sjmc.Pp
120242e3f46SjmcArgument names not beginning with a letter, digit, or underscore
121242e3f46Sjmcmust be quoted.
122242e3f46Sjmc.Pp
1233ec91679SjmcAddresses can be specified in CIDR notation (matching netblocks),
1243ec91679Sjmcas symbolic host names, interface names, or interface group names.
1253ec91679Sjmc.Pp
1263ec91679SjmcCertain parameters can be expressed as lists, in which case
1273ec91679Sjmc.Xr ipsecctl 8
1283ec91679Sjmcgenerates all the necessary combinations.
1293ec91679SjmcFor example:
1303ec91679Sjmc.Bd -literal -offset indent
1313ec91679Sjmcike esp from {192.168.1.1, 192.168.1.2} to \e
1323ec91679Sjmc	{10.0.0.17, 10.0.0.18} peer 192.168.10.1
1333ec91679Sjmc.Ed
1343ec91679Sjmc.Pp
1353ec91679SjmcWill expand to:
1363ec91679Sjmc.Bd -literal -offset indent
1373ec91679Sjmcike esp from 192.168.1.1 to 10.0.0.17 peer 192.168.10.1
1383ec91679Sjmcike esp from 192.168.1.1 to 10.0.0.18 peer 192.168.10.1
1393ec91679Sjmcike esp from 192.168.1.2 to 10.0.0.17 peer 192.168.10.1
1403ec91679Sjmcike esp from 192.168.1.2 to 10.0.0.18 peer 192.168.10.1
1413ec91679Sjmc.Ed
1423ec91679Sjmc.Pp
143086a4d69SjmcMacros can be defined that will later be expanded in context.
144242e3f46SjmcMacro names must start with a letter, digit, or underscore,
145242e3f46Sjmcand may contain any of those characters.
1463d351c90SreykMacro names may not be reserved words (for example
14779c3e352Sjmc.Ic flow ,
14879c3e352Sjmc.Ic from ,
14979c3e352Sjmc.Ic esp ) .
1503d351c90SreykMacros are not expanded inside quotes.
1513d351c90Sreyk.Pp
15255ece517SjmcFor example:
1533d351c90Sreyk.Bd -literal -offset indent
15455ece517Sjmcremote_gw = "192.168.3.12"
1553d351c90Sreykflow esp from 192.168.7.0/24 to 192.168.8.0/24 peer $remote_gw
1563d351c90Sreyk.Ed
1570e382bbfSreyk.Pp
1580e382bbfSreykAdditional configuration files can be included with the
1590e382bbfSreyk.Ic include
1600e382bbfSreykkeyword, for example:
1610e382bbfSreyk.Bd -literal -offset indent
1620e382bbfSreykinclude "/etc/macros.conf"
1630e382bbfSreyk.Ed
1649f98aabfSjmc.Sh AUTOMATIC KEYING
1650d9e70aaSjmcIn this scenario,
1660d9e70aaSjmc.Nm
1670d9e70aaSjmcis used to set up flows and SAs automatically using
168df7849f0Sreyk.Xr isakmpd 8
169df7849f0Sreykwith the ISAKMP/Oakley a.k.a. IKEv1 protocol.
170df7849f0SreykTo configure automatic keying using the IKEv2 protocol, see
171df7849f0Sreyk.Xr iked.conf 5
172df7849f0Sreykinstead.
17370d92abaSjmcSome examples of setting up automatic keying:
1749f98aabfSjmc.Bd -literal -offset 3n
175bb599165Sjmc# Set up a VPN:
176bb599165Sjmc# First between the gateway machines 192.168.3.1 and 192.168.3.2
17770d92abaSjmc# Second between the networks 10.1.1.0/24 and 10.1.2.0/24
1789f98aabfSjmcike esp from 192.168.3.1 to 192.168.3.2
17970d92abaSjmcike esp from 10.1.1.0/24 to 10.1.2.0/24 peer 192.168.3.2
1809f98aabfSjmc.Ed
1819f98aabfSjmc.Pp
1823ec91679SjmcThe commands are as follows:
18368ef0603Shshoexer.Bl -tag -width xxxx
1840b981053Sjmc.It Xo
1850b981053Sjmc.Ic ike
1860b981053Sjmc.Op Ar mode
1870b981053Sjmc.Op Ar encap
1880b981053Sjmc.Op Ar tmode
1890b981053Sjmc.Xc
1900b981053Sjmc.Ar mode
191df7849f0Sreykspecifies the IKEv1 mode to use:
1920b981053Sjmcone of
1930b981053Sjmc.Ar passive ,
1940b981053Sjmc.Ar active ,
1950b981053Sjmcor
1960b981053Sjmc.Ar dynamic .
19768ef0603ShshoexerWhen
19868ef0603Shshoexer.Ar passive
199101a3da2Sreykis specified,
20068ef0603Shshoexer.Xr isakmpd 8
20168ef0603Shshoexerwill not immediately start negotiation of this tunnel, but wait for an incoming
20209712fbdSjmcrequest from the remote peer.
203101a3da2SreykWhen
204101a3da2Sreyk.Ar active
205101a3da2Sreykor
206101a3da2Sreyk.Ar dynamic
207101a3da2Sreykis specified, negotiation will be started at once.
208101a3da2SreykThe
209101a3da2Sreyk.Ar dynamic
210101a3da2Sreykmode will additionally enable Dead Peer Detection (DPD) and use the
21178e88d97Sdavidlocal hostname as the identity of the local peer, if not specified by
212101a3da2Sreykthe
2130b981053Sjmc.Ic srcid
214101a3da2Sreykparameter.
215101a3da2Sreyk.Ar dynamic
216101a3da2Sreykmode should be used for hosts with dynamic IP addresses like road
217101a3da2Sreykwarriors or dialup hosts.
218101a3da2SreykIf omitted,
219101a3da2Sreyk.Ar active
220101a3da2Sreykmode will be used.
221ec1b78e4Sjmc.Pp
2220b981053Sjmc.Ar encap
2230b981053Sjmcspecifies the encapsulation protocol to be used.
22411a1b5c9SnaddyPossible protocols are
22511a1b5c9Snaddy.Ar esp
22611a1b5c9Snaddyand
2270b981053Sjmc.Ar ah ;
2280b981053Sjmcthe default is
22911a1b5c9Snaddy.Ar esp .
2300b981053Sjmc.Pp
2310b981053Sjmc.Ar tmode
2320b981053Sjmcdescribes the encapsulation mode to be used.
2335432b47aSnaddyPossible modes are
2345432b47aSnaddy.Ar tunnel
2355432b47aSnaddyand
2360b981053Sjmc.Ar transport ;
2370b981053Sjmcthe default is
2380b981053Sjmc.Ar tunnel .
239c009571eSjmc.It Ic proto Ar protocol
2404fad32afSmarkusThe optional
24179c3e352Sjmc.Ic proto
2424fad32afSmarkusparameter restricts the flow to a specific IP protocol.
2434fad32afSmarkusCommon protocols are
2444fad32afSmarkus.Xr icmp 4 ,
2454fad32afSmarkus.Xr tcp 4 ,
2464fad32afSmarkusand
2474fad32afSmarkus.Xr udp 4 .
2484fad32afSmarkusFor a list of all the protocol name to number mappings used by
2494fad32afSmarkus.Xr ipsecctl 8 ,
2504fad32afSmarkussee the file
251164aef54Sjmc.Pa /etc/protocols .
25268ef0603Shshoexer.It Xo
253c009571eSjmc.Ic from Ar src
254c009571eSjmc.Op Ic port Ar sport
255ad80fffdSjmc.Op Pq Ar srcnat
256c009571eSjmc.Ic to Ar dst
257c009571eSjmc.Op Ic port Ar dport
25868ef0603Shshoexer.Xc
25968ef0603ShshoexerThis rule applies for packets with source address
260c009571eSjmc.Ar src
26168ef0603Shshoexerand destination address
262c009571eSjmc.Ar dst .
26365d3656aShshoexerThe keyword
26465d3656aShshoexer.Ar any
26565d3656aShshoexerwill match any address (i.e. 0.0.0.0/0).
266c471c043SmpfIf the
267c471c043Smpf.Ar src
268c471c043Smpfargument specifies a fictional source ID,
269c471c043Smpfthe
270c471c043Smpf.Ar srcnat
271c471c043Smpfparameter can be used to specify the actual source address.
27299237e78SjmcThis can be used in outgoing NAT/BINAT scenarios as described below in
27399237e78Sjmc.Sx OUTGOING NETWORK ADDRESS TRANSLATION .
274c471c043SmpfHost addresses are parsed as type
275ead691f0Shshoexer.Dq IPV4_ADDR ;
276ead691f0Shshoexeradding the suffix /32 will change the type to
277ead691f0Shshoexer.Dq IPV4_ADDR_SUBNET ,
278df7849f0Sreykwhich can improve interoperability with some IKEv1 implementations.
279c471c043Smpf.Pp
280bd77874dSnaddyThe optional
281bd77874dSnaddy.Ic port
282bd77874dSnaddymodifiers restrict the flows to the specified ports.
283bd77874dSnaddyThey are only valid in conjunction with the
284bd77874dSnaddy.Xr tcp 4
285bd77874dSnaddyand
286bd77874dSnaddy.Xr udp 4
287bd77874dSnaddyprotocols.
288bd77874dSnaddyPorts can be specified by number or by name.
289bd77874dSnaddyFor a list of all port name to number mappings used by
290bd77874dSnaddy.Xr ipsecctl 8 ,
291bd77874dSnaddysee the file
292bd77874dSnaddy.Pa /etc/services .
2930b981053Sjmc.It Ic local Ar localip Ic peer Ar remote
29468ef0603ShshoexerThe
29579c3e352Sjmc.Ic local
296d97b5a7fSjmcparameter specifies the address or FQDN of the local endpoint.
297d97b5a7fSjmcUnless we are multi-homed or have aliases,
29889adc933Sstspthis parameter is generally not needed.
29989adc933SstspThis parameter does not affect the set of IP addresses
30089adc933Sstsp.Xr isakmpd 8
30189adc933Sstspwill listen on and send packets from.
30289adc933SstspThe
30389adc933Sstsp.Em Listen-on
30489adc933Sstspdirective in
30589adc933Sstsp.Xr isakmpd.conf 5
30689adc933Sstspshould additionally be used to ensure that the local endpoint will
30789adc933Sstspsend IKE messages with an appropriate source IP address.
3080b981053Sjmc.Pp
3095cc8dc1aShshoexerThe
31079c3e352Sjmc.Ic peer
311d97b5a7fSjmcparameter specifies the address or FQDN of the remote endpoint.
31268ef0603ShshoexerFor host-to-host connections where
313c009571eSjmc.Ar dst
31468ef0603Shshoexeris identical to
315c009571eSjmc.Ar remote ,
316cbdee783Sbluhmthis option is generally not needed as it will be set to
317cbdee783Sbluhm.Ar dst
318cbdee783Sbluhmautomatically.
319cbdee783SbluhmIf it is not specified or if the keyword
320cbdee783Sbluhm.Ar any
321cbdee783Sbluhmis given, the default peer is used.
32268ef0603Shshoexer.It Xo
3231c4843d7Sjmc.Ar mode
3241c4843d7Sjmc.Ic auth Ar algorithm
325c009571eSjmc.Ic enc Ar algorithm
326c009571eSjmc.Ic group Ar group
32745afb999Smikeb.Ic lifetime Ar time
32868ef0603Shshoexer.Xc
329336f7f89SmcbrideThese parameters define the mode and cryptographic transforms to be
330336f7f89Smcbrideused for the phase 1 negotiation.
33167ae5c53SjmcDuring phase 1
33267ae5c53Sjmcthe machines authenticate and set up an encrypted channel.
33367ae5c53Sjmc.Pp
334336f7f89SmcbrideThe mode can be either
335336f7f89Smcbride.Ar main ,
336336f7f89Smcbridewhich specifies main mode, or
337336f7f89Smcbride.Ar aggressive ,
338336f7f89Smcbridewhich specifies aggressive mode.
33968ef0603ShshoexerPossible values for
3408814d473Sjmc.Ic auth ,
3418814d473Sjmc.Ic enc ,
34268ef0603Shshoexerand
34379c3e352Sjmc.Ic group
3448814d473Sjmcare described below in
3458814d473Sjmc.Sx CRYPTO TRANSFORMS .
3468814d473Sjmc.Pp
34745afb999SmikebThe
34845afb999Smikeb.Ic lifetime
34945afb999Smikebparameter specifies the phase 1 lifetime in seconds.
3501955ce79SlteoTwo unit specifiers are recognized (ignoring case):
35145afb999Smikeb.Ql m
35245afb999Smikeband
35345afb999Smikeb.Ql h
35445afb999Smikebfor minutes and hours, respectively.
35545afb999Smikeb.Pp
35668ef0603ShshoexerIf omitted,
3578e6bfe25Shshoexer.Xr ipsecctl 8
35868ef0603Shshoexerwill use the default values
359336f7f89Smcbride.Ar main ,
36055ece517Sjmc.Ar hmac-sha1 ,
36155ece517Sjmc.Ar aes ,
362bf14ca98Snaddy.Ar modp3072 ,
3638814d473Sjmcand
36445afb999Smikeb.Ar 3600 .
36568ef0603Shshoexer.It Xo
366c009571eSjmc.Ic quick auth Ar algorithm
367c009571eSjmc.Ic enc Ar algorithm
368c009571eSjmc.Ic group Ar group
36945afb999Smikeb.Ic lifetime Ar time
37068ef0603Shshoexer.Xc
3718814d473SjmcThese parameters define the cryptographic transforms to be used for
372336f7f89Smcbridethe phase 2 negotiation.
37367ae5c53SjmcDuring phase 2
37467ae5c53Sjmcthe actual IPsec negotiations happen.
37567ae5c53Sjmc.Pp
3768814d473SjmcPossible values for
3778814d473Sjmc.Ic auth ,
3788814d473Sjmc.Ic enc ,
37968ef0603Shshoexerand
38079c3e352Sjmc.Ic group
3818814d473Sjmcare described below in
3828814d473Sjmc.Sx CRYPTO TRANSFORMS .
3831244bb4cSsobradoPerfect Forward Secrecy (PFS) is enabled unless
38445afb999Smikeb.Ic group Ar none
38545afb999Smikebis specified.
38645afb999Smikeb.Pp
38745afb999SmikebThe
38845afb999Smikeb.Ic lifetime
3891955ce79Slteoparameter specifies the phase 2 lifetime in seconds.
3901955ce79SlteoTwo unit specifiers are recognized (ignoring case):
39145afb999Smikeb.Ql m
39245afb999Smikeband
39345afb999Smikeb.Ql h
39445afb999Smikebfor minutes and hours, respectively.
3958814d473Sjmc.Pp
3968814d473SjmcIf omitted,
3978814d473Sjmc.Xr ipsecctl 8
3988814d473Sjmcwill use the default values
3997b723bfeShshoexer.Ar hmac-sha2-256
400791b89f7Shshoexerand
4018814d473Sjmc.Ar aes ;
40255ece517SjmcPFS will only be used if the remote side requests it.
40345afb999SmikebThe default phase 2 lifetime value is
40445afb999Smikeb.Ar 1200 .
4050b981053Sjmc.It Ic srcid Ar string Ic dstid Ar string
4060b981053Sjmc.Ic srcid
4070b981053Sjmcdefines an ID of type
408d894c12dSjmc.Dq USER_FQDN
409d894c12dSjmcor
410d894c12dSjmc.Dq FQDN
411d894c12dSjmcthat will be used by
41268ef0603Shshoexer.Xr isakmpd 8
41309712fbdSjmcas the identity of the local peer.
414d894c12dSjmcIf the argument is an email address (bob@example.com),
415d894c12dSjmc.Xr ipsecctl 8
416d894c12dSjmcwill use USER_FQDN as the ID type.
41788635086SmsfAnything else is considered to be an FQDN.
418d894c12dSjmcIf
419d894c12dSjmc.Ic srcid
420d894c12dSjmcis omitted,
421d894c12dSjmcthe default is to use the IP address of the connecting machine.
4220b981053Sjmc.Pp
4230b981053Sjmc.Ic dstid
4240b981053Sjmcis similar to
42579c3e352Sjmc.Ic srcid ,
4260b981053Sjmcbut instead specifies the ID to be used
427d894c12dSjmcby the remote peer.
428c009571eSjmc.It Ic psk Ar string
429aa4503c0SreykUse a pre-shared key
430aa4503c0Sreyk.Ar string
431aa4503c0Sreykfor authentication.
432d97b5a7fSjmcIf this option is not specified,
433d97b5a7fSjmcpublic key authentication is used (see
434d97b5a7fSjmc.Xr isakmpd 8 ) .
435aa920ac7Sreyk.It Ic tag Ar string
436aa920ac7SreykAdd a
437aa920ac7Sreyk.Xr pf 4
438aa920ac7Sreyktag to all packets of phase 2 SAs created for this connection.
439aa920ac7SreykThis will allow matching packets for this connection by defining
440aa920ac7Sreykrules in
441aa920ac7Sreyk.Xr pf.conf 5
442aa920ac7Sreykusing the
443aa920ac7Sreyk.Cm tagged
444aa920ac7Sreykkeyword.
445aa920ac7Sreyk.Pp
446aa920ac7SreykThe following variables can be used in tags to include information
447aa920ac7Sreykfrom the remote peer on runtime:
448aa920ac7Sreyk.Pp
449aa920ac7Sreyk.Bl -tag -width $domain -compact -offset indent
450aa920ac7Sreyk.It Ar $id
451aa920ac7SreykThe remote phase 1 ID.
452aa920ac7SreykIt will be expanded to
453aa920ac7Sreyk.Ar id-type/id-value ,
454aa920ac7Sreyke.g.\&
455aa920ac7Sreyk.Ar fqdn/foo.bar.org .
456aa920ac7Sreyk.It Ar $domain
457aa920ac7SreykExtract the domain from IDs of type FQDN or UFQDN.
458aa920ac7Sreyk.El
459aa920ac7Sreyk.Pp
460aa920ac7SreykFor example, if the ID is
461aa920ac7Sreyk.Ar fqdn/foo.bar.org
462aa920ac7Sreykor
463aa920ac7Sreyk.Ar ufqdn/user@bar.org ,
464aa920ac7Sreyk.Dq ipsec-$domain
465aa920ac7Sreykexpands to
466aa920ac7Sreyk.Dq ipsec-bar.org .
467aa920ac7SreykThe variable expansion for the
468aa920ac7Sreyk.Ar tag
469521965d7Skndirective occurs only at runtime (not when the file is parsed)
470521965d7Sknand must be quoted, or it will be interpreted as a macro.
471aa4503c0Sreyk.El
4725cae4fc4Sjmc.Sh PACKET FILTERING
4735cae4fc4SjmcIPsec traffic appears unencrypted on the
4745cae4fc4Sjmc.Xr enc 4
4755cae4fc4Sjmcinterface
4765cae4fc4Sjmcand can be filtered accordingly using the
4775cae4fc4Sjmc.Ox
4785cae4fc4Sjmcpacket filter,
4795cae4fc4Sjmc.Xr pf 4 .
4805cae4fc4SjmcThe grammar for the packet filter is described in
4815cae4fc4Sjmc.Xr pf.conf 5 .
4825cae4fc4Sjmc.Pp
483dca6c689SjmcThe following components are relevant to filtering IPsec traffic:
484dca6c689Sjmc.Bl -ohang -offset indent
485dca6c689Sjmc.It external interface
486dca6c689SjmcInterface for ISAKMP traffic and encapsulated IPsec traffic.
487dca6c689Sjmc.It proto udp port 500
488dca6c689SjmcISAKMP traffic on the external interface.
489dca6c689Sjmc.It proto udp port 4500
490dca6c689SjmcISAKMP NAT-Traversal traffic on the external interface.
4919dbd6965Sbentley.It proto ah | esp
492dca6c689SjmcEncapsulated IPsec traffic
493dca6c689Sjmcon the external interface.
494dca6c689Sjmc.It enc0
495dca6c689SjmcInterface for outgoing traffic before it's been encapsulated,
496dca6c689Sjmcand incoming traffic after it's been decapsulated.
497c206d1e0SjmcState on this interface should be interface bound;
498c206d1e0Sjmcsee
499c206d1e0Sjmc.Xr enc 4
500c206d1e0Sjmcfor further information.
501dca6c689Sjmc.It proto ipencap
502dca6c689Sjmc[tunnel mode only]
503dca6c689SjmcIP-in-IP traffic flowing between gateways
504dca6c689Sjmcon the enc0 interface.
505aa920ac7Sreyk.It tagged ipsec-example.org
506aa920ac7SreykMatch traffic of phase 2 SAs using the
507aa920ac7Sreyk.Ic tag
508aa920ac7Sreykkeyword.
509dca6c689Sjmc.El
510dca6c689Sjmc.Pp
5115cae4fc4SjmcIf the filtering rules specify to block everything by default,
5125cae4fc4Sjmcthe following rule
5135cae4fc4Sjmcwould ensure that IPsec traffic never hits the packet filtering engine,
5145cae4fc4Sjmcand is therefore passed:
5155cae4fc4Sjmc.Bd -literal -offset indent
5165cae4fc4Sjmcset skip on enc0
5175cae4fc4Sjmc.Ed
5185cae4fc4Sjmc.Pp
5195cae4fc4SjmcIn the following example, all traffic is blocked by default.
520dca6c689SjmcIPsec-related traffic from gateways {192.168.3.1, 192.168.3.2} and
5215cae4fc4Sjmcnetworks {10.0.1.0/24, 10.0.2.0/24} is permitted.
5225cae4fc4Sjmc.Bd -literal -offset indent
5235cae4fc4Sjmcblock on sk0
5245cae4fc4Sjmcblock on enc0
5255cae4fc4Sjmc
5265cae4fc4Sjmcpass  in on sk0 proto udp from 192.168.3.2 to 192.168.3.1 \e
5275cae4fc4Sjmc	port {500, 4500}
5285cae4fc4Sjmcpass out on sk0 proto udp from 192.168.3.1 to 192.168.3.2 \e
5295cae4fc4Sjmc	port {500, 4500}
5305cae4fc4Sjmc
531dca6c689Sjmcpass  in on sk0 proto esp from 192.168.3.2 to 192.168.3.1
532dca6c689Sjmcpass out on sk0 proto esp from 192.168.3.1 to 192.168.3.2
53393997790Sjmc
53493997790Sjmcpass  in on enc0 proto ipencap from 192.168.3.2 to 192.168.3.1 \e
53593997790Sjmc	keep state (if-bound)
53693997790Sjmcpass out on enc0 proto ipencap from 192.168.3.1 to 192.168.3.2 \e
53793997790Sjmc	keep state (if-bound)
53893997790Sjmcpass  in on enc0 from 10.0.2.0/24 to 10.0.1.0/24 \e
53993997790Sjmc	keep state (if-bound)
54093997790Sjmcpass out on enc0 from 10.0.1.0/24 to 10.0.2.0/24 \e
54193997790Sjmc	keep state (if-bound)
5425cae4fc4Sjmc.Ed
5435cae4fc4Sjmc.Pp
54493997790Sjmc.Xr pf 4
545aa920ac7Sreykhas the ability to filter IPsec-related packets
546aa920ac7Sreykbased on an arbitrary
547aa920ac7Sreyk.Em tag
548aa920ac7Sreykspecified within a ruleset.
549aa920ac7SreykThe tag is used as an internal marker
550aa920ac7Sreykwhich can be used to identify the packets later on.
551aa920ac7SreykThis could be helpful,
552aa920ac7Sreykfor example,
553aa920ac7Sreykin scenarios where users are connecting in from differing IP addresses,
554aa920ac7Sreykor to support queue-based bandwidth control,
555aa920ac7Sreyksince the enc0 interface does not support it.
556aa920ac7Sreyk.Pp
557aa920ac7SreykThe following
558aa920ac7Sreyk.Xr pf.conf 5
559aa920ac7Sreykfragment uses queues for all IPsec traffic with special
560aa920ac7Sreykhandling for developers and employees:
561aa920ac7Sreyk.Bd -literal -offset indent
5625e8568e2Shenningqueue std on sk0 bandwidth 100M
5635e8568e2Shenningqueue   deflt parent std bandwidth 10M default
5645e8568e2Shenningqueue   developers parent std bandwidth 75M
5655e8568e2Shenningqueue   employees parent std bandwidth 5M
5665e8568e2Shenningqueue   ipsec parent std bandwidth 10M
567aa920ac7Sreyk
5685e8568e2Shenningpass out on sk0 proto esp set queue ipsec
569aa920ac7Sreyk
5705e8568e2Shenningpass out on sk0 tagged ipsec-developers.bar.org set queue developers
5715e8568e2Shenningpass out on sk0 tagged ipsec-employees.bar.org set queue employees
572aa920ac7Sreyk.Ed
573aa920ac7Sreyk.Pp
574aa920ac7SreykThe tags will be assigned by the following
575aa920ac7Sreyk.Nm
576aa920ac7Sreykexample:
577aa920ac7Sreyk.Bd -literal -offset indent
578aa920ac7Sreykike esp from 10.1.1.0/24 to 10.1.2.0/24 peer 192.168.3.2 \e
579521965d7Skn	tag "ipsec-$domain"
580aa920ac7Sreyk.Ed
581c471c043Smpf.Sh OUTGOING NETWORK ADDRESS TRANSLATION
582c471c043SmpfIn some network topologies it is desirable to perform NAT on traffic leaving
583c471c043Smpfthrough the VPN tunnel.
584c471c043SmpfIn order to achieve that,
585c471c043Smpfthe
586c471c043Smpf.Ar src
587c471c043Smpfargument is used to negotiate the desired network ID with the peer
588c471c043Smpfand the
589c471c043Smpf.Ar srcnat
590c471c043Smpfparameter defines the true local subnet,
591c471c043Smpfso that a correct SA can be installed on the local side.
592c471c043Smpf.Pp
593c471c043SmpfFor example,
594c471c043Smpfif the local subnet is 192.168.1.0/24 and all the traffic
595c471c043Smpffor a specific VPN peer should appear as coming from 10.10.10.1,
596c471c043Smpfthe following configuration is used:
597c471c043Smpf.Bd -literal -offset indent
598c471c043Smpfike esp from 10.10.10.1 (192.168.1.0/24) to 192.168.2.0/24 \e
599c471c043Smpf	peer 10.10.20.1
600c471c043Smpf.Ed
601c471c043Smpf.Pp
602c471c043SmpfNaturally,
603c471c043Smpfa relevant NAT rule is required in
604c471c043Smpf.Xr pf.conf 5 .
605c471c043SmpfFor the example above,
606c471c043Smpfthis would be:
607c471c043Smpf.Bd -literal -offset indent
608b3234563Ssthenmatch out on enc0 from 192.168.1.0/24 to 192.168.2.0/24 \e
609b3234563Ssthen	nat-to 10.10.10.1
610c471c043Smpf.Ed
611c471c043Smpf.Pp
612c471c043SmpfFrom the peer's point of view,
613c471c043Smpfthe local end of the VPN tunnel is declared to be 10.10.10.1
614c471c043Smpfand all the traffic arrives with that source address.
6155cae4fc4Sjmc.Sh CRYPTO TRANSFORMS
6165cae4fc4SjmcIt is very important that keys are not guessable.
6175cae4fc4SjmcOne practical way of generating keys is to use
6185cae4fc4Sjmc.Xr openssl 1 .
6195cae4fc4SjmcThe following generates a 160-bit (20-byte) key:
6205cae4fc4Sjmc.Bd -literal -offset indent
6215f649d51Snaddy$ openssl rand -hex 20
6225cae4fc4Sjmc.Ed
6235cae4fc4Sjmc.Pp
6245cae4fc4SjmcThe following authentication types are permitted with the
6255cae4fc4Sjmc.Ic auth
6265cae4fc4Sjmckeyword:
627e324319bSjmc.Bl -column "Authentication" "Key Length" "Description" -offset indent
628e324319bSjmc.It Em "Authentication" Ta Em "Key Length" Ta ""
629e324319bSjmc.It Li hmac-md5 Ta "128 bits" Ta ""
63067ae5c53Sjmc.It Li hmac-ripemd160 Ta "160 bits" Ta "[phase 2 only]"
631e324319bSjmc.It Li hmac-sha1 Ta "160 bits" Ta ""
632e324319bSjmc.It Li hmac-sha2-256 Ta "256 bits" Ta ""
633e324319bSjmc.It Li hmac-sha2-384 Ta "384 bits" Ta ""
634e324319bSjmc.It Li hmac-sha2-512 Ta "512 bits" Ta ""
6355cae4fc4Sjmc.El
6365cae4fc4Sjmc.Pp
6375cae4fc4SjmcThe following cipher types are permitted with the
6385cae4fc4Sjmc.Ic enc
6395cae4fc4Sjmckeyword:
640439349a5Syasuoka.Bl -column "chacha20-poly1305" "128-256 bits" "Description" -offset indent
641e324319bSjmc.It Em "Cipher" Ta Em "Key Length" Ta ""
642e324319bSjmc.It Li 3des Ta "168 bits" Ta ""
643439349a5Syasuoka.It Li aes Ta "128-256 bits" Ta ""
644e324319bSjmc.It Li aes-128 Ta "128 bits" Ta ""
645e324319bSjmc.It Li aes-192 Ta "192 bits" Ta ""
646e324319bSjmc.It Li aes-256 Ta "256 bits" Ta ""
647bda04dedSnaddy.It Li aesctr Ta "160 bits" Ta "[phase 2 only, IKE only]"
648bda04dedSnaddy.It Li aes-128-ctr Ta "160 bits" Ta "[phase 2 only, IKE only]"
649bda04dedSnaddy.It Li aes-192-ctr Ta "224 bits" Ta "[phase 2 only, IKE only]"
650bda04dedSnaddy.It Li aes-256-ctr Ta "288 bits" Ta "[phase 2 only, IKE only]"
651bda04dedSnaddy.It Li aes-128-gcm Ta "160 bits" Ta "[phase 2 only, IKE only]"
652bda04dedSnaddy.It Li aes-192-gcm Ta "224 bits" Ta "[phase 2 only, IKE only]"
653bda04dedSnaddy.It Li aes-256-gcm Ta "288 bits" Ta "[phase 2 only, IKE only]"
654439349a5Syasuoka.It Li blowfish Ta "160 bits" Ta ""
655439349a5Syasuoka.It Li cast128 Ta "128 bits" Ta ""
656439349a5Syasuoka.It Li chacha20-poly1305 Ta "288 bits" Ta ""
657439349a5Syasuoka.El
658439349a5Syasuoka.Pp
659439349a5SyasuokaThe following cipher types provide only authentication, not encryption:
660439349a5Syasuoka.Bl -column "chacha20-poly1305" "128-256 bits" "Description" -offset indent
661bda04dedSnaddy.It Li aes-128-gmac Ta "160 bits" Ta "[phase 2 only, IKE only]"
662bda04dedSnaddy.It Li aes-192-gmac Ta "224 bits" Ta "[phase 2 only, IKE only]"
663bda04dedSnaddy.It Li aes-256-gmac Ta "288 bits" Ta "[phase 2 only, IKE only]"
6642681cd80Shshoexer.It Li null Ta "(none)" Ta "[phase 2 only]"
6655cae4fc4Sjmc.El
6665cae4fc4Sjmc.Pp
667439349a5SyasuokaTransforms followed by
668439349a5Syasuoka.Bq IKE only
669439349a5Syasuokacan only be used with the
670439349a5Syasuoka.Ic ike
67122db0d4bSyasuokakeyword; transforms with
672439349a5Syasuoka.Bq phase 2 only
673439349a5Syasuokacan only be used with the
674439349a5Syasuoka.Ic quick
675439349a5Syasuokakeyword.
676439349a5Syasuoka.Pp
6770e800071Snaddy3DES requires 24 bytes to form its 168-bit key.
6785cae4fc4SjmcThis is because the most significant bit of each byte is used for parity.
6795cae4fc4Sjmc.Pp
680bda04dedSnaddyThe keysize of AES-CTR can be 128, 192, or 256 bits.
681fc61f758ShshoexerHowever as well as the key, a 32-bit nonce has to be supplied.
682bda04dedSnaddyThus 160, 224, or 288 bits of key material, respectively, have to be supplied.
683*2c96ffb0StbThe same applies to AES-GCM, AES-GMAC and ChaCha20-Poly1305,
68422db0d4bSyasuokahowever in the latter case the keysize is 256 bits.
685783454c1Smikeb.Pp
686e7d4b039SmikebUsing AES-GMAC or NULL with ESP will only provide authentication.
687258f075bSjmcThis is useful in setups where AH cannot be used, e.g. when NAT is involved.
6882681cd80Shshoexer.Pp
6895cae4fc4SjmcThe following group types are permitted with the
6905cae4fc4Sjmc.Ic group
6915cae4fc4Sjmckeyword:
692e324319bSjmc.Bl -column "modp1024" "Size" "Description" -offset indent
693e324319bSjmc.It Em Group Ta Em Size Ta ""
694e324319bSjmc.It Li modp768 Ta 768 Ta "[DH group 1]"
695e324319bSjmc.It Li modp1024 Ta 1024 Ta "[DH group 2]"
696e324319bSjmc.It Li modp1536 Ta 1536 Ta "[DH group 5]"
697e324319bSjmc.It Li modp2048 Ta 2048 Ta "[DH group 14]"
698e324319bSjmc.It Li modp3072 Ta 3072 Ta "[DH group 15]"
699e324319bSjmc.It Li modp4096 Ta 4096 Ta "[DH group 16]"
700e324319bSjmc.It Li modp6144 Ta 6144 Ta "[DH group 17]"
701e324319bSjmc.It Li modp8192 Ta 8192 Ta "[DH group 18]"
70226c588ccSmpi.It Li ecp256 Ta 256 Ta "[DH group 19]"
70326c588ccSmpi.It Li ecp384 Ta 384 Ta "[DH group 20]"
70426c588ccSmpi.It Li ecp521 Ta 512 Ta "[DH group 21]"
70526c588ccSmpi.It Li ecp192 Ta 192 Ta "[DH group 25]"
70626c588ccSmpi.It Li ecp224 Ta 224 Ta "[DH group 26]"
70726c588ccSmpi.It Li bp224 Ta 224 Ta "[DH group 27]"
70826c588ccSmpi.It Li bp256 Ta 256 Ta "[DH group 28]"
70926c588ccSmpi.It Li bp384 Ta 384 Ta "[DH group 29]"
71026c588ccSmpi.It Li bp512 Ta 512 Ta "[DH group 30]"
711e324319bSjmc.It Li none Ta 0 Ta "[phase 2 only]"
7125cae4fc4Sjmc.El
7139f98aabfSjmc.Sh MANUAL FLOWS
7140d9e70aaSjmcIn this scenario,
7150d9e70aaSjmc.Nm
7160d9e70aaSjmcis used to set up flows manually.
7170d9e70aaSjmcIPsec uses flows
7189f98aabfSjmcto determine whether to apply security services to an IP packet or not.
71970d92abaSjmcSome examples of setting up flows:
7209f98aabfSjmc.Bd -literal -offset 3n
72170d92abaSjmc# Set up two flows:
72270d92abaSjmc# First between the machines 192.168.3.14 and 192.168.3.100
72370d92abaSjmc# Second between the networks 192.168.7.0/24 and 192.168.8.0/24
7249f98aabfSjmcflow esp from 192.168.3.14 to 192.168.3.100
7259f98aabfSjmcflow esp from 192.168.7.0/24 to 192.168.8.0/24 peer 192.168.3.12
7269f98aabfSjmc.Ed
7279f98aabfSjmc.Pp
7282aa0310cSjmcThe following types of flow are available:
729150a6f91Shshoexer.Bl -tag -width xxxx
7309f98aabfSjmc.It Ic flow esp
7319f98aabfSjmcESP can provide the following properties:
7329f98aabfSjmcauthentication, integrity, replay protection, and confidentiality of the data.
7332aa0310cSjmcIf no flow type is specified,
7342aa0310cSjmcthis is the default.
7359f98aabfSjmc.It Ic flow ah
7362aa0310cSjmcAH provides authentication, integrity, and replay protection, but not
7379f98aabfSjmcconfidentiality.
7389f98aabfSjmc.It Ic flow ipip
7392aa0310cSjmcIPIP does not provide authentication, integrity, replay protection, or
7409f98aabfSjmcconfidentiality.
7412aa0310cSjmcHowever, it does allow tunnelling of IP traffic over IP, without setting up
7429f98aabfSjmc.Xr gif 4
7439f98aabfSjmcinterfaces.
7449f98aabfSjmc.El
7459f98aabfSjmc.Pp
7463ec91679SjmcThe commands are as follows:
7479f98aabfSjmc.Bl -tag -width xxxx
7489f98aabfSjmc.It Ic in No or Ic out
7499f98aabfSjmcThis rule applies to incoming or outgoing packets.
7509f98aabfSjmcIf neither
7519f98aabfSjmc.Ic in
7529f98aabfSjmcnor
7539f98aabfSjmc.Ic out
7549f98aabfSjmcare specified,
7559f98aabfSjmc.Xr ipsecctl 8
7569f98aabfSjmcwill assume the direction
7579f98aabfSjmc.Ic out
7589f98aabfSjmcfor this rule and will construct a proper
7599f98aabfSjmc.Ic in
7609f98aabfSjmcrule.
7619f98aabfSjmcThus packets in both directions will be matched.
762c009571eSjmc.It Ic proto Ar protocol
7639f98aabfSjmcThe optional
7649f98aabfSjmc.Ic proto
7659f98aabfSjmcparameter restricts the flow to a specific IP protocol.
7669f98aabfSjmcCommon protocols are
7679f98aabfSjmc.Xr icmp 4 ,
7689f98aabfSjmc.Xr tcp 4 ,
7699f98aabfSjmcand
7709f98aabfSjmc.Xr udp 4 .
7719f98aabfSjmcFor a list of all the protocol name to number mappings used by
7729f98aabfSjmc.Xr ipsecctl 8 ,
7739f98aabfSjmcsee the file
7749f98aabfSjmc.Pa /etc/protocols .
7759f98aabfSjmc.It Xo
776c009571eSjmc.Ic from Ar src
777c009571eSjmc.Op Ic port Ar sport
778c009571eSjmc.Ic to Ar dst
779c009571eSjmc.Op Ic port Ar dport
7809f98aabfSjmc.Xc
7819f98aabfSjmcThis rule applies for packets with source address
782c009571eSjmc.Ar src
7839f98aabfSjmcand destination address
784c009571eSjmc.Ar dst .
7859f98aabfSjmcThe keyword
7869f98aabfSjmc.Ar any
7879f98aabfSjmcwill match any address (i.e. 0.0.0.0/0).
7889f98aabfSjmcThe optional
7899f98aabfSjmc.Ic port
7909f98aabfSjmcmodifiers restrict the flows to the specified ports.
7919f98aabfSjmcThey are only valid in conjunction with the
7929f98aabfSjmc.Xr tcp 4
7939f98aabfSjmcand
7949f98aabfSjmc.Xr udp 4
7959f98aabfSjmcprotocols.
7969f98aabfSjmcPorts can be specified by number or by name.
7979f98aabfSjmcFor a list of all port name to number mappings used by
7989f98aabfSjmc.Xr ipsecctl 8 ,
7999f98aabfSjmcsee the file
8009f98aabfSjmc.Pa /etc/services .
801c009571eSjmc.It Ic local Ar localip
8029f98aabfSjmcThe
8039f98aabfSjmc.Ic local
8049f98aabfSjmcparameter specifies the address or FQDN of the local endpoint of this
8059f98aabfSjmcflow and can be usually left out.
806c009571eSjmc.It Ic peer Ar remote
8079f98aabfSjmcThe
8089f98aabfSjmc.Ic peer
8099f98aabfSjmcparameter specifies the address or FQDN of the remote endpoint of this
8109f98aabfSjmcflow.
8119f98aabfSjmcFor host-to-host connections where
812c009571eSjmc.Ar dst
8139f98aabfSjmcis identical to
814c009571eSjmc.Ar remote ,
8159f98aabfSjmcthe
8169f98aabfSjmc.Ic peer
817cbdee783Sbluhmspecification can be left out as it will be set to
818cbdee783Sbluhm.Ar dst
819cbdee783Sbluhmautomatically.
820cbdee783SbluhmOnly if the keyword
821cbdee783Sbluhm.Ar any
8222bc9ad67Sjmcis given is a flow without peer created.
823c009571eSjmc.It Ic type Ar modifier
824fc06ef68SjmcThis optional parameter sets up special flows using modifiers.
8259f98aabfSjmcBy default,
8269f98aabfSjmc.Xr ipsecctl 8
8279f98aabfSjmcwill automatically set up normal flows with the corresponding type.
828fc06ef68Sjmc.Ar modifier
829fc06ef68Sjmcmay be one of the following:
830fc06ef68Sjmc.Pp
831fc06ef68Sjmc.Bl -tag -width "acquireXX" -offset indent -compact
832fc06ef68Sjmc.It acquire
833fc06ef68SjmcUse IPsec and establish SAs dynamically.
834fc06ef68SjmcUnencrypted traffic is permitted until it is protected by IPsec.
835fc06ef68Sjmc.It bypass
836fc06ef68SjmcMatching packets are not processed by IPsec.
837fc06ef68Sjmc.It deny
838fc06ef68SjmcMatching packets are dropped.
839fc06ef68Sjmc.It dontacq
840fc06ef68SjmcUse IPsec.
841fc06ef68SjmcIf no SAs are available,
842fc06ef68Sjmcdoes not trigger
843fc06ef68Sjmc.Xr isakmpd 8 .
844fc06ef68Sjmc.It require
845fc06ef68SjmcUse IPsec and establish SAs dynamically.
846fc06ef68SjmcUnencrypted traffic is not permitted until it is protected by IPsec.
847fc06ef68Sjmc.It use
848fc06ef68SjmcUse IPsec.
849fc06ef68SjmcUnencrypted traffic is permitted.
850fc06ef68SjmcDoes not trigger
851fc06ef68Sjmc.Xr isakmpd 8 .
852fc06ef68Sjmc.El
8539f98aabfSjmc.El
854aa6c965cSjmc.Sh MANUAL SECURITY ASSOCIATIONS (SAs)
8550d9e70aaSjmcIn this scenario,
8560d9e70aaSjmc.Nm
8570d9e70aaSjmcis used to set up SAs manually.
8580d9e70aaSjmcThe security parameters for a flow
85958c9dd7dSjmcare stored in the Security Association Database (SADB).
8600d9e70aaSjmcAn example of setting up an SA:
8619f98aabfSjmc.Bd -literal -offset 3n
8620d9e70aaSjmc# Set up an IPsec SA for flows between 192.168.3.14 and 192.168.3.12
8639f98aabfSjmcesp from 192.168.3.14 to 192.168.3.12 spi 0xdeadbeef:0xbeefdead \e
864afdc4689Shshoexer	authkey file "auth14:auth12" enckey file "enc14:enc12"
8659f98aabfSjmc.Ed
8669f98aabfSjmc.Pp
8672aa0310cSjmcParameters specify the peers, Security Parameter Index (SPI),
8682aa0310cSjmccryptographic transforms, and key material to be used.
8699f98aabfSjmcThe following rules enter SAs in the SADB:
8709f98aabfSjmc.Pp
8712aa0310cSjmc.Bl -tag -width "tcpmd5XX" -offset indent -compact
8729f98aabfSjmc.It Ic esp
8739f98aabfSjmcEnter an ESP SA.
8749f98aabfSjmc.It Ic ah
8759f98aabfSjmcEnter an AH SA.
87609be88eaSderaadt.It Ic ipcomp
87709be88eaSderaadtEnter an IPCOMP SA.
8789f98aabfSjmc.It Ic ipip
8799f98aabfSjmcEnter an IPIP pseudo SA.
880bb027f23Sjmc.It Ic tcpmd5
881bb027f23SjmcEnter a TCP MD5 SA.
8829f98aabfSjmc.El
8839f98aabfSjmc.Pp
8843ec91679SjmcThe commands are as follows:
8859f98aabfSjmc.Bl -tag -width xxxx
886c009571eSjmc.It Ar mode
8878814d473SjmcFor ESP and AH
88848767dafSjmc.\".Ic ipcomp
8898814d473Sjmcthe encapsulation mode can be specified.
8909f98aabfSjmcPossible modes are
8919f98aabfSjmc.Ar tunnel
8929f98aabfSjmcand
8939f98aabfSjmc.Ar transport .
8949f98aabfSjmcWhen left out,
8959f98aabfSjmc.Ar tunnel
8969f98aabfSjmcis chosen.
8979f98aabfSjmcFor details on modes see
8989f98aabfSjmc.Xr ipsec 4 .
899c009571eSjmc.It Ic from Ar src Ic to Ar dst
9009f98aabfSjmcThis SA is for a
9019f98aabfSjmc.Ar flow
9029f98aabfSjmcbetween the peers
903c009571eSjmc.Ar src
9049f98aabfSjmcand
905c009571eSjmc.Ar dst .
906c009571eSjmc.It Ic spi Ar number
9079f98aabfSjmcThe SPI identifies a specific SA.
9089f98aabfSjmc.Ar number
9099f98aabfSjmcis a 32-bit value and needs to be unique.
910a3b4c2abSbluhm.It Ic udpencap Op Ic port Ar dport
911a3b4c2abSbluhmFor NAT-Traversal encapsulate the IPsec traffic in UDP.
912a3b4c2abSbluhmThe port number of the peer can be set to
913a3b4c2abSbluhm.Ar dport .
914c009571eSjmc.It Ic auth Ar algorithm
9158814d473SjmcFor ESP and AH
9169f98aabfSjmcan authentication algorithm can be specified.
9178814d473SjmcPossible values
9185cae4fc4Sjmcare described above in
9198814d473Sjmc.Sx CRYPTO TRANSFORMS .
9209f98aabfSjmc.Pp
9219f98aabfSjmcIf no algorithm is specified,
9229f98aabfSjmc.Xr ipsecctl 8
9239f98aabfSjmcwill choose
9249f98aabfSjmc.Ar hmac-sha2-256
9259f98aabfSjmcby default.
926c009571eSjmc.It Ic enc Ar algorithm
9278814d473SjmcFor ESP
9288814d473Sjmcan encryption algorithm can be specified.
9298814d473SjmcPossible values
9305cae4fc4Sjmcare described above in
9318814d473Sjmc.Sx CRYPTO TRANSFORMS .
9329f98aabfSjmc.Pp
9339f98aabfSjmcIf no algorithm is specified,
9349f98aabfSjmc.Xr ipsecctl 8
9359f98aabfSjmcwill choose
9369f98aabfSjmc.Ar aes
9379f98aabfSjmcby default.
938c009571eSjmc.It Ic authkey Ar keyspec
9399f98aabfSjmc.Ar keyspec
9409f98aabfSjmcdefines the authentication key to be used.
9419f98aabfSjmcIt is either a hexadecimal string or a path to a file containing the key.
9429f98aabfSjmcThe filename may be given as either an absolute path to the file
9439f98aabfSjmcor a relative pathname,
9449f98aabfSjmcand is specified as follows:
9454614c0e8Sschwarze.Bd -literal -offset indent
9469f98aabfSjmcauthkey file "filename"
9479f98aabfSjmc.Ed
948c009571eSjmc.It Ic enckey Ar keyspec
949acd70746SjmcThe encryption key is defined similarly to
950acd70746Sjmc.Ic authkey .
95107f0d149Sbluhm.It Ic bundle Ar identifier
95207f0d149SbluhmSeveral SAs can be attached to a single flow.
95307f0d149SbluhmThe cryptographic transforms are applied in order.
95407f0d149SbluhmThe type of the first SA has to match the type of the flow.
95507f0d149SbluhmAll SAs with identical
95607f0d149Sbluhm.Ar src , dst ,
95707f0d149Sbluhmand
95807f0d149Sbluhm.Ar identifier
95907f0d149Sbluhmare grouped together.
960150a6f91Shshoexer.It Xo
96179c3e352Sjmc.Ic tcpmd5
962c009571eSjmc.Ic from Ar src
963c009571eSjmc.Ic to Ar dst
964c009571eSjmc.Ic spi Ar number
965c009571eSjmc.Ic authkey Ar keyspec
966150a6f91Shshoexer.Xc
967f1ac0521SjmcTCP MD5 signatures are generally used between BGP daemons, such as
968f1ac0521Sjmc.Xr bgpd 8 .
969f1ac0521SjmcSince
970f1ac0521Sjmc.Xr bgpd 8
971f1ac0521Sjmcitself already provides this functionality,
972f1ac0521Sjmcthis option is generally not needed.
973f1ac0521SjmcMore information on TCP MD5 signatures can be found in
974f1ac0521Sjmc.Xr tcp 4 ,
975f1ac0521Sjmc.Xr bgpd.conf 5 ,
976f1ac0521Sjmcand RFC 2385.
977f1ac0521Sjmc.Pp
978150a6f91ShshoexerThis rule applies for packets with source address
979c009571eSjmc.Ar src
980150a6f91Shshoexerand destination address
981c009571eSjmc.Ar dst .
982150a6f91ShshoexerThe parameter
98379c3e352Sjmc.Ic spi
984150a6f91Shshoexeris a 32-bit value defining the Security Parameter Index (SPI) for this SA.
985acd70746SjmcThe encryption key is defined similarly to
98679c3e352Sjmc.Ic authkey .
9879f98aabfSjmc.El
988aa03eebbSsthen.Pp
989aa03eebbSsthenSince an SA is directional, a second SA is normally configured in the
990aa03eebbSsthenreverse direction.
991aa03eebbSsthenThis is done by adding a second, colon-separated, value to
992aa03eebbSsthen.Ic spi ,
993aa03eebbSsthen.Ic authkey ,
994aa03eebbSsthenand
995aa03eebbSsthen.Ic enckey .
996c9d6433dSschwarze.Sh FILES
997c9d6433dSschwarze.Bl -tag -width /etc/examples/ipsec.conf -compact
998c9d6433dSschwarze.It Pa /etc/ipsec.conf
999c9d6433dSschwarze.It Pa /etc/examples/ipsec.conf
1000c9d6433dSschwarze.El
1001c573ac5dShshoexer.Sh SEE ALSO
1002709974ddSjmc.Xr openssl 1 ,
1003cb2c2d5aSjmc.Xr enc 4 ,
100409be88eaSderaadt.Xr ipcomp 4 ,
1005c573ac5dShshoexer.Xr ipsec 4 ,
100696e84c4fSjmc.Xr tcp 4 ,
100762ed4693Sjmc.Xr pf.conf 5 ,
1008c573ac5dShshoexer.Xr ipsecctl 8 ,
100910f11e23Sjmc.Xr isakmpd 8
1010f484f2cfShshoexer.Sh HISTORY
1011f484f2cfShshoexerThe
1012f484f2cfShshoexer.Nm
1013f484f2cfShshoexerfile format first appeared in
1014e067389aStom.Ox 3.8 .
1015