xref: /openbsd/sbin/iked/iked.conf.5 (revision 891d7ab6)
1.\" $OpenBSD: iked.conf.5,v 1.13 2011/01/21 12:34:11 jmc Exp $
2.\" $vantronix: iked.conf.5,v 1.10 2010/06/03 16:13:40 reyk Exp $
3.\"
4.\" Copyright (c) 2010 Reyk Floeter <reyk@vantronix.net>
5.\" Copyright (c) 2004 Mathieu Sauve-Frankel  All rights reserved.
6.\"
7.\" Permission to use, copy, modify, and distribute this software for any
8.\" purpose with or without fee is hereby granted, provided that the above
9.\" copyright notice and this permission notice appear in all copies.
10.\"
11.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18.\"
19.Dd $Mdocdate: January 21 2011 $
20.Dt IKED.CONF 5
21.Os
22.Sh NAME
23.Nm iked.conf
24.Nd IKEv2 configuration file
25.Sh DESCRIPTION
26.Nm
27is the configuration file for
28.Xr iked 8 ,
29the Internet Key Exchange version 2 (IKEv2) daemon for IPsec.
30IPsec itself is a pair of protocols:
31Encapsulating Security Payload (ESP),
32which provides integrity and confidentiality;
33and Authentication Header (AH),
34which provides integrity.
35The IPsec protocol itself is described in
36.Xr ipsec 4 .
37.Pp
38In its most basic form, a flow is established between hosts and/or
39networks, and then Security Associations (SA) are established,
40which detail how the desired protection will be achieved.
41IPsec uses flows to determine whether to apply security services to an
42IP packet or not.
43.Xr iked 8
44is used to set up flows and establish SAs automatically,
45by specifying
46.Sq ikev2
47policies in
48.Nm
49(see
50.Sx AUTOMATIC KEYING POLICIES ,
51below).
52.Pp
53Alternative methods of setting up flows and SAs are also possible
54using manual keying or automatic keying using the older ISAKMP/Oakley
55a.k.a. IKEv1 protocol.
56Manual keying is not recommended, but can be convenient for quick
57setups and testing.
58See
59.Xr ipsec.conf 5
60and
61.Xr isakmpd 8
62for more information about manual keying and ISAKMP support.
63.Sh IKED.CONF FILE FORMAT
64.Nm
65is divided into three main sections:
66.Bl -tag -width xxxx
67.It Sy Macros
68User-defined variables may be defined and used later, simplifying the
69configuration file.
70.It Sy Global Configuration
71Global settings for
72.Xr iked 8 .
73.It Sy Automatic Keying Policies
74Policies to set up IPsec flows and SAs automatically.
75.El
76.Pp
77Lines beginning with
78.Sq #
79and empty lines are regarded as comments,
80and ignored.
81Lines may be split using the
82.Sq \e
83character.
84.Pp
85Addresses can be specified in CIDR notation (matching netblocks),
86as symbolic host names, interface names, or interface group names.
87.Pp
88Additional configuration files can be included with the
89.Ic include
90keyword, for example:
91.Bd -literal -offset indent
92include "/etc/macros.conf"
93.Ed
94.Sh MACROS
95Macros can be defined that will later be expanded in context.
96Macro names must start with a letter, and may contain letters, digits
97and underscores.
98Macro names may not be reserved words (for example
99.Ic flow ,
100.Ic from ,
101.Ic esp ) .
102Macros are not expanded inside quotes.
103.Pp
104For example:
105.Bd -literal -offset indent
106remote_gw = "192.168.3.12"
107ikev2 esp from 192.168.7.0/24 to 192.168.8.0/24 peer $remote_gw
108.Ed
109.Sh GLOBAL CONFIGURATION
110Here are the settings that can be set globally:
111.Bl -tag -width xxxx
112.It Ic set active
113Set
114.Xr iked 8
115to active mode.
116This is the default.
117.It Ic set passive
118Set
119.Xr iked 8
120to passive mode.
121In passive mode no packets are sent to peers and no connections are
122initiated by
123.Xr iked 8 .
124This option is used for setups using
125.Xr sasyncd 8
126and
127.Xr carp 4
128to provide redundancy.
129iked will run in passive mode until sasyncd has determined that the host
130is the master and can switch to active mode.
131.It Ic set couple
132Load the negotiated security associations (SAs) and flows into the kernel.
133This is the default.
134.It Ic set decouple
135Don't load the negotiated SAs and flows from the kernel.
136This mode is only useful for testing and debugging.
137.It Ic user Ar name Ar password
138.Xr iked 8
139supports user-based authentication by tunneling the Extensible
140Authentication Protocol (EAP) over IKEv2.
141In its most basic form, the users will be authenticated against a
142local, integrated password database that is configured with the
143.Ic user
144lines in
145.Nm
146and the
147.Ar name
148and
149.Ar password
150arguments.
151Note that the password has to be specified in plain text which is
152required to support different challenge-based EAP methods like
153EAP-MD5 or EAP-MSCHAPv2.
154.El
155.Sh AUTOMATIC KEYING POLICIES
156This section is used to configure policies that will be used by
157.Xr iked 8
158to set up flows and SAs automatically.
159Some examples of setting up automatic keying:
160.Bd -literal -offset 3n
161# Set up a VPN:
162# First between the gateway machines 192.168.3.1 and 192.168.3.2
163# Second between the networks 10.1.1.0/24 and 10.1.2.0/24
164ikev2 esp from 192.168.3.1 to 192.168.3.2
165ikev2 esp from 10.1.1.0/24 to 10.1.2.0/24 peer 192.168.3.2
166.Ed
167.Pp
168For incoming connections from remote peers, the policies are evaluated
169in sequential order, from first to last.
170The last matching policy decides what action is taken; if no policy matches
171the connection, the default action is to ignore the connection attempt or
172to use the
173.Ar default
174policy, if set.
175Please also see the
176.Sx EXAMPLES
177section for a detailed example of the policy evaluation.
178.Pp
179The first time an IKEv2 connection matches a policy, an IKE SA is
180created; for subsequent packets the connection is identified by the
181IKEv2 parameters that are stored in the SA without evaluating any
182policies.
183After the connection is closed or times out, the IKE SA is
184automatically removed.
185.Pp
186The commands are as follows:
187.Bl -tag -width xxxx
188.It Xo
189.Ic ikev2
190.Op Ar name
191.Xc
192The mandatory
193.Ic ikev2
194keyword will identify an IKEv2 automatic keying policy.
195.Ar name
196is an optional arbitrary string identifying the policy.
197The name should only occur once in
198.Nm
199or any included files.
200If omitted,
201a name will be generated automatically for the policy.
202.It Op Ar eval
203The
204.Ar eval
205option modifies the policy evaluation for this policy.
206It can be one of
207.Ar quick ,
208.Ar skip
209or
210.Ar default .
211If a new incoming connection matches a policy with the
212.Ar quick
213option set, that policy is considered the last matching policy,
214and evaluation of subsequent policies is skipped.
215The
216.Ar skip
217option will disable evaluation of this policy for incoming connections.
218The
219.Ar default
220option sets the default policy and should only be specified once.
221.It Op Ar mode
222.Ar mode
223specifies the IKEv2 mode to use:
224one of
225.Ar passive
226or
227.Ar active .
228When
229.Ar passive
230is specified,
231.Xr iked 8
232will not immediately start negotiation of this tunnel, but wait for an incoming
233request from the remote peer.
234When
235.Ar active
236is specified, negotiation will be started at once.
237If omitted,
238.Ar passive
239mode will be used.
240.It Op Ar encap
241.Ar encap
242specifies the encapsulation protocol to be used.
243Possible protocols are
244.Ar esp
245and
246.Ar ah ;
247the default is
248.Ar esp .
249.\" .It Op Ar tmode
250.\" .Ar tmode
251.\" describes the encapsulation mode to be used.
252.\" Possible modes are
253.\" .Ar tunnel
254.\" and
255.\" .Ar transport ;
256.\" the default is
257.\" .Ar tunnel .
258.It Op Ar af
259This policy only applies to endpoints of the specified address family
260which can be either
261.Ar inet
262or
263.Ar inet6 .
264Note that this only matters for IKEv2 endpoints and does not
265restrict the traffic selectors to negotiate flows with different
266address families, e.g. IPv6 flows negotiated by IPv4 endpoints.
267.It Ic proto Ar protocol
268The optional
269.Ic proto
270parameter restricts the flow to a specific IP protocol.
271Common protocols are
272.Xr icmp 4 ,
273.Xr tcp 4 ,
274and
275.Xr udp 4 .
276For a list of all the protocol name to number mappings used by
277.Xr iked 8 ,
278see the file
279.Pa /etc/protocols .
280.It Xo
281.Ic from Ar src
282.Op Ic port Ar sport
283.Op Pq Ar srcnat
284.Ic to Ar dst
285.Op Ic port Ar dport
286.Xc
287Specify one or more traffic selectors for this policy which will be
288used to negotiate the IPsec flows between the IKEv2 peers.
289During the negotiation, the peers may decide to narrow a flow to a
290subset of the configured traffic selector networks to match the
291policies on each side.
292.Pp
293Each traffic selector will apply for packets with source address
294.Ar src
295and destination address
296.Ar dst .
297The keyword
298.Ar any
299will match any address (i.e. 0.0.0.0/0).
300If the
301.Ar src
302argument specifies a fictional source ID,
303the
304.Ar srcnat
305parameter can be used to specify the actual source address.
306This can be used in outgoing NAT/BINAT scenarios as described below.
307.Pp
308The optional
309.Ic port
310modifiers restrict the traffic selectors to the specified ports.
311They are only valid in conjunction with the
312.Xr tcp 4
313and
314.Xr udp 4
315protocols.
316Ports can be specified by number or by name.
317For a list of all port name to number mappings used by
318.Xr ipsecctl 8 ,
319see the file
320.Pa /etc/services .
321.It Ic local Ar localip Ic peer Ar remote
322The
323.Ic local
324parameter specifies the address or FQDN of the local endpoint.
325Unless the gateway is multi-homed or uses address aliases,
326this option is generally not needed.
327.Pp
328The
329.Ic peer
330parameter specifies the address or FQDN of the remote endpoint.
331For host-to-host connections where
332.Ar dst
333is identical to
334.Ar remote ,
335this option is generally not needed as it will be set to
336.Ar dst
337automatically.
338If it is not specified or if the keyword
339.Ar any
340is given, the default peer is used.
341.It Xo
342.Ic ikesa
343.Ic auth Ar algorithm
344.Ic enc Ar algorithm
345.Ic prf Ar algorithm
346.Ic group Ar group
347.Xc
348These parameters define the mode and cryptographic transforms to be
349used for the IKE SA negotiation, also known as phase 1.
350The IKE SA will be used to authenticate the machines and to set up an
351encrypted channel for the IKEv2 protocol.
352.Pp
353Possible values for
354.Ic auth ,
355.Ic enc ,
356.Ic prf ,
357.Ic group ,
358and the default proposals are described below in
359.Sx CRYPTO TRANSFORMS .
360If omitted,
361.Xr iked 8
362will use the default proposals for the IKEv2 protocol.
363.It Xo
364.Ic childsa
365.Ic auth Ar algorithm
366.Ic enc Ar algorithm
367.Ic group Ar group
368.Xc
369These parameters define the cryptographic transforms to be used for
370the Child SA negotiation, also known as phase 2.
371Each Child SA will be used to negotiate the actual IPsec SAs.
372The initial Child SA is always negotiated with the initial IKEv2 key
373exchange; additional Child SAs may be negotiated with additional
374Child SA key exchanges for an established IKE SA.
375.Pp
376Possible values for
377.Ic auth ,
378.Ic enc ,
379.Ic group ,
380and the default proposals are described below in
381.Sx CRYPTO TRANSFORMS .
382If omitted,
383.Xr iked 8
384will use the default proposals for the ESP or AH protocol.
385The
386.Ic group
387option will only be used to enable Perfect Forwarding Security (PFS)
388for additional Child SAs exchanges that are not part of the initial
389key exchange.
390.It Ic srcid Ar string Ic dstid Ar string
391.Ic srcid
392defines an ID of type
393.Dq FQDN ,
394.Dq ASN1_DN ,
395.Dq IPV4 ,
396.Dq IPV6 ,
397or
398.Dq UFQDN
399that will be used by
400.Xr iked 8
401as the identity of the local peer.
402If the argument is an email address (reyk@example.com),
403.Xr iked 8
404will use UFQDN as the ID type.
405The ASN1_DN type will be used if the string starts with a slash
406.Sq /
407(/C=DE/../CN=10.0.0.1/emailAddress=reyk@example.com).
408If the argument is an IPv4 address or a compressed IPv6 address,
409the ID types IPV4 or IPV6 will be used.
410Anything else is considered to be an FQDN.
411.Pp
412If
413.Ic srcid
414is omitted,
415the default is to use the hostname of the local machine,
416see
417.Xr hostname 1
418to set or print the hostname.
419.Pp
420.Ic dstid
421is similar to
422.Ic srcid ,
423but instead specifies the ID to be used
424by the remote peer.
425.It Ic lifetime Ar time Op Ic bytes Ar bytes
426The optional
427.Ic lifetime
428parameter defines the Child SA expiration timeout by the
429.Ar time
430SA was in use and by the number of
431.Ar bytes
432that were processed using the SA.
433Default values are 3 hours and 512 megabytes which means that SA will be
434rekeyed before reaching the time limit or 512 megabytes of data
435will pass through.
436Zero values disable rekeying.
437.Pp
438Several unit specifiers are recognized (ignoring case):
439.Ql m
440and
441.Ql h
442for minutes and hours, and
443.Ql K ,
444.Ql M
445and
446.Ql G
447for kilo-, mega- and gigabytes accordingly.
448.Pp
449Please note that rekeying must happen at least several times a day as
450IPsec security heavily depends on the frequent key renewals.
451.It Op Ar ikeauth
452Specify the mode to mutually authenticate the peers.
453Non-psk modes will require to set up certificates and RSA public keys;
454see
455.Xr iked 8
456for more information.
457.Pp
458.Bl -tag -width $domain -compact -offset indent
459.It Ic eap Ar type
460Use EAP to authenticate the initiator.
461The only supported EAP
462.Ar type
463is currently
464.Ar MSCHAP-V2 .
465The responder will use RSA public key authentication.
466.It Ic psk Ar string
467Use a pre-shared key
468.Ar string
469or hex value (starting with 0x) for authentication.
470.It Ic rsa
471Use RSA public key authentication.
472This is the default mode if no option is specified.
473.El
474.It Ic tag Ar string
475Add a
476.Xr pf 4
477tag to all packets of IPsec SAs created for this connection.
478This will allow matching packets for this connection by defining
479rules in
480.Xr pf.conf 5
481using the
482.Cm tagged
483keyword.
484.Pp
485The following variables can be used in tags to include information
486from the remote peer on runtime:
487.Pp
488.Bl -tag -width $domain -compact -offset indent
489.It Ar $id
490The
491.Ic dstid
492that was proposed by the remote peer to identify itself.
493It will be expanded to
494.Ar id-value ,
495e.g.\&
496.Ar FQDN/foo.example.com .
497To limit the size of the derived tag,
498.Xr iked 8
499will extract the common name
500.Sq CN=
501from ASN1_DN IDs, for example
502.Ar ASN1_ID//C=DE/../CN=10.1.1.1/..
503will be expanded to
504.Ar 10.1.1.1 .
505.It Ar $domain
506Extract the domain from IDs of type FQDN, UFQDN or ASN1_DN.
507.It Ar $name
508The name of the IKEv2 policy that was configured in
509.Nm
510or automatically generated by
511.Xr iked 8 .
512.El
513.Pp
514For example, if the ID is
515.Ar FQDN/foo.example.com
516or
517.Ar UFQDN/user@example.com ,
518.Dq ipsec-$domain
519expands to
520.Dq ipsec-example.com .
521The variable expansion for the
522.Ar tag
523directive occurs only at runtime, not during configuration file parse time.
524.It Ic tap Ar interface
525Send the decapsulated IPsec traffic to the specified
526.Xr enc 4
527.Ar interface
528instead of
529.Ar enc0
530for filtering and monitoring.
531The traffic will be blocked if the specified
532.Ar interface
533does not exist.
534.El
535.Sh PACKET FILTERING
536IPsec traffic appears unencrypted on the
537.Xr enc 4
538interface
539and can be filtered accordingly using the
540.Ox
541packet filter,
542.Xr pf 4 .
543The grammar for the packet filter is described in
544.Xr pf.conf 5 .
545.Pp
546The following components are relevant to filtering IPsec traffic:
547.Bl -ohang -offset indent
548.It external interface
549Interface for IKE traffic and encapsulated IPsec traffic.
550.It proto udp port 500
551IKE traffic on the external interface.
552.It proto udp port 4500
553IKE NAT-Traversal traffic on the external interface.
554.It proto ah \*(Ba esp
555Encapsulated IPsec traffic
556on the external interface.
557.It enc0
558Default interface for outgoing traffic before it's been encapsulated,
559and incoming traffic after it's been decapsulated.
560State on this interface should be interface bound;
561see
562.Xr enc 4
563for further information.
564.It proto ipencap
565[tunnel mode only]
566IP-in-IP traffic flowing between gateways
567on the enc0 interface.
568.It tagged ipsec-example.org
569Match traffic of IPsec SAs using the
570.Ic tag
571keyword.
572.El
573.Pp
574If the filtering rules specify to block everything by default,
575the following rule
576would ensure that IPsec traffic never hits the packet filtering engine,
577and is therefore passed:
578.Bd -literal -offset indent
579set skip on enc0
580.Ed
581.Pp
582In the following example, all traffic is blocked by default.
583IPsec-related traffic from gateways {192.168.3.1, 192.168.3.2} and
584networks {10.0.1.0/24, 10.0.2.0/24} is permitted.
585.Bd -literal -offset indent
586block on ix0
587block on enc0
588
589pass  in on ix0 proto udp from 192.168.3.2 to 192.168.3.1 \e
590	port {500, 4500}
591pass out on ix0 proto udp from 192.168.3.1 to 192.168.3.2 \e
592	port {500, 4500}
593
594pass  in on ix0 proto esp from 192.168.3.2 to 192.168.3.1
595pass out on ix0 proto esp from 192.168.3.1 to 192.168.3.2
596
597pass  in on enc0 proto ipencap from 192.168.3.2 to 192.168.3.1 \e
598	keep state (if-bound)
599pass out on enc0 proto ipencap from 192.168.3.1 to 192.168.3.2 \e
600	keep state (if-bound)
601pass  in on enc0 from 10.0.2.0/24 to 10.0.1.0/24 \e
602	keep state (if-bound)
603pass out on enc0 from 10.0.1.0/24 to 10.0.2.0/24 \e
604	keep state (if-bound)
605.Ed
606.Pp
607.Xr pf 4
608has the ability to filter IPsec-related packets
609based on an arbitrary
610.Em tag
611specified within a ruleset.
612The tag is used as an internal marker
613which can be used to identify the packets later on.
614This could be helpful,
615for example,
616in scenarios where users are connecting in from differing IP addresses,
617or to support queue-based bandwidth control,
618since the enc0 interface does not support it.
619.Pp
620The following
621.Xr pf.conf 5
622fragment uses queues for all IPsec traffic with special
623handling for developers and employees:
624.Bd -literal -offset indent
625altq on ix0 cbq bandwidth 1000Mb \e
626	queue { deflt, developers, employees, ipsec }
627    queue deflt bandwidth 10% priority 0 cbq(default ecn)
628    queue developers bandwidth 75% priority 7 cbq(borrow red)
629    queue employees bandwidth 5% cbq(red)
630    queue ipsec bandwidth 10% cbq(red)
631
632pass out on ix0 proto esp queue ipsec
633
634pass out on ix0 tagged ipsec-developers.example.com queue developers
635pass out on ix0 tagged ipsec-employees.example.com queue employees
636.Ed
637.Pp
638The following example assigns the tags in the
639.Nm
640configuration and also sets an alternative
641.Xr enc 4
642device:
643.Bd -literal -offset indent
644ikev2 esp from 10.1.1.0/24 to 10.1.2.0/24 peer 192.168.3.2 \e
645	tag ipsec-$domain tap "enc1"
646.Ed
647.Sh OUTGOING NETWORK ADDRESS TRANSLATION
648In some network topologies it is desirable to perform NAT on traffic leaving
649through the VPN tunnel.
650In order to achieve that,
651the
652.Ar src
653argument is used to negotiate the desired network ID with the peer
654and the
655.Ar srcnat
656parameter defines the true local subnet,
657so that a correct SA can be installed on the local side.
658.Pp
659For example,
660if the local subnet is 192.168.1.0/24 and all the traffic
661for a specific VPN peer should appear as coming from 10.10.10.1,
662the following configuration is used:
663.Bd -literal -offset indent
664ikev2 esp from 10.10.10.1 (192.168.1.0/24) to 192.168.2.0/24 \e
665	peer 10.10.20.1
666.Ed
667.Pp
668Naturally,
669a relevant NAT rule is required in
670.Xr pf.conf 5 .
671For the example above,
672this would be:
673.Bd -literal -offset indent
674match on enc0 from 192.168.1.0/24 to 192.168.2.0/24 nat-to 10.10.10.1
675.Ed
676.Pp
677From the peer's point of view,
678the local end of the VPN tunnel is declared to be 10.10.10.1
679and all the traffic arrives with that source address.
680.Sh CRYPTO TRANSFORMS
681The following authentication types are permitted with the
682.Ic auth
683keyword:
684.Pp
685.Bl -column "authenticationXX" "Key Length" -offset indent -compact
686.It Em Authentication	Key Length	Truncated Length
687.It Li hmac-md5 Ta "128 bits" Ta "96 bits"
688.It Li hmac-sha1 Ta "160 bits" Ta "96 bits"
689.It Li hmac-sha2-256 Ta "256 bits" Ta "128 bits"
690.It Li hmac-sha2-384 Ta "384 bits" Ta "192 bits"
691.It Li hmac-sha2-512 Ta "512 bits" Ta "256 bits"
692.El
693.Pp
694The following pseudo-random function types are permitted with the
695.Ic prf
696keyword:
697.Pp
698.Bl -column "authenticationXX" "Key Length" -offset indent -compact
699.It Em Authentication	Key Length
700.It Li hmac-md5 Ta "128 bits" Ta "[IKE only]"
701.It Li hmac-sha1 Ta "160 bits" Ta "[IKE only]"
702.It Li hmac-sha2-256 Ta "256 bits" Ta "[IKE only]"
703.It Li hmac-sha2-384 Ta "384 bits" Ta "[IKE only]"
704.It Li hmac-sha2-512 Ta "512 bits" Ta "[IKE only]"
705.El
706.Pp
707The following cipher types are permitted with the
708.Ic enc
709keyword:
710.Pp
711.Bl -column "authenticationXX" "Key Length" -offset indent -compact
712.It Em Cipher	Key Length
713.It Li des Ta "56 bits" Ta "[ESP only]"
714.It Li 3des Ta "168 bits"
715.It Li aes-128 Ta "128 bits"
716.It Li aes-192 Ta "192 bits"
717.It Li aes-256 Ta "256 bits"
718.It Li aes-ctr Ta "160 bits" Ta "[ESP only]"
719.It Li aes-128-gcm Ta "160 bits" Ta "[ESP only]"
720.It Li aes-192-gcm Ta "224 bits" Ta "[ESP only]"
721.It Li aes-256-gcm Ta "288 bits" Ta "[ESP only]"
722.It Li aes-128-gmac Ta "160 bits" Ta "[ESP only]"
723.It Li aes-192-gmac Ta "224 bits" Ta "[ESP only]"
724.It Li aes-256-gmac Ta "288 bits" Ta "[ESP only]"
725.It Li blowfish Ta "160 bits" Ta "[ESP only]"
726.It Li cast Ta "128 bits" Ta "[ESP only]"
727.It Li null Ta "" Ta "[ESP only]"
728.El
729.Pp
730Use of DES as an encryption algorithm is not recommended (except for
731backwards compatibility) due to the short key length.
732.Pp
733DES requires 8 bytes to form a 56-bit key and 3DES requires 24 bytes
734to form its 168-bit key.
735This is because the most significant bit of each byte is used for parity.
736.Pp
737The keysize of AES-CTR is actually 128-bit.
738However as well as the key, a 32-bit nonce has to be supplied.
739Thus 160 bits of key material have to be supplied.
740The same applies to AES-GCM and AES-GMAC.
741.Pp
742Using AES-GMAC or NULL with ESP will only provide authentication.
743This is useful in setups where AH can not be used, e.g. when NAT is involved.
744.Pp
745The following group types are permitted with the
746.Ic group
747keyword:
748.Pp
749.Bl -column "modpXXXX-XXX" "grpXX" "XXXX" "Alias" -offset indent -compact
750.It Em Name	Group	Size	Type
751.It Li modp768 Ta grp1 Ta 768 Ta "MODP"
752.It Li modp1024 Ta grp2 Ta 1024 Ta "MODP"
753.It Li ec2n155 Ta grp3 Ta 155 Ta "EC2N [insecure]"
754.It Li ec2n185 Ta grp4 Ta 185 Ta "EC2N [insecure]"
755.It Li modp1536 Ta grp5 Ta 1536 Ta "MODP"
756.It Li modp2048 Ta grp14 Ta 2048 Ta "MODP"
757.It Li modp3072 Ta grp15 Ta 3072 Ta "MODP"
758.It Li modp4096 Ta grp16 Ta 4096 Ta "MODP"
759.It Li modp6144 Ta grp17 Ta 6144 Ta "MODP"
760.It Li modp8192 Ta grp18 Ta 8192 Ta "MODP"
761.It Li ecp256 Ta grp19 Ta 256 Ta "ECP"
762.It Li ecp384 Ta grp20 Ta 384 Ta "ECP"
763.It Li ecp521 Ta grp21 Ta 521 Ta "ECP"
764.It Li modp1024-160 Ta grp22 Ta 2048 Ta "MODP, 160 bit Prime Order Subgroup"
765.It Li modp2048-224 Ta grp23 Ta 2048 Ta "MODP, 224 bit Prime Order Subgroup"
766.It Li modp2048-256 Ta grp24 Ta 2048 Ta "MODP, 256 bit Prime Order Subgroup"
767.It Li ecp192 Ta grp25 Ta 192 Ta "ECP"
768.It Li ecp224 Ta grp26 Ta 224 Ta "ECP"
769.El
770.Pp
771The currently supported group types are either
772MODP (exponentiation groups modulo a prime),
773EC2N (elliptic curve groups over GF[2^N]),
774or
775ECP (elliptic curve groups modulo a prime).
776Please note that the EC2N groups are considered as insecure and only
777provided for backwards compatibility.
778.Sh EXAMPLES
779The first example is intended for clients connecting to
780.Xr iked 8
781as an IPsec gateway, or IKEv2 responder, using mutual public key
782authentication and additional challenge-based EAP-MSCHAPv2 password
783authentication:
784.Bd -literal -offset indent
785user "test" "password123"
786
787ikev2 "win7" esp \e
788	from 172.16.2.0/24 to 0.0.0.0/0 \e
789	peer 10.0.0.0/8 local 192.168.56.0/24 \e
790	eap "mschap-v2" \e
791	config address 172.16.2.1 \e
792	tag "$name-$id"
793.Ed
794.Pp
795The next example allows peers to authenticate using a pre-shared key
796.Sq foobar :
797.Bd -literal -offset indent
798ikev2 "big test" \e
799	esp proto tcp \e
800	from 10.0.0.0/8 port 23 to 20.0.0.0/8 port 40 \e
801	from 192.168.1.1 to 192.168.2.2 \e
802	peer any local any \e
803	ikesa enc 3des auth hmac-sha1 group modp1024 \e
804	childsa enc aes-128 auth hmac-sha1 \e
805	srcid host.example.com \e
806	dstid 192.168.0.254 \e
807	psk "foobar"
808.Ed
809.Pp
810The following example illustrates the last matching policy
811evaluation for incoming connections on an IKEv2 gateway.
812The peer 192.168.1.34 will always match the first policy because of the
813.Ar quick
814keyword;
815connections from the peers 192.168.1.3 and 192.168.1.2 will be matched
816by one of the last two policies;
817any other connections from 192.168.1.0/24 will be matched by the
818.Sq subnet
819policy;
820and any other connection will be matched by the
821.Sq catch all
822policy.
823.Bd -literal -offset indent
824ikev2 quick esp from 10.10.10.0/24 to 10.20.20.0/24 \e
825	peer 192.168.1.34
826ikev2 "catch all" esp from 10.0.1.0/24 to 10.0.2.0/24 \e
827	peer any
828ikev2 "subnet" esp from 10.0.3.0/24 to 10.0.4.0/24 \e
829	peer 192.168.1.0/24
830ikev2 esp from 10.0.5.0/30 to 10.0.5.4/30 peer 192.168.1.2
831ikev2 esp from 10.0.5.8/30 to 10.0.5.12/30 peer 192.168.1.3
832.Ed
833.Sh SEE ALSO
834.Xr enc 4 ,
835.Xr ipsec 4 ,
836.Xr ipsec.conf 5 ,
837.Xr pf.conf 5 ,
838.Xr ikectl 8 ,
839.Xr iked 8
840.Sh HISTORY
841The
842.Nm
843file format first appeared in
844.Ox 4.8 .
845.Sh AUTHORS
846The
847.Nm
848program was written by
849.An Reyk Floeter Aq reyk@vantronix.net .
850