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
|
.\" $OpenBSD: isakmpd.8,v 1.81 2005/06/04 17:22:42 hshoexer Exp $
.\" $EOM: isakmpd.8,v 1.23 2000/05/02 00:30:23 niklas Exp $
.\"
.\" Copyright (c) 1998, 1999, 2000, 2001 Niklas Hallqvist.
.\" All rights reserved.
.\" Copyright (c) 1999 Angelos D. Keromytis. All rights reserved.
.\" Copyright (c) 2001, 2002 Håkan Olsson. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" This code was written under funding by Ericsson Radio Systems.
.\"
.\" Manual page, using -mandoc macros
.\"
.Dd August 07, 2002
.Dt ISAKMPD 8
.Os
.Sh NAME
.Nm isakmpd
.Nd ISAKMP/Oakley a.k.a. IKE key management daemon
.Sh SYNOPSIS
.Nm isakmpd
.Bk -words
.Op Fl 46adKLnTv
.Op Fl c Ar config-file
.Xo
.Oo Fl D
.Ar class Ns = Ns Ar level Oc
.Xc
.Op Fl f Ar fifo
.Op Fl i Ar pid-file
.Op Fl l Ar packetlog-file
.Op Fl N Ar udpencap-port
.Op Fl p Ar listen-port
.Op Fl R Ar report-file
.Ek
.Sh DESCRIPTION
The
.Nm
daemon establishes security associations for encrypted
and/or authenticated network traffic.
At this moment, and probably forever, this means
.Xr ipsec 4
traffic.
.Pp
The way
.Nm
goes about its work is by maintaining an internal configuration
as well as a policy database which describes what kinds of SAs to negotiate,
and by listening for different events that trigger these negotiations.
The events that control
.Nm
consist of negotiation initiations from a remote party, user input via
a FIFO or by signals, upcalls from the kernel via a
.Dv PF_KEY
socket, and lastly by scheduled events triggered by timers running out.
.Pp
Most uses of
.Nm
will be to implement so called "virtual private networks" (VPNs).
The
.Xr vpn 8
manual page describes how to set up
.Nm
for a simple VPN.
For other uses, some more knowledge of IKE as a protocol is required.
One source of information are the RFCs mentioned below.
.Pp
On startup
.Nm
forks into two processes for privilege separation.
The unprivileged child jails itself with
.Xr chroot 8
to
.Pa /var/empty .
The privileged process communicates with the child, reads configuration files
and PKI information, and binds to privileged ports on its behalf.
See the
.Sx CAVEATS
section below.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl 4 | 6
These options control what address family
.Pf ( Dv AF_INET
and/or
.Dv AF_INET6 )
.Nm
will use.
The default is to use both IPv4 and IPv6.
.It Fl a
If given,
.Nm
does not set up flows automatically.
This is useful when flows are configured with
.Xr ipsecadm 8
or by other programs like
.Xr bgpd 8 .
Thus
.Nm
only takes care of the SA establishment.
.It Fl c Ar config-file
If given, the
.Fl c
option specifies an alternate configuration file instead of
.Pa /etc/isakmpd/isakmpd.conf .
As this file may contain sensitive information, it must be readable
only by the user running the daemon.
.Nm
will reread the configuration file when sent a
.Dv SIGHUP
signal.
.It Fl D Ar class Ns = Ns Ar level
Debugging class.
It's possible to specify this argument many times.
It takes a parameter of the form
.Ar class Ns = Ns Ar level ,
where both
.Ar class
and
.Ar level
are numbers.
.Ar class
denotes a debugging class, and
.Ar level
the level you want that debugging class to
limit debug printouts at (i.e. all debug printouts above the level specified
will not output anything).
If
.Ar class
is set to
.Sq A ,
then all debugging classes are set to the specified level.
.Pp
Valid values for
.Ar class
are as follows:
.Pp
.Bl -tag -width 2n -offset indent -compact
.It 0
Misc
.It 1
Transport
.It 2
Message
.It 3
Crypto
.It 4
Timer
.It 5
Sysdep
.It 6
SA
.It 7
Exchange
.It 8
Negotiation
.It 9
Policy
.It 10
FIFO user interface
.It A
All
.El
.Pp
Currently used values for
.Ar level
are 0 to 99.
.It Fl d
The
.Fl d
option is used to make the daemon run in the foreground, logging to stderr.
.It Fl f Ar fifo
The
.Fl f
option specifies the
.Tn FIFO
(a.k.a. named pipe) where the daemon listens for
user requests.
If the path given is a dash
.Pq Sq \&- ,
.Nm
will listen to stdin instead.
.It Fl i Ar pid-file
By default the PID of the daemon process will be written to
.Pa /var/run/isakmpd.pid .
This path can be overridden by specifying another one as the argument to the
.Fl i
option.
Note that only paths beginning with
.Pa /var/run
are allowed.
.It Fl K
When this option is given,
.Nm
does not read the policy configuration file and no
.Xr keynote 4
policy check is accomplished.
This option can be used when policies for flows and SA establishment are
arranged by other programs like
.Xr ipsecadm 8
or
.Xr bgpd 8 .
.It Fl L
Enable IKE packet capture.
When this option is given,
.Nm
will capture to file an unencrypted copy of the negotiation packets it
is sending and receiving.
This file can later be read by
.Xr tcpdump 8
and other utilities using
.Xr pcap 3 .
.It Fl l Ar packetlog-file
As option
.Fl L
above, but capture to a specified file.
.It Fl N Ar udpencap-port
The
.Fl N
option specifies the listen port for encapsulated UDP
that the daemon will bind to.
.It Fl n
When the
.Fl n
option is given, the kernel will not take part in the negotiations.
This is a non-destructive mode, so to speak, in that it won't alter any
SAs in the IPsec stack.
.It Fl p Ar listen-port
The
.Fl p
option specifies the listen port the daemon will bind to.
.It Fl R Ar report-file
When you signal
.Nm
a
.Dv SIGUSR1 ,
it will report its internal state to a report file, normally
.Pa /var/run/isakmpd.report ,
but this can be changed by feeding
the file name as an argument to the
.Fl R
flag.
Note that only paths beginning with
.Pa /var/run
are allowed.
.It Fl T
When this option is given, NAT-Traversal will be disabled and
.Nm
will not advertise support for NAT-Traversal to its peers.
.It Fl v
Enables verbose logging.
Normally,
.Nm
is silent and outputs only messages when a warning or an error occurs.
With verbose logging
.Nm
reports successful completion of phase 1 (Main and Aggressive) and phase 2
(Quick) exchanges (Information and Transaction exchanges do not generate any
additional status information).
.El
.Sh THE FIFO USER INTERFACE
When
.Nm
starts, it creates a FIFO (named pipe) where it listens for user
requests.
All commands start with a single letter, followed by command-specific options.
Available commands are:
.Bl -tag -width Ds -compact
.Pp
.It Xo
.Ic C add
.Sm off
.Op Ic section
.No :
.Ic tag No = Ic value
.Sm on
.Xc
.It Xo
.Ic C rm
.Sm off
.Op Ic section
.No :
.Ic tag
.Sm on
.Xc
.It Xo
.Ic C rms
.Op Ic section
.Xc
.It Xo
.Ic C set
.Sm off
.Op Ic section
.No :
.Ic tag No = Ic value
.Sm on
.Xc
.It Xo
.Ic C set
.Sm off
.Op Ic section
.No :
.Ic tag No = Ic value\ \&force
.Sm on
.Xc
Update the running
.Nm
configuration atomically.
.Sq set
sets a configuration value consisting of a section, tag, and value triplet.
.Sq set
will fail if the configuration already contains a section with the named tag;
use the
.Sq force
option to change this behaviour.
.Sq add
appends a configuration value to the named configuration list tag.
.Sq rm
removes a tag in a section.
.Sq rms
removes an entire section.
.Pp
NOTE: Sending
.Nm
a
.Dv SIGHUP
or an "R" through the FIFO will void any updates done to the configuration.
.Pp
.It Xo
.Ic C get
.Sm off
.Op Ic section
.No :
.Ic tag
.Sm on
.Xc
Get the configuration value of the specified section and tag.
The result is stored in
.Pa /var/run/isakmpd.result .
.Pp
.It Ic c Aq Ic name
Start the named connection, if stopped or inactive.
.Pp
.It Xo
.Ic D
.Aq Ic class
.Aq Ic level
.Xc
.It Xo
.Ic D A
.Aq Ic level
.Xc
.It Ic D T
Set debug class
.Aq Ic class
to level
.Aq Ic level .
If
.Aq Ic class
is specified as
.Sq A ,
the level applies to all debug classes.
.Ic D T
toggles all debug classes to level zero.
Another
.Ic D T
command will toggle them back to the earlier levels.
.Pp
.It Xo
.Ic d
.Aq Ic cookies
.Aq Ic msgid
.Xc
Delete the specified SA from the system.
Specify
.Aq Ic msgid
as
.Sq -
to match a Phase 1 SA.
.Pp
.It Xo
.Ic p
.Sm off
.Ic on
.Op No = Aq Ic path
.Sm on
.Xc
.It Ic p off
Enable or disable cleartext IKE packet capture.
When enabling, optionally specify which file
.Nm
should capture the packets to.
.Pp
.It Ic Q
Cleanly shutdown the daemon, as when sent a
.Dv SIGTERM
signal.
.Pp
.It Ic R
Reinitialize
.Nm isakmpd ,
as when sent a
.Dv SIGHUP
signal.
.Pp
.It Ic r
Report
.Nm
internal state to a file.
See the
.Fl R
option.
Same as when sent a
.Dv SIGUSR1
signal.
.Pp
.It Ic S
Report information on all known SAs to the
.Pa /var/run/isakmpd.result
file.
.Pp
.It Ic T
Tear down all active connections.
.Pp
.It Ic t Aq Ic name
Tear down the named connection, if active.
.El
.Sh SETTING UP AN IKE PUBLIC KEY INFRASTRUCTURE (PKI)
In order to use public key based authentication, there has to be an
infrastructure managing the key signing.
Either there is an already existing PKI
.Nm
should take part in, or there will be a need to set one up.
The procedures for using a pre-existing PKI varies depending on the
actual Certificate Authority (CA) used, and is therefore not covered here,
other than mentioning that
.Xr openssl 1
needs to be used to create a Certificate Signing Request (CSR) that the
CA understands.
.Pp
A number of methods exist to allow authentication:
.Bl -ohang -offset indent
.It Passphrase:
This method does not use keys at all, but relies on a shared passphrase.
See
.Xr vpn 8
for an example implementation.
.It Host Keys:
Public keys are used to authenticate.
See
.Sx PUBLIC KEY AUTHENTICATION
below.
.It X509 Certificates:
X509 Certificates are used to authenticate.
See
.Sx X509 AUTHENTICATION
below.
.It Keynote Certificates:
Keynote Certificates are used to authenticate.
See
.Sx KEYNOTE AUTHENTICATION
below.
.El
.Sh PUBLIC KEY AUTHENTICATION
It is possible to store trusted public keys to make them directly
usable by
.Nm ,
bypassing the need to use certificates.
The keys should be saved in PEM format (see
.Xr openssl 1 )
and named and stored after this easy formula:
.Pp
.Bl -tag -width "for_ufqdn_identitiesXX" -offset 3n -compact
.It For IPv4 identities:
/etc/isakmpd/pubkeys/ipv4/A.B.C.D
.It For IPv6 identities:
/etc/isakmpd/pubkeys/ipv6/abcd:abcd::ab:bc
.It For FQDN identities:
/etc/isakmpd/pubkeys/fqdn/foo.bar.org
.It For UFQDN identities:
/etc/isakmpd/pubkeys/ufqdn/user@foo.bar.org
.El
.Pp
By default, the system startup script
.Xr rc 8
generates a key-pair when starting, if one does not already exist.
The private and public keys are named
.Pa local.key
and
.Pa local.pub ,
respectively.
Depending on the
.Dv ID-type
field of
.Xr isakmpd.conf 5 ,
keys may be named after their IPv4 address (IPV4_ADDR or IPV4_ADDR_SUBNET),
IPv6 address (IPV6_ADDR or IPV6_ADDR_SUBNET),
fully qualified domain name (FDQN),
user fully qualified domain name (USER_FQDN),
or key ID (KEY_ID).
.Pp
For example,
.Nm
can authenticate using the pre-generated keys if the local public key
is copied to the remote gateway as
.Pa /etc/isakmpd/pubkeys/ipv4/local.gateway.ip.address
and the remote gateway's public key
is copied to the local gateway as
.Pa /etc/isakmpd/pubkeys/ipv4/remote.gateway.ip.address .
Of course, new keys may also be generated
(the user is not required to use the pre-generated keys).
In this example,
.Dv ID-type
would also have to be set to IPV4_ADDR or IPV4_ADDR_SUBNET
in
.Xr isakmpd.conf 5 .
.Sh X509 AUTHENTICATION
X509 is a framework for public key certificates.
Certificates can be generated using
.Xr openssl 1
and provide a means for PKI authentication.
In the following example, a CA is created along with host certificates
to be signed by the CA.
.Bl -enum
.It
Create your own Certificate Authority (CA).
.Pp
Create a self-signed root certificate.
The CA certificate is named
.Pa ca.crt ,
and its private key
.Pa ca.key :
.Bd -literal -offset indent
# openssl req -x509 -days 365 -newkey rsa:1024 \e
-keyout /etc/ssl/private/ca.key \e
-out /etc/ssl/ca.crt
.Ed
.Pp
.Ic openssl req
will prompt for information that will be incorporated
into the certificate request.
The information entered comprises a Distinguished Name (DN).
There are quite a few fields, but some can be left blank.
For some fields there will be a default value; if
.Sq \&.
is entered, the field will be left blank.
.It
Create Certificate Signing Requests (CSRs) for IKE peers.
The CSRs are signed with a pre-generated private key.
By default, the system startup script
.Xr rc 8
generates a key-pair when starting, if one does not already exist.
The private and public keys are named
.Pa local.key
and
.Pa local.pub ,
respectively.
.Pp
This step, as well as the next one, needs to be done for every peer.
Furthermore the last step will need to be done once for each ID you
want the peer to have.
The 10.0.0.1 below symbolizes that ID, in this case an IPv4 ID,
and should be changed for each invocation.
You will be asked for a DN for each run.
Encoding the ID in the common name is recommended, as it should be unique.
.Bd -literal -offset indent
# openssl req -new -key /etc/isakmpd/private/local.key \e
-out /etc/isakmpd/private/10.0.0.1.csr
.Ed
.Pp
Now take these certificate signing requests to your CA and process
them as below.
A
.Em subjectAltName
extension field should be added to the certificate.
This field is not mandatory, but is highly recommended since it allows
.Nm
to avoid
.Dq man in the middle
attacks.
Replace 10.0.0.1 with the IP address which
.Nm
will use as the certificate identity.
.Bd -literal -offset indent
# setenv CERTIP 10.0.0.1
# openssl x509 -req -days 365 -in 10.0.0.1.csr \e
-CA /etc/ssl/ca.crt -CAkey /etc/ssl/private/ca.key \e
-CAcreateserial -extfile /etc/ssl/x509v3.cnf \e
-extensions x509v3_IPAddr -out 10.0.0.1.crt
.Ed
.Pp
For a FQDN certificate, do:
.Bd -literal -offset indent
# setenv CERTFQDN somehost.somedomain
# openssl x509 -req -days 365 -in somehost.somedomain.csr \e
-CA /etc/ssl/ca.crt -CAkey /etc/ssl/private/ca.key \e
-CAcreateserial -extfile /etc/ssl/x509v3.cnf \e
-extensions x509v3_FQDN -out somehost.somedomain.crt
.Ed
.Pp
Put the certificate (the file ending in .crt) in
.Pa /etc/isakmpd/certs/
on your local system.
Also carry over the CA cert
.Pa /etc/ssl/ca.crt
and put it in
.Pa /etc/isakmpd/ca/ .
.El
.Pp
To revoke certificates, create a Certificate Revocation List (CRL) file
and install it in the
.Pa /etc/isakmpd/crls/
directory.
See
.Xr openssl 1
and the
.Sq crl
subcommand for more info.
.Sh KEYNOTE AUTHENTICATION
Keynote is a trust-management framework.
Keys can be generated using
.Xr keynote 1
and provide an alternative means for
.Nm
to authenticate.
See
.Xr keynote 4
for further information.
.Sh FILES
.Bl -tag -width Ds
.It /etc/isakmpd/ca/
The directory where CA certificates are kept.
.It /etc/isakmpd/certs/
The directory where IKE certificates are kept, both the local
certificate(s) and those of the peers, if a choice to have them kept
permanently has been made.
.It /etc/isakmpd/crls/
The directory where CRLs are kept.
.It /etc/isakmpd/isakmpd.conf
The configuration file.
As this file can contain sensitive information
it must not be readable by anyone but the user running
.Nm .
.It /etc/isakmpd/isakmpd.policy
The keynote policy configuration file.
The same mode requirements as
.Pa isakmpd.conf .
.It /etc/isakmpd/keynote/
The directory where KeyNote credentials are kept.
.It /etc/isakmpd/private/
The directory where local private keys for certificate-based authentication,
and their public key counterparts, are kept.
By default, the system startup script
.Xr rc 8
generates a key-pair when starting, if one does not already exist.
The private and public keys are named
.Pa local.key
and
.Pa local.pub ,
respectively.
There has to be a certificate for
.Pa local.key
in the certificate directory,
.Pa /etc/isakmpd/certs/ .
.Pa local.key
has the same mode requirements as
.Pa isakmpd.conf .
.It /etc/isakmpd/pubkeys/
The directory in which trusted public keys are kept.
The keys must be named in the fashion described above.
.It /usr/share/ipsec/isakmpd/
A directory containing some sample
.Nm
and keynote policy configuration files.
.It /var/run/isakmpd.fifo
The FIFO used to manually control
.Nm isakmpd .
.It /var/run/isakmpd.pcap
The default IKE packet capture file.
.It /var/run/isakmpd.pid
The PID of the current daemon.
.It /var/run/isakmpd.report
The report file written when
.Dv SIGUSR1
is received.
.It /var/run/isakmpd.result
The report file written when the
.Sq S
or
.Sq "C get"
command is issued in the command FIFO.
.El
.Sh SEE ALSO
.Xr openssl 1 ,
.Xr getnameinfo 3 ,
.Xr pcap 3 ,
.Xr ipsec 4 ,
.Xr isakmpd.conf 5 ,
.Xr isakmpd.policy 5 ,
.Xr ssl 8 ,
.Xr tcpdump 8 ,
.Xr vpn 8
.Sh HISTORY
The ISAKMP/Oakley key management protocol is described in
RFC 2407, RFC 2408, and RFC 2409.
NAT-Traversal is described in RFC 3947.
This implementation was done 1998 by Niklas Hallqvist and Niels Provos,
sponsored by Ericsson Radio Systems.
.Sh CAVEATS
When storing a trusted public key for an IPv6 identity, the
.Em most efficient
form of address representation, i.e. "::" instead of ":0:0:0:",
must be used or the matching will fail.
.Nm
uses the output from
.Xr getnameinfo 3
for the address-to-name translation.
The privileged process only allows binding to the default port 500 or
unprivileged ports (>1024).
It is not possible to change the interfaces
.Nm
listens on without a restart.
|