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