xref: /freebsd/sbin/setkey/setkey.8 (revision 00a4311adc197c3518f5d60c69e00c4e80d065fd)
1cf43a054SHajimu UMEMOTO.\"	$KAME: setkey.8,v 1.89 2003/09/07 22:17:41 itojun Exp $
23c62e87aSJun-ichiro itojun Hagino.\"
39a4365d0SYoshinobu Inoue.\" Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
49a4365d0SYoshinobu Inoue.\" All rights reserved.
59a4365d0SYoshinobu Inoue.\"
69a4365d0SYoshinobu Inoue.\" Redistribution and use in source and binary forms, with or without
79a4365d0SYoshinobu Inoue.\" modification, are permitted provided that the following conditions
89a4365d0SYoshinobu Inoue.\" are met:
99a4365d0SYoshinobu Inoue.\" 1. Redistributions of source code must retain the above copyright
109a4365d0SYoshinobu Inoue.\"    notice, this list of conditions and the following disclaimer.
119a4365d0SYoshinobu Inoue.\" 2. Redistributions in binary form must reproduce the above copyright
129a4365d0SYoshinobu Inoue.\"    notice, this list of conditions and the following disclaimer in the
139a4365d0SYoshinobu Inoue.\"    documentation and/or other materials provided with the distribution.
149a4365d0SYoshinobu Inoue.\" 3. Neither the name of the project nor the names of its contributors
159a4365d0SYoshinobu Inoue.\"    may be used to endorse or promote products derived from this software
169a4365d0SYoshinobu Inoue.\"    without specific prior written permission.
179a4365d0SYoshinobu Inoue.\"
189a4365d0SYoshinobu Inoue.\" THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
199a4365d0SYoshinobu Inoue.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
209a4365d0SYoshinobu Inoue.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
219a4365d0SYoshinobu Inoue.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
229a4365d0SYoshinobu Inoue.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
239a4365d0SYoshinobu Inoue.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
249a4365d0SYoshinobu Inoue.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
259a4365d0SYoshinobu Inoue.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
269a4365d0SYoshinobu Inoue.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
279a4365d0SYoshinobu Inoue.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
289a4365d0SYoshinobu Inoue.\" SUCH DAMAGE.
299a4365d0SYoshinobu Inoue.\"
306b806d21SRuslan Ermilov.\" $FreeBSD$
316b806d21SRuslan Ermilov.\"
32*00a4311aSJohn Baldwin.Dd June 4, 2020
339a4365d0SYoshinobu Inoue.Dt SETKEY 8
3433841545SHajimu UMEMOTO.Os
353c62e87aSJun-ichiro itojun Hagino.\"
369a4365d0SYoshinobu Inoue.Sh NAME
379a4365d0SYoshinobu Inoue.Nm setkey
386992e2a5SRuslan Ermilov.Nd "manually manipulate the IPsec SA/SP database"
393c62e87aSJun-ichiro itojun Hagino.\"
409a4365d0SYoshinobu Inoue.Sh SYNOPSIS
41e97407b4SRuslan Ermilov.Nm
42cf43a054SHajimu UMEMOTO.Op Fl v
439a4365d0SYoshinobu Inoue.Fl c
44e97407b4SRuslan Ermilov.Nm
45cf43a054SHajimu UMEMOTO.Op Fl v
469a4365d0SYoshinobu Inoue.Fl f Ar filename
47e97407b4SRuslan Ermilov.Nm
4822986c67SAndrey V. Elsukov.Op Fl Pgltv
499a4365d0SYoshinobu Inoue.Fl D
50e97407b4SRuslan Ermilov.Nm
51cf43a054SHajimu UMEMOTO.Op Fl Pv
529a4365d0SYoshinobu Inoue.Fl F
53e97407b4SRuslan Ermilov.Nm
549a4365d0SYoshinobu Inoue.Op Fl h
559a4365d0SYoshinobu Inoue.Fl x
569a4365d0SYoshinobu Inoue.\"
579a4365d0SYoshinobu Inoue.Sh DESCRIPTION
58490d5836SPhilippe CharnierThe
599a4365d0SYoshinobu Inoue.Nm
606992e2a5SRuslan Ermilovutility adds, updates, dumps, or flushes
613c62e87aSJun-ichiro itojun HaginoSecurity Association Database (SAD) entries
623c62e87aSJun-ichiro itojun Haginoas well as Security Policy Database (SPD) entries in the kernel.
639a4365d0SYoshinobu Inoue.Pp
64490d5836SPhilippe CharnierThe
659a4365d0SYoshinobu Inoue.Nm
666992e2a5SRuslan Ermilovutility takes a series of operations from the standard input
676992e2a5SRuslan Ermilov(if invoked with
686992e2a5SRuslan Ermilov.Fl c )
693c62e87aSJun-ichiro itojun Haginoor the file named
709a4365d0SYoshinobu Inoue.Ar filename
716992e2a5SRuslan Ermilov(if invoked with
726992e2a5SRuslan Ermilov.Fl f Ar filename ) .
736992e2a5SRuslan Ermilov.Bl -tag -width indent
749a4365d0SYoshinobu Inoue.It Fl D
759a4365d0SYoshinobu InoueDump the SAD entries.
769a4365d0SYoshinobu InoueIf with
779a4365d0SYoshinobu Inoue.Fl P ,
789a4365d0SYoshinobu Inouethe SPD entries are dumped.
799a4365d0SYoshinobu Inoue.It Fl F
803c62e87aSJun-ichiro itojun HaginoFlush the SAD entries.
819a4365d0SYoshinobu InoueIf with
829a4365d0SYoshinobu Inoue.Fl P ,
833c62e87aSJun-ichiro itojun Haginothe SPD entries are flushed.
8422986c67SAndrey V. Elsukov.It Fl g
8522986c67SAndrey V. ElsukovOnly SPD entries with global scope are dumped with
8622986c67SAndrey V. Elsukov.Fl D
8722986c67SAndrey V. Elsukovand
8822986c67SAndrey V. Elsukov.Fl P
8922986c67SAndrey V. Elsukovflags.
9022986c67SAndrey V. Elsukov.It Fl t
9122986c67SAndrey V. ElsukovOnly SPD entries with ifnet scope are dumped with
9222986c67SAndrey V. Elsukov.Fl D
9322986c67SAndrey V. Elsukovand
9422986c67SAndrey V. Elsukov.Fl P
9522986c67SAndrey V. Elsukovflags.
9622986c67SAndrey V. ElsukovSuch SPD entries are linked to the corresponding
9722986c67SAndrey V. Elsukov.Xr if_ipsec 4
9822986c67SAndrey V. Elsukovvirtual tunneling interface.
999a4365d0SYoshinobu Inoue.It Fl h
1009a4365d0SYoshinobu InoueAdd hexadecimal dump on
1019a4365d0SYoshinobu Inoue.Fl x
102f2e366a1SSheldon Hearnmode.
1039a4365d0SYoshinobu Inoue.It Fl l
1049a4365d0SYoshinobu InoueLoop forever with short output on
1059a4365d0SYoshinobu Inoue.Fl D .
1069a4365d0SYoshinobu Inoue.It Fl v
1079a4365d0SYoshinobu InoueBe verbose.
10833841545SHajimu UMEMOTOThe program will dump messages exchanged on
1099a4365d0SYoshinobu Inoue.Dv PF_KEY
11033841545SHajimu UMEMOTOsocket, including messages sent from other processes to the kernel.
111cf43a054SHajimu UMEMOTO.It Fl x
112cf43a054SHajimu UMEMOTOLoop forever and dump all the messages transmitted to
113cf43a054SHajimu UMEMOTO.Dv PF_KEY
114cf43a054SHajimu UMEMOTOsocket.
115cf43a054SHajimu UMEMOTO.Fl xx
1167cb0189dSEitan Adlermakes each timestamp unformatted.
1179a4365d0SYoshinobu Inoue.El
118cf43a054SHajimu UMEMOTO.Ss Configuration syntax
119cf43a054SHajimu UMEMOTOWith
120cf43a054SHajimu UMEMOTO.Fl c
121cf43a054SHajimu UMEMOTOor
122cf43a054SHajimu UMEMOTO.Fl f
123cf43a054SHajimu UMEMOTOon the command line,
124cf43a054SHajimu UMEMOTO.Nm
125cf43a054SHajimu UMEMOTOaccepts the following configuration syntax.
1266992e2a5SRuslan ErmilovLines starting with hash signs
1276992e2a5SRuslan Ermilov.Pq Ql #
1286992e2a5SRuslan Ermilovare treated as comment lines.
1296992e2a5SRuslan Ermilov.Bl -tag -width indent
1309a4365d0SYoshinobu Inoue.It Xo
1319a4365d0SYoshinobu Inoue.Li add
132cf43a054SHajimu UMEMOTO.Op Fl 46n
1339a4365d0SYoshinobu Inoue.Ar src Ar dst Ar protocol Ar spi
1349a4365d0SYoshinobu Inoue.Op Ar extensions
1359a4365d0SYoshinobu Inoue.Ar algorithm ...
13635471bf8SJoel Dahl.Li \&;
1379a4365d0SYoshinobu Inoue.Xc
1383c62e87aSJun-ichiro itojun HaginoAdd an SAD entry.
139cf43a054SHajimu UMEMOTO.Li add
140cf43a054SHajimu UMEMOTOcan fail with multiple reasons,
141cf43a054SHajimu UMEMOTOincluding when the key length does not match the specified algorithm.
1429a4365d0SYoshinobu Inoue.\"
1439a4365d0SYoshinobu Inoue.It Xo
1449a4365d0SYoshinobu Inoue.Li get
145cf43a054SHajimu UMEMOTO.Op Fl 46n
1469a4365d0SYoshinobu Inoue.Ar src Ar dst Ar protocol Ar spi
14735471bf8SJoel Dahl.Li \&;
1489a4365d0SYoshinobu Inoue.Xc
1493c62e87aSJun-ichiro itojun HaginoShow an SAD entry.
1509a4365d0SYoshinobu Inoue.\"
1519a4365d0SYoshinobu Inoue.It Xo
1529a4365d0SYoshinobu Inoue.Li delete
153cf43a054SHajimu UMEMOTO.Op Fl 46n
1549a4365d0SYoshinobu Inoue.Ar src Ar dst Ar protocol Ar spi
15535471bf8SJoel Dahl.Li \&;
1569a4365d0SYoshinobu Inoue.Xc
1573c62e87aSJun-ichiro itojun HaginoRemove an SAD entry.
1589a4365d0SYoshinobu Inoue.\"
1599a4365d0SYoshinobu Inoue.It Xo
16033841545SHajimu UMEMOTO.Li deleteall
161cf43a054SHajimu UMEMOTO.Op Fl 46n
16233841545SHajimu UMEMOTO.Ar src Ar dst Ar protocol
16335471bf8SJoel Dahl.Li \&;
16433841545SHajimu UMEMOTO.Xc
16533841545SHajimu UMEMOTORemove all SAD entries that match the specification.
16633841545SHajimu UMEMOTO.\"
16733841545SHajimu UMEMOTO.It Xo
1689a4365d0SYoshinobu Inoue.Li flush
1699a4365d0SYoshinobu Inoue.Op Ar protocol
17035471bf8SJoel Dahl.Li \&;
1719a4365d0SYoshinobu Inoue.Xc
1723c62e87aSJun-ichiro itojun HaginoClear all SAD entries matched by the options.
173cf43a054SHajimu UMEMOTO.Fl F
174cf43a054SHajimu UMEMOTOon the command line achieves the same functionality.
1759a4365d0SYoshinobu Inoue.\"
1769a4365d0SYoshinobu Inoue.It Xo
1779a4365d0SYoshinobu Inoue.Li dump
1789a4365d0SYoshinobu Inoue.Op Ar protocol
17935471bf8SJoel Dahl.Li \&;
1809a4365d0SYoshinobu Inoue.Xc
1813c62e87aSJun-ichiro itojun HaginoDumps all SAD entries matched by the options.
182cf43a054SHajimu UMEMOTO.Fl D
183cf43a054SHajimu UMEMOTOon the command line achieves the same functionality.
1849a4365d0SYoshinobu Inoue.\"
1859a4365d0SYoshinobu Inoue.It Xo
1869a4365d0SYoshinobu Inoue.Li spdadd
187cf43a054SHajimu UMEMOTO.Op Fl 46n
1889a4365d0SYoshinobu Inoue.Ar src_range Ar dst_range Ar upperspec Ar policy
18935471bf8SJoel Dahl.Li \&;
1909a4365d0SYoshinobu Inoue.Xc
1913c62e87aSJun-ichiro itojun HaginoAdd an SPD entry.
1929a4365d0SYoshinobu Inoue.\"
1939a4365d0SYoshinobu Inoue.It Xo
1949a4365d0SYoshinobu Inoue.Li spddelete
195cf43a054SHajimu UMEMOTO.Op Fl 46n
1963c62e87aSJun-ichiro itojun Hagino.Ar src_range Ar dst_range Ar upperspec Fl P Ar direction
19735471bf8SJoel Dahl.Li \&;
1989a4365d0SYoshinobu Inoue.Xc
1993c62e87aSJun-ichiro itojun HaginoDelete an SPD entry.
2009a4365d0SYoshinobu Inoue.\"
2019a4365d0SYoshinobu Inoue.It Xo
2029a4365d0SYoshinobu Inoue.Li spdflush
20335471bf8SJoel Dahl.Li \&;
2049a4365d0SYoshinobu Inoue.Xc
2059a4365d0SYoshinobu InoueClear all SPD entries.
206cf43a054SHajimu UMEMOTO.Fl FP
207cf43a054SHajimu UMEMOTOon the command line achieves the same functionality.
2089a4365d0SYoshinobu Inoue.\"
2099a4365d0SYoshinobu Inoue.It Xo
2109a4365d0SYoshinobu Inoue.Li spddump
21135471bf8SJoel Dahl.Li \&;
2129a4365d0SYoshinobu Inoue.Xc
21317deb182SYoshinobu InoueDumps all SPD entries.
214cf43a054SHajimu UMEMOTO.Fl DP
215cf43a054SHajimu UMEMOTOon the command line achieves the same functionality.
2169a4365d0SYoshinobu Inoue.El
2179a4365d0SYoshinobu Inoue.\"
2189a4365d0SYoshinobu Inoue.Pp
2199a4365d0SYoshinobu InoueMeta-arguments are as follows:
220059b1593SBen Smithurst.Pp
2216992e2a5SRuslan Ermilov.Bl -tag -compact -width indent
2229a4365d0SYoshinobu Inoue.It Ar src
2239a4365d0SYoshinobu Inoue.It Ar dst
2249a4365d0SYoshinobu InoueSource/destination of the secure communication is specified as
2259a4365d0SYoshinobu InoueIPv4/v6 address.
2266992e2a5SRuslan ErmilovThe
2279a4365d0SYoshinobu Inoue.Nm
2286992e2a5SRuslan Ermilovutility
229cf43a054SHajimu UMEMOTOcan resolve a FQDN into numeric addresses.
230cf43a054SHajimu UMEMOTOIf the FQDN resolves into multiple addresses,
231cf43a054SHajimu UMEMOTO.Nm
232cf43a054SHajimu UMEMOTOwill install multiple SAD/SPD entries into the kernel
233cf43a054SHajimu UMEMOTOby trying all possible combinations.
234cf43a054SHajimu UMEMOTO.Fl 4 ,
235cf43a054SHajimu UMEMOTO.Fl 6
2369a4365d0SYoshinobu Inoueand
237cf43a054SHajimu UMEMOTO.Fl n
238cf43a054SHajimu UMEMOTOrestricts the address resolution of FQDN in certain ways.
239cf43a054SHajimu UMEMOTO.Fl 4
240cf43a054SHajimu UMEMOTOand
241cf43a054SHajimu UMEMOTO.Fl 6
242cf43a054SHajimu UMEMOTOrestrict results into IPv4/v6 addresses only, respectively.
243cf43a054SHajimu UMEMOTO.Fl n
244cf43a054SHajimu UMEMOTOavoids FQDN resolution and requires addresses to be numeric addresses.
2459a4365d0SYoshinobu Inoue.\"
2469a4365d0SYoshinobu Inoue.Pp
2479a4365d0SYoshinobu Inoue.It Ar protocol
2489a4365d0SYoshinobu Inoue.Ar protocol
2499a4365d0SYoshinobu Inoueis one of following:
2509a4365d0SYoshinobu Inoue.Bl -tag -width Fl -compact
2519a4365d0SYoshinobu Inoue.It Li esp
252cf43a054SHajimu UMEMOTOESP based on rfc2406
2539a4365d0SYoshinobu Inoue.It Li esp-old
2549a4365d0SYoshinobu InoueESP based on rfc1827
2559a4365d0SYoshinobu Inoue.It Li ah
2569a4365d0SYoshinobu InoueAH based on rfc2402
2579a4365d0SYoshinobu Inoue.It Li ah-old
2589a4365d0SYoshinobu InoueAH based on rfc1826
2599a4365d0SYoshinobu Inoue.It Li ipcomp
260cf43a054SHajimu UMEMOTOIPComp
2611922fd12SBruce M Simpson.It Li tcp
2621922fd12SBruce M SimpsonTCP-MD5 based on rfc2385
2639a4365d0SYoshinobu Inoue.El
2649a4365d0SYoshinobu Inoue.\"
2659a4365d0SYoshinobu Inoue.Pp
2669a4365d0SYoshinobu Inoue.It Ar spi
267cf43a054SHajimu UMEMOTOSecurity Parameter Index
2686992e2a5SRuslan Ermilov(SPI)
269cf43a054SHajimu UMEMOTOfor the SAD and the SPD.
270cf43a054SHajimu UMEMOTO.Ar spi
271cf43a054SHajimu UMEMOTOmust be a decimal number, or a hexadecimal number with
2726992e2a5SRuslan Ermilov.Ql 0x
273cf43a054SHajimu UMEMOTOprefix.
274cf43a054SHajimu UMEMOTOSPI values between 0 and 255 are reserved for future use by IANA
275cf43a054SHajimu UMEMOTOand they cannot be used.
2769a4365d0SYoshinobu Inoue.\"
2779a4365d0SYoshinobu Inoue.Pp
2789a4365d0SYoshinobu Inoue.It Ar extensions
279cf43a054SHajimu UMEMOTOtake some of the following:
2809a4365d0SYoshinobu Inoue.Bl -tag -width Fl -compact
2813c62e87aSJun-ichiro itojun Hagino.\"
2829a4365d0SYoshinobu Inoue.It Fl m Ar mode
2833c62e87aSJun-ichiro itojun HaginoSpecify a security protocol mode for use.
2849a4365d0SYoshinobu Inoue.Ar mode
2859a4365d0SYoshinobu Inoueis one of following:
2869a4365d0SYoshinobu Inoue.Li transport , tunnel
2879a4365d0SYoshinobu Inoueor
2889a4365d0SYoshinobu Inoue.Li any .
2893c62e87aSJun-ichiro itojun HaginoThe default value is
2903c62e87aSJun-ichiro itojun Hagino.Li any .
2913c62e87aSJun-ichiro itojun Hagino.\"
2929a4365d0SYoshinobu Inoue.It Fl r Ar size
29323852d5cSBenedict ReuschlingSpecify the bitmap size in octets of the anti-replay window.
2949a4365d0SYoshinobu Inoue.Ar size
29523852d5cSBenedict Reuschlingis a 32-bit unsigned integer, and its value is one eighth of the
29623852d5cSBenedict Reuschlinganti-replay window size in packets.
29733841545SHajimu UMEMOTOIf
2989a4365d0SYoshinobu Inoue.Ar size
29923852d5cSBenedict Reuschlingis zero or not specified, an anti-replay check does not take place.
3003c62e87aSJun-ichiro itojun Hagino.\"
3013c62e87aSJun-ichiro itojun Hagino.It Fl u Ar id
30233841545SHajimu UMEMOTOSpecify the identifier of the policy entry in SPD.
30333841545SHajimu UMEMOTOSee
30433841545SHajimu UMEMOTO.Ar policy .
3053c62e87aSJun-ichiro itojun Hagino.\"
3069a4365d0SYoshinobu Inoue.It Fl f Ar pad_option
30733841545SHajimu UMEMOTOdefines the content of the ESP padding.
3089a4365d0SYoshinobu Inoue.Ar pad_option
3099a4365d0SYoshinobu Inoueis one of following:
31033841545SHajimu UMEMOTO.Bl -tag -width random-pad -compact
31133841545SHajimu UMEMOTO.It Li zero-pad
31233841545SHajimu UMEMOTOAll of the padding are zero.
31333841545SHajimu UMEMOTO.It Li random-pad
31433841545SHajimu UMEMOTOA series of randomized values are set.
31533841545SHajimu UMEMOTO.It Li seq-pad
31633841545SHajimu UMEMOTOA series of sequential increasing numbers started from 1 are set.
31733841545SHajimu UMEMOTO.El
3183c62e87aSJun-ichiro itojun Hagino.\"
3193c62e87aSJun-ichiro itojun Hagino.It Fl f Li nocyclic-seq
3206992e2a5SRuslan ErmilovDo not allow cyclic sequence number.
3213c62e87aSJun-ichiro itojun Hagino.\"
3229a4365d0SYoshinobu Inoue.It Fl lh Ar time
3239a4365d0SYoshinobu Inoue.It Fl ls Ar time
32433841545SHajimu UMEMOTOSpecify hard/soft life time duration of the SA.
3259a4365d0SYoshinobu Inoue.El
3269a4365d0SYoshinobu Inoue.\"
3279a4365d0SYoshinobu Inoue.Pp
3289a4365d0SYoshinobu Inoue.It Ar algorithm
3299a4365d0SYoshinobu Inoue.Bl -tag -width Fl -compact
3309a4365d0SYoshinobu Inoue.It Fl E Ar ealgo Ar key
331cf43a054SHajimu UMEMOTOSpecify an encryption algorithm
332cf43a054SHajimu UMEMOTO.Ar ealgo
333cf43a054SHajimu UMEMOTOfor ESP.
334cf43a054SHajimu UMEMOTO.It Xo
335cf43a054SHajimu UMEMOTO.Fl E Ar ealgo Ar key
336cf43a054SHajimu UMEMOTO.Fl A Ar aalgo Ar key
337cf43a054SHajimu UMEMOTO.Xc
338cf43a054SHajimu UMEMOTOSpecify a encryption algorithm
339cf43a054SHajimu UMEMOTO.Ar ealgo ,
340cf43a054SHajimu UMEMOTOas well as a payload authentication algorithm
341cf43a054SHajimu UMEMOTO.Ar aalgo ,
342cf43a054SHajimu UMEMOTOfor ESP.
343ec2f949eSTim Vanderhoek.It Fl A Ar aalgo Ar key
344cf43a054SHajimu UMEMOTOSpecify an authentication algorithm for AH.
3459a4365d0SYoshinobu Inoue.It Fl C Ar calgo Op Fl R
346cf43a054SHajimu UMEMOTOSpecify a compression algorithm for IPComp.
3479a4365d0SYoshinobu InoueIf
3489a4365d0SYoshinobu Inoue.Fl R
349fb170c44SGeorge V. Neville-Neilis specified, the
3509a4365d0SYoshinobu Inoue.Ar spi
351cf43a054SHajimu UMEMOTOfield value will be used as the IPComp CPI
3526992e2a5SRuslan Ermilov(compression parameter index)
353cf43a054SHajimu UMEMOTOon wire as is.
3549a4365d0SYoshinobu InoueIf
3559a4365d0SYoshinobu Inoue.Fl R
356cf43a054SHajimu UMEMOTOis not specified,
357cf43a054SHajimu UMEMOTOthe kernel will use well-known CPI on wire, and
3589a4365d0SYoshinobu Inoue.Ar spi
359cf43a054SHajimu UMEMOTOfield will be used only as an index for kernel internal usage.
3609a4365d0SYoshinobu Inoue.El
3619a4365d0SYoshinobu Inoue.Pp
3629a4365d0SYoshinobu Inoue.Ar key
363cf43a054SHajimu UMEMOTOmust be double-quoted character string, or a series of hexadecimal digits
364cf43a054SHajimu UMEMOTOpreceded by
3656992e2a5SRuslan Ermilov.Ql 0x .
3669a4365d0SYoshinobu Inoue.Pp
3679a4365d0SYoshinobu InouePossible values for
3689a4365d0SYoshinobu Inoue.Ar ealgo ,
3699a4365d0SYoshinobu Inoue.Ar aalgo
3709a4365d0SYoshinobu Inoueand
3719a4365d0SYoshinobu Inoue.Ar calgo
3729a4365d0SYoshinobu Inoueare specified in separate section.
3739a4365d0SYoshinobu Inoue.\"
374059b1593SBen Smithurst.Pp
3759a4365d0SYoshinobu Inoue.It Ar src_range
3769a4365d0SYoshinobu Inoue.It Ar dst_range
3773c62e87aSJun-ichiro itojun HaginoThese are selections of the secure communication specified as
3789a4365d0SYoshinobu InoueIPv4/v6 address or IPv4/v6 address range, and it may accompany
3799a4365d0SYoshinobu InoueTCP/UDP port specification.
3809a4365d0SYoshinobu InoueThis takes the following form:
38162890a39SRuslan Ermilov.Bd -unfilled
3829a4365d0SYoshinobu Inoue.Ar address
3839a4365d0SYoshinobu Inoue.Ar address/prefixlen
3849a4365d0SYoshinobu Inoue.Ar address[port]
3859a4365d0SYoshinobu Inoue.Ar address/prefixlen[port]
3869a4365d0SYoshinobu Inoue.Ed
3879a4365d0SYoshinobu Inoue.Pp
3889a4365d0SYoshinobu Inoue.Ar prefixlen
3899a4365d0SYoshinobu Inoueand
3909a4365d0SYoshinobu Inoue.Ar port
391fb170c44SGeorge V. Neville-Neilmust be a decimal number.
392fb170c44SGeorge V. Neville-NeilThe square brackets around
3939a4365d0SYoshinobu Inoue.Ar port
394fb170c44SGeorge V. Neville-Neilare necessary and are not manpage metacharacters.
395cf43a054SHajimu UMEMOTOFor FQDN resolution, the rules applicable to
3969a4365d0SYoshinobu Inoue.Ar src
3979a4365d0SYoshinobu Inoueand
398cf43a054SHajimu UMEMOTO.Ar dst
399cf43a054SHajimu UMEMOTOapply here as well.
4009a4365d0SYoshinobu Inoue.\"
401059b1593SBen Smithurst.Pp
4029a4365d0SYoshinobu Inoue.It Ar upperspec
403fb170c44SGeorge V. Neville-NeilThe upper layer protocol to be used.
404fb170c44SGeorge V. Neville-NeilYou can use one of the words in
40533841545SHajimu UMEMOTO.Pa /etc/protocols
40633841545SHajimu UMEMOTOas
407fb170c44SGeorge V. Neville-Neil.Ar upperspec ,
408fb170c44SGeorge V. Neville-Neilas well as
409f1b1c5daSBrian Somers.Li icmp6 ,
410f1b1c5daSBrian Somers.Li ip4 ,
411fb170c44SGeorge V. Neville-Neilor
412fb170c44SGeorge V. Neville-Neil.Li any .
4138266d476SRuslan ErmilovThe word
4148266d476SRuslan Ermilov.Li any
4159a4365d0SYoshinobu Inouestands for
4169a4365d0SYoshinobu Inoue.Dq any protocol .
417fb170c44SGeorge V. Neville-NeilThe protocol number may also be used to specify the
418fb170c44SGeorge V. Neville-Neil.Ar upperspec .
419fb170c44SGeorge V. Neville-NeilA type and code related to ICMPv6 may also be specified as an
420fb170c44SGeorge V. Neville-Neil.Ar upperspec .
421fb170c44SGeorge V. Neville-NeilThe type is specified first, followed by a comma and then the relevant
422fb170c44SGeorge V. Neville-Neilcode.
423fb170c44SGeorge V. Neville-NeilThe specification must be placed after
424cf43a054SHajimu UMEMOTO.Li icmp6 .
425fb170c44SGeorge V. Neville-NeilThe kernel considers a zero to be a wildcard but
426fb170c44SGeorge V. Neville-Neilcannot distinguish between a wildcard and an ICMPv6
427fb170c44SGeorge V. Neville-Neiltype which is zero.
428fb170c44SGeorge V. Neville-NeilThe following example shows a policy where IPSec is not required for
429fb170c44SGeorge V. Neville-Neilinbound Neighbor Solicitations:
4306992e2a5SRuslan Ermilov.Pp
4316992e2a5SRuslan Ermilov.Dl "spdadd ::/0 ::/0 icmp6 135,0 -P in none;"
4329a4365d0SYoshinobu Inoue.Pp
4339a4365d0SYoshinobu InoueNOTE:
4349a4365d0SYoshinobu Inoue.Ar upperspec
435fb170c44SGeorge V. Neville-Neildoes not work in the forwarding case at this moment,
436fb170c44SGeorge V. Neville-Neilas it requires extra reassembly at forwarding node,
437fb170c44SGeorge V. Neville-Neilwhich is not implemented at this moment.
438fb170c44SGeorge V. Neville-NeilAlthough there are many protocols in
43933841545SHajimu UMEMOTO.Pa /etc/protocols ,
440fb170c44SGeorge V. Neville-Neilprotocols other than TCP, UDP and ICMP may not be suitable to use with IPsec.
4419a4365d0SYoshinobu Inoue.\"
442059b1593SBen Smithurst.Pp
4439a4365d0SYoshinobu Inoue.It Ar policy
4449a4365d0SYoshinobu Inoue.Ar policy
445fb170c44SGeorge V. Neville-Neilis expressed in one of the following three formats:
446b2e52cedSUlrich Spörlein.Pp
44729e758c2SJoel Dahl.Bl -tag -width 2n -compact
448cf43a054SHajimu UMEMOTO.It Fl P Ar direction Li discard
449cf43a054SHajimu UMEMOTO.It Fl P Ar direction Li none
450cf43a054SHajimu UMEMOTO.It Xo Fl P Ar direction Li ipsec
451cf43a054SHajimu UMEMOTO.Ar protocol/mode/src-dst/level Op ...
45233841545SHajimu UMEMOTO.Xc
453b2e52cedSUlrich Spörlein.El
4549a4365d0SYoshinobu Inoue.Pp
455fb170c44SGeorge V. Neville-NeilThe direction of a policy must be specified as
456fb170c44SGeorge V. Neville-Neilone of:
457fb170c44SGeorge V. Neville-Neil.Li out ,
458fb170c44SGeorge V. Neville-Neil.Li in ,
4598266d476SRuslan Ermilov.Li discard ,
460fb170c44SGeorge V. Neville-Neil.Li none ,
461fb170c44SGeorge V. Neville-Neilor
462fb170c44SGeorge V. Neville-Neil.Li ipsec .
4638266d476SRuslan ErmilovThe
4648266d476SRuslan Ermilov.Li discard
4658266d476SRuslan Ermilovdirection
466fb170c44SGeorge V. Neville-Neilmeans that packets matching the supplied indices will be discarded
467fb170c44SGeorge V. Neville-Neilwhile
4689a4365d0SYoshinobu Inoue.Li none
469fb170c44SGeorge V. Neville-Neilmeans that IPsec operations will not take place on the packet and
4709a4365d0SYoshinobu Inoue.Li ipsec
4719a4365d0SYoshinobu Inouemeans that IPsec operation will take place onto the packet.
472fb170c44SGeorge V. Neville-NeilThe
473cf43a054SHajimu UMEMOTO.Ar protocol/mode/src-dst/level
474fb170c44SGeorge V. Neville-Neilstatement gives the rule for how to process the packet.
4758266d476SRuslan ErmilovThe
4768266d476SRuslan Ermilov.Ar protocol
4778266d476SRuslan Ermilovis specified as
4789a4365d0SYoshinobu Inoue.Li ah ,
4799a4365d0SYoshinobu Inoue.Li esp
4809a4365d0SYoshinobu Inoueor
48119d35886SMaxim Konovalov.Li ipcomp .
482fb170c44SGeorge V. Neville-NeilThe
4839a4365d0SYoshinobu Inoue.Ar mode
4849a4365d0SYoshinobu Inoueis either
4859a4365d0SYoshinobu Inoue.Li transport
4869a4365d0SYoshinobu Inoueor
4879a4365d0SYoshinobu Inoue.Li tunnel .
48833841545SHajimu UMEMOTOIf
48933841545SHajimu UMEMOTO.Ar mode
49033841545SHajimu UMEMOTOis
49133841545SHajimu UMEMOTO.Li tunnel ,
492fb170c44SGeorge V. Neville-Neilyou must specify the end-point addresses of the SA as
4939a4365d0SYoshinobu Inoue.Ar src
4949a4365d0SYoshinobu Inoueand
4959a4365d0SYoshinobu Inoue.Ar dst
496fb170c44SGeorge V. Neville-Neilwith a dash,
497fb170c44SGeorge V. Neville-Neil.Sq - ,
498fb170c44SGeorge V. Neville-Neilbetween the addresses.
49933841545SHajimu UMEMOTOIf
50033841545SHajimu UMEMOTO.Ar mode
50133841545SHajimu UMEMOTOis
50233841545SHajimu UMEMOTO.Li transport ,
50333841545SHajimu UMEMOTOboth
50433841545SHajimu UMEMOTO.Ar src
50533841545SHajimu UMEMOTOand
50633841545SHajimu UMEMOTO.Ar dst
50757bd0fc6SJens Schweikhardtcan be omitted.
508fb170c44SGeorge V. Neville-NeilThe
5099a4365d0SYoshinobu Inoue.Ar level
510fb170c44SGeorge V. Neville-Neilis one of the following:
51133841545SHajimu UMEMOTO.Li default , use , require
5129a4365d0SYoshinobu Inoueor
51333841545SHajimu UMEMOTO.Li unique .
51433841545SHajimu UMEMOTOIf the SA is not available in every level, the kernel will request
515fb170c44SGeorge V. Neville-Neilthe SA from the key exchange daemon.
516fb170c44SGeorge V. Neville-NeilA value of
5179a4365d0SYoshinobu Inoue.Li default
518fb170c44SGeorge V. Neville-Neiltells the kernel to use the system wide default protocol
519c14beb68SWarren Blocke.g.,\& the one from the
5209a4365d0SYoshinobu Inoue.Li esp_trans_deflev
5213c62e87aSJun-ichiro itojun Haginosysctl variable, when the kernel processes the packet.
5228266d476SRuslan ErmilovA value of
5238266d476SRuslan Ermilov.Li use
524fb170c44SGeorge V. Neville-Neilmeans that the kernel will use an SA if it is available,
525fb170c44SGeorge V. Neville-Neilotherwise the kernel will pass the packet as it would normally.
5268266d476SRuslan ErmilovA value of
5278266d476SRuslan Ermilov.Li require
528fb170c44SGeorge V. Neville-Neilmeans that an SA is required whenever the kernel sends a packet matched
529fb170c44SGeorge V. Neville-Neilthat matches the policy.
530fb170c44SGeorge V. Neville-NeilThe
53133841545SHajimu UMEMOTO.Li unique
532fb170c44SGeorge V. Neville-Neillevel is the same as
533fb170c44SGeorge V. Neville-Neil.Li require
534fb170c44SGeorge V. Neville-Neilbut, in addition, it allows the policy to bind with the unique out-bound SA.
535fb170c44SGeorge V. Neville-NeilFor example, if you specify the policy level
536cf43a054SHajimu UMEMOTO.Li unique ,
537cf43a054SHajimu UMEMOTO.Xr racoon 8
538cf43a054SHajimu UMEMOTOwill configure the SA for the policy.
539cf43a054SHajimu UMEMOTOIf you configure the SA by manual keying for that policy,
54033841545SHajimu UMEMOTOyou can put the decimal number as the policy identifier after
54133841545SHajimu UMEMOTO.Li unique
54233841545SHajimu UMEMOTOseparated by colon
5436992e2a5SRuslan Ermilov.Ql :\&
544fb170c44SGeorge V. Neville-Neilas in the following example:
54533841545SHajimu UMEMOTO.Li unique:number .
5466992e2a5SRuslan ErmilovIn order to bind this policy to the SA,
54733841545SHajimu UMEMOTO.Li number
548fb170c44SGeorge V. Neville-Neilmust be between 1 and 32767,
549fb170c44SGeorge V. Neville-Neilwhich corresponds to
550cf43a054SHajimu UMEMOTO.Ar extensions Fl u
551fb170c44SGeorge V. Neville-Neilof manual SA configuration.
552fb170c44SGeorge V. Neville-Neil.Pp
5538266d476SRuslan ErmilovWhen you want to use an SA bundle, you can define multiple rules.
5548266d476SRuslan ErmilovFor
555fb170c44SGeorge V. Neville-Neilexample, if an IP header was followed by an AH header followed by an
556fb170c44SGeorge V. Neville-NeilESP header followed by an upper layer protocol header, the rule would
557fb170c44SGeorge V. Neville-Neilbe:
55829e758c2SJoel Dahl.Pp
559cf43a054SHajimu UMEMOTO.Dl esp/transport//require ah/transport//require ;
56029e758c2SJoel Dahl.Pp
561cf43a054SHajimu UMEMOTOThe rule order is very important.
56233841545SHajimu UMEMOTO.Pp
5639a4365d0SYoshinobu InoueNote that
5649a4365d0SYoshinobu Inoue.Dq Li discard
5659a4365d0SYoshinobu Inoueand
5669a4365d0SYoshinobu Inoue.Dq Li none
5679a4365d0SYoshinobu Inoueare not in the syntax described in
5689a4365d0SYoshinobu Inoue.Xr ipsec_set_policy 3 .
569fb170c44SGeorge V. Neville-NeilThere are small, but important, differences in the syntax.
5709a4365d0SYoshinobu InoueSee
5719a4365d0SYoshinobu Inoue.Xr ipsec_set_policy 3
572fb170c44SGeorge V. Neville-Neilfor details.
5739a4365d0SYoshinobu Inoue.El
5749a4365d0SYoshinobu Inoue.\"
5759a4365d0SYoshinobu Inoue.Sh ALGORITHMS
5769a4365d0SYoshinobu InoueThe following list shows the supported algorithms.
577fb170c44SGeorge V. Neville-NeilThe
5789a4365d0SYoshinobu Inoue.Sy protocol
5799a4365d0SYoshinobu Inoueand
5809a4365d0SYoshinobu Inoue.Sy algorithm
581fb170c44SGeorge V. Neville-Neilare almost completely orthogonal.
582fb170c44SGeorge V. Neville-NeilThe following list of authentication algorithms can be used as
5839a4365d0SYoshinobu Inoue.Ar aalgo
584fb170c44SGeorge V. Neville-Neilin the
5859a4365d0SYoshinobu Inoue.Fl A Ar aalgo
586fb170c44SGeorge V. Neville-Neilof the
5879a4365d0SYoshinobu Inoue.Ar protocol
5889a4365d0SYoshinobu Inoueparameter:
5899a4365d0SYoshinobu Inoue.Bd -literal -offset indent
5909a4365d0SYoshinobu Inouealgorithm	keylen (bits)	comment
5919a4365d0SYoshinobu Inouehmac-sha1	160		ah: rfc2404
5929a4365d0SYoshinobu Inoue		160		ah-old: 128bit ICV (no document)
5939a4365d0SYoshinobu Inouenull		0 to 2048	for debugging
594db881946SAndrey V. Elsukovhmac-sha2-256	256		ah: 128bit ICV (RFC4868)
59533841545SHajimu UMEMOTO		256		ah-old: 128bit ICV (no document)
596db881946SAndrey V. Elsukovhmac-sha2-384	384		ah: 192bit ICV (RFC4868)
59733841545SHajimu UMEMOTO		384		ah-old: 128bit ICV (no document)
598db881946SAndrey V. Elsukovhmac-sha2-512	512		ah: 256bit ICV (RFC4868)
59933841545SHajimu UMEMOTO		512		ah-old: 128bit ICV (no document)
600db540018SHajimu UMEMOTOaes-xcbc-mac	128		ah: 96bit ICV (RFC3566)
601db540018SHajimu UMEMOTO		128		ah-old: 128bit ICV (no document)
6021922fd12SBruce M Simpsontcp-md5		8 to 640	tcp: rfc2385
6039a4365d0SYoshinobu Inoue.Ed
6049a4365d0SYoshinobu Inoue.Pp
605fb170c44SGeorge V. Neville-NeilThe following is the list of encryption algorithms that can be used as the
6069a4365d0SYoshinobu Inoue.Ar ealgo
607fb170c44SGeorge V. Neville-Neilin the
6089a4365d0SYoshinobu Inoue.Fl E Ar ealgo
609fb170c44SGeorge V. Neville-Neilof the
6109a4365d0SYoshinobu Inoue.Ar protocol
6119a4365d0SYoshinobu Inoueparameter:
6129a4365d0SYoshinobu Inoue.Bd -literal -offset indent
6139a4365d0SYoshinobu Inouealgorithm	keylen (bits)	comment
614cf43a054SHajimu UMEMOTOnull		0 to 2048	rfc2410
615*00a4311aSJohn Baldwinaes-cbc		128/192/256	rfc3602
616af5b6f81SJohn Baldwinaes-ctr		160/224/288	rfc3686
617987de844SGeorge V. Neville-Neilaes-gcm-16	160/224/288	rfc4106
6189a4365d0SYoshinobu Inoue.Ed
6199a4365d0SYoshinobu Inoue.Pp
6204c4090f5SPawel Jakub DawidekNote that the first 128/192/256 bits of a key for
621987de844SGeorge V. Neville-Neil.Li aes-ctr or aes-gcm-16
622b42ac57fSHajimu UMEMOTOwill be used as AES key, and remaining 32 bits will be used as nonce.
623b42ac57fSHajimu UMEMOTO.Pp
624fb170c44SGeorge V. Neville-NeilThe following are the list of compression algorithms that can be used
625fb170c44SGeorge V. Neville-Neilas the
6269a4365d0SYoshinobu Inoue.Ar calgo
627fb170c44SGeorge V. Neville-Neilin the
6289a4365d0SYoshinobu Inoue.Fl C Ar calgo
629fb170c44SGeorge V. Neville-Neilof the
6309a4365d0SYoshinobu Inoue.Ar protocol
6319a4365d0SYoshinobu Inoueparameter:
6329a4365d0SYoshinobu Inoue.Bd -literal -offset indent
6339a4365d0SYoshinobu Inouealgorithm	comment
6349a4365d0SYoshinobu Inouedeflate		rfc2394
6359a4365d0SYoshinobu Inoue.Ed
6369a4365d0SYoshinobu Inoue.\"
637a866e170SRuslan Ermilov.Sh EXIT STATUS
6386992e2a5SRuslan Ermilov.Ex -std
639cf43a054SHajimu UMEMOTO.\"
6409a4365d0SYoshinobu Inoue.Sh EXAMPLES
641fb170c44SGeorge V. Neville-NeilAdd an ESP SA between two IPv6 addresses using the
64216aabb76SJohn BaldwinAES-GCM encryption algorithm.
64346355096SJoel Dahl.Bd -literal -offset indent
6449a4365d0SYoshinobu Inoueadd 3ffe:501:4819::1 3ffe:501:481d::1 esp 123457
64516aabb76SJohn Baldwin	-E aes-gcm-16 0x3ffe050148193ffe050148193ffe050148193ffe ;
646c14beb68SWarren Block.Pp
647fb170c44SGeorge V. Neville-Neil.Ed
648fb170c44SGeorge V. Neville-Neil.\"
649fb170c44SGeorge V. Neville-NeilAdd an authentication SA between two FQDN specified hosts:
65046355096SJoel Dahl.Bd -literal -offset indent
651cf43a054SHajimu UMEMOTOadd -6 myhost.example.com yourhost.example.com ah 123456
65216aabb76SJohn Baldwin	-A hmac-sha2-256 "AH SA configuration!" ;
653c14beb68SWarren Block.Pp
654fb170c44SGeorge V. Neville-Neil.Ed
65516d1ba4fSMaxim KonovalovGet the SA information associated with first example above:
65646355096SJoel Dahl.Bd -literal -offset indent
6579a4365d0SYoshinobu Inoueget 3ffe:501:4819::1 3ffe:501:481d::1 ah 123456 ;
658c14beb68SWarren Block.Pp
659fb170c44SGeorge V. Neville-Neil.Ed
660fb170c44SGeorge V. Neville-NeilFlush all entries from the database:
66146355096SJoel Dahl.Bd -literal -offset indent
6629a4365d0SYoshinobu Inoueflush ;
663c14beb68SWarren Block.Pp
664fb170c44SGeorge V. Neville-Neil.Ed
665fb170c44SGeorge V. Neville-NeilDump the ESP entries from the database:
66646355096SJoel Dahl.Bd -literal -offset indent
6679a4365d0SYoshinobu Inouedump esp ;
668c14beb68SWarren Block.Pp
669fb170c44SGeorge V. Neville-Neil.Ed
670fb170c44SGeorge V. Neville-NeilAdd a security policy between two networks that uses ESP in tunnel mode:
67146355096SJoel Dahl.Bd -literal -offset indent
6729a4365d0SYoshinobu Inouespdadd 10.0.11.41/32[21] 10.0.11.33/32[any] any
6739a4365d0SYoshinobu Inoue	-P out ipsec esp/tunnel/192.168.0.1-192.168.1.2/require ;
674c14beb68SWarren Block.Pp
675fb170c44SGeorge V. Neville-Neil.Ed
676fb170c44SGeorge V. Neville-NeilUse TCP MD5 between two numerically specified hosts:
67746355096SJoel Dahl.Bd -literal -offset indent
6781922fd12SBruce M Simpsonadd 10.1.10.34 10.1.10.36 tcp 0x1000 -A tcp-md5 "TCP-MD5 BGP secret" ;
6791bbe19e6SAndrey V. Elsukovadd 10.1.10.36 10.1.10.34 tcp 0x1001 -A tcp-md5 "TCP-MD5 BGP secret" ;
6809a4365d0SYoshinobu Inoue.Ed
6819a4365d0SYoshinobu Inoue.\"
6829a4365d0SYoshinobu Inoue.Sh SEE ALSO
6839a4365d0SYoshinobu Inoue.Xr ipsec_set_policy 3 ,
68422986c67SAndrey V. Elsukov.Xr if_ipsec 4 ,
6855521ff5aSRuslan Ermilov.Xr racoon 8 ,
6865521ff5aSRuslan Ermilov.Xr sysctl 8
687cf43a054SHajimu UMEMOTO.Rs
688cf43a054SHajimu UMEMOTO.%T "Changed manual key configuration for IPsec"
689aa4a335bSRuslan Ermilov.%U http://www.kame.net/newsletter/19991007/
690cf43a054SHajimu UMEMOTO.%D "October 1999"
691cf43a054SHajimu UMEMOTO.Re
6929a4365d0SYoshinobu Inoue.\"
6939a4365d0SYoshinobu Inoue.Sh HISTORY
6949a4365d0SYoshinobu InoueThe
6959a4365d0SYoshinobu Inoue.Nm
6966992e2a5SRuslan Ermilovutility first appeared in WIDE Hydrangea IPv6 protocol stack kit.
6976992e2a5SRuslan ErmilovThe utility was completely re-designed in June 1998.
698032a05d5SSevan JaniyanIt first appeared in
699032a05d5SSevan Janiyan.Fx 4.0 .
7003c62e87aSJun-ichiro itojun Hagino.\"
701cf43a054SHajimu UMEMOTO.Sh BUGS
7026992e2a5SRuslan ErmilovThe
703cf43a054SHajimu UMEMOTO.Nm
7046992e2a5SRuslan Ermilovutility
705cf43a054SHajimu UMEMOTOshould report and handle syntax errors better.
706cf43a054SHajimu UMEMOTO.Pp
707cf43a054SHajimu UMEMOTOFor IPsec gateway configuration,
708cf43a054SHajimu UMEMOTO.Ar src_range
709cf43a054SHajimu UMEMOTOand
710cf43a054SHajimu UMEMOTO.Ar dst_range
711cf43a054SHajimu UMEMOTOwith TCP/UDP port number do not work, as the gateway does not reassemble
712cf43a054SHajimu UMEMOTOpackets
7136992e2a5SRuslan Ermilov(cannot inspect upper-layer headers).
714