Project

General

Profile

ipsec.conf Reference » History » Version 21

Tobias Brunner, 04.09.2024 15:35

1 16 Tobias Brunner
{{title(ipsec.conf Reference)}}
2 16 Tobias Brunner
3 21 Tobias Brunner
{{swanctl}}
4 21 Tobias Brunner
5 21 Tobias Brunner
6 12 Andreas Steffen
h1. ipsec.conf
7 1 Martin Willi
8 1 Martin Willi
9 12 Andreas Steffen
strongSwan's _/etc/ipsec.conf_ configuration file consists of three different section types:
10 1 Martin Willi
11 12 Andreas Steffen
* [[ConfigSetupSection|config setup]] defines general configuration parameters
12 12 Andreas Steffen
* [[ConnSection|conn <name>]] defines a connection
13 12 Andreas Steffen
* [[CaSection|ca <name>]] defines a certification authority
14 12 Andreas Steffen
15 18 Tobias Brunner
There can be only one [[ConfigSetupSection|config setup]] section but an unlimited number of [[ConnSection|conn]] and [[CaSection|ca]] sections.
16 12 Andreas Steffen
17 3 Martin Willi
All parameters belonging to a section must be indented by at least one space or tab
18 4 Martin Willi
character. The rest of the line after a '#' character is treated as a comment.
19 4 Martin Willi
Comments within a section must also be indented.
20 4 Martin Willi
21 15 Tobias Brunner
A line which contains *include* followed by a file name is replaced by the contents
22 15 Tobias Brunner
of that file.  If the file name is not a full pathname, it is considered to be relative
23 1 Martin Willi
to the directory containing the including file. Such inclusions can be nested. The file
24 1 Martin Willi
name may include wildcards, for example: @include ipsec.*.conf@
25 18 Tobias Brunner
26 18 Tobias Brunner
h2. Reusing Existing Parameters
27 18 Tobias Brunner
28 18 Tobias Brunner
All [[ConnSection|conn]] and [[CaSection|ca]] sections inherit the parameters defined in a @conn %default@
29 18 Tobias Brunner
or @ca %default@ section, respectively.
30 18 Tobias Brunner
31 18 Tobias Brunner
Parameters defined in other [[ConnSection|conn]] or [[CaSection|ca]] sections may be included in a section
32 19 Tobias Brunner
with the @also=othersection@ parameter.  The included section may in turn use the
33 19 Tobias Brunner
_also_ keyword to include other sections.
34 1 Martin Willi
35 19 Tobias Brunner
In versions prior to version:5.2.0 each setting could only be defined once, so settings included
36 19 Tobias Brunner
via _also_ could not be changed (the only exception were settings defined in the _%default_
37 19 Tobias Brunner
section, which could be overwritten once).
38 19 Tobias Brunner
Since version:5.2.0 settings from included sections may be changed - the same setting may
39 19 Tobias Brunner
even be defined multiple times in the same section, the last value will be used. It does
40 19 Tobias Brunner
not matter if settings are defined before or after an _also_ statement, settings in the current
41 19 Tobias Brunner
section always override inherited settings. But if multiple _also_ statements are used in the
42 19 Tobias Brunner
same section their order matters (settings from a section included later will override those
43 19 Tobias Brunner
from previously included sections). The new parser also allows to unset a setting by
44 19 Tobias Brunner
assigning no value (e.g. @leftcert=@), the setting's default value, if any, will apply, which
45 19 Tobias Brunner
may be used to "remove" settings inherited from e.g. the _%default_ section.
46 12 Andreas Steffen
47 12 Andreas Steffen
h2. Example
48 12 Andreas Steffen
49 12 Andreas Steffen
<pre>
50 9 Martin Willi
# /etc/ipsec.conf - strongSwan IPsec configuration file
51 9 Martin Willi
52 8 Martin Willi
config setup
53 8 Martin Willi
       cachecrls=yes
54 8 Martin Willi
       strictcrlpolicy=yes
55 8 Martin Willi
56 10 Martin Willi
ca strongswan  #define alternative CRL distribution point
57 8 Martin Willi
       cacert=strongswanCert.pem
58 8 Martin Willi
       crluri=http://crl2.strongswan.org/strongswan.crl
59 8 Martin Willi
       auto=add
60 8 Martin Willi
61 8 Martin Willi
conn %default
62 1 Martin Willi
       keyingtries=1
63 1 Martin Willi
       keyexchange=ikev2
64 1 Martin Willi
	
65 1 Martin Willi
conn roadwarrior
66 8 Martin Willi
       leftsubnet=10.1.0.0/16
67 8 Martin Willi
       leftcert=moonCert.pem
68 8 Martin Willi
       leftid=@moon.strongswan.org
69 8 Martin Willi
       right=%any
70 8 Martin Willi
       auto=add
71 12 Andreas Steffen
</pre>