Project

General

Profile

Usable Examples configurations » History » Version 9

Noel Kuntze, 26.10.2016 22:43
fixed xauth configs (xauth=server was missing).

1 1 Noel Kuntze
h1. Sane Example configurations
2 1 Noel Kuntze
3 1 Noel Kuntze
Preliminary obligatory notes:
4 1 Noel Kuntze
* These examples follow the [[SecurityRecommendations|Security Recommendations]]. Follow them. They are there
5 1 Noel Kuntze
  for a reason.
6 1 Noel Kuntze
* You can have several conn sections in your @ipsec.conf@ file
7 2 Noel Kuntze
* In scenarios where the remote peer authenticates itself with a client certificate,
8 4 Noel Kuntze
  charon requires all certificates that are in the trust path of the client's certificate
9 4 Noel Kuntze
  to be present, readable and valid for authentication
10 2 Noel Kuntze
  to be successful. charon implicitely trusts all CA certificates that it loads
11 1 Noel Kuntze
  via local files or that are loaded via the VICI API.
12 4 Noel Kuntze
* In scenarios where charon authenticates itself with a certificate, it needs to have
13 4 Noel Kuntze
  all certificates in the trust path. 
14 4 Noel Kuntze
* charon only reads the first certificate in a file.
15 1 Noel Kuntze
* Your responder (the proper word for "server" in ipsec talk) needs to identify
16 1 Noel Kuntze
  and authenticate itself to the initiator (the proper word for "client" in ipsec talk)
17 1 Noel Kuntze
  with the apropriate identity. If your initiator wants to talk to "foo.bar.com",
18 1 Noel Kuntze
  your responder needs to identify and authenticate itself as _foo.bar.com_.
19 1 Noel Kuntze
* Credentials are bound to identities. You can not successfully authenticate yourself
20 1 Noel Kuntze
  as the identitiy _foo.bar.com_ with a certificate if that certificate is not issued for that
21 1 Noel Kuntze
  identity. The identities that a certificate provide are its complete DN and the SAN fields.
22 1 Noel Kuntze
* The used cipher suite must be supported by both sides. Some implementations
23 3 Noel Kuntze
  only support weak crypto. Do not make concessions, unless necessary for interoperability.
24 1 Noel Kuntze
* XAUTH credentials are handled internally as EAP credentials. Both are valid for
25 1 Noel Kuntze
  XAUTH, EAP-GTC, EAP-MSCHAPv2 and whatever other cleartext or digest based
26 1 Noel Kuntze
  authentication might be implemented in the future.
27 1 Noel Kuntze
* The cipher settings are deliberately ordered by performance.
28 6 Noel Kuntze
  Faster, but secure ciphers appear in the beginning of the cipher list.
29 6 Noel Kuntze
  That should make charon choose faster, but secure ones first.  
30 1 Noel Kuntze
* Do not use MD5, DES or 3DES. They are broken.
31 1 Noel Kuntze
* The algorithm your certificate uses and they algorithm the key exchange uses
32 1 Noel Kuntze
  do not have anything to do with each other.
33 1 Noel Kuntze
* strongSwan does not implement L2TP.
34 1 Noel Kuntze
* Read the documentation and use "the search function":https://wiki.strongswan.org/projects/strongswan/search.
35 1 Noel Kuntze
36 1 Noel Kuntze
h2. Roadwarrior scenario
37 9 Noel Kuntze
38 1 Noel Kuntze
This is an example configuration that provides support for several clients
39 1 Noel Kuntze
with several authentication styles.
40 1 Noel Kuntze
41 1 Noel Kuntze
{{collapse(ipsec.conf)
42 1 Noel Kuntze
<pre>
43 1 Noel Kuntze
conn rw-base
44 1 Noel Kuntze
    # enables IKE fragmentation 
45 1 Noel Kuntze
    fragmentation=yes
46 1 Noel Kuntze
    dpdaction=clear
47 1 Noel Kuntze
    # dpdtimeout is not honored for ikev2. For IKEv2, every message is used
48 1 Noel Kuntze
    # to determine the timeout, so the generic timeout value for IKEv2 messages
49 1 Noel Kuntze
    # is used. 
50 1 Noel Kuntze
    dpdtimeout=90s
51 1 Noel Kuntze
    dpddelay=30s
52 1 Noel Kuntze
53 1 Noel Kuntze
# this is used in every conn in which the client is assigned a "virtual" IP or
54 1 Noel Kuntze
# one or several DNS servers    
55 1 Noel Kuntze
# the cipher suits require the openssl plugin.
56 1 Noel Kuntze
conn rw-config
57 1 Noel Kuntze
    also=rw-base
58 1 Noel Kuntze
    rightsourceip=172.16.252.0/24
59 1 Noel Kuntze
    # set this to a local DNS server that the clients can reach with their assigned IPs.
60 1 Noel Kuntze
    # Think about routing.
61 1 Noel Kuntze
    rightdns=
62 1 Noel Kuntze
    leftsubnet=0.0.0.0/0
63 1 Noel Kuntze
    leftid=whatevertheclientusestoconnect
64 1 Noel Kuntze
    leftcert=mycertificate.pem
65 1 Noel Kuntze
    # not possible with asymmetric authentication
66 1 Noel Kuntze
    reauth=no
67 1 Noel Kuntze
    rekey=no
68 1 Noel Kuntze
    # sane cipher suits
69 1 Noel Kuntze
    ike=aes192gcm16-aes128gcm16-aes192-prfsha256-ecp256-ecp521,aes192-sha256-modp3072
70 1 Noel Kuntze
    esp=aes192gcm16-aes128gcm16-aes192-ecp256,aes192-sha256-modp3072#
71 1 Noel Kuntze
    leftsendcert=always
72 1 Noel Kuntze
    rightca="C=This, O=Is, OU=My, CN=CA"
73 1 Noel Kuntze
    
74 1 Noel Kuntze
# this conn is set up for l2tp support where the user authentication is happening
75 1 Noel Kuntze
# in the l2tp control connection. With L2TP, clients are usually not assigned
76 1 Noel Kuntze
# a virtual IP in IKE.
77 1 Noel Kuntze
# Charon is not an l2tp server. You need to install xl2tp for that and configure it correctly.
78 1 Noel Kuntze
# mark=%unique requires the connmark plugin.
79 1 Noel Kuntze
conn ikev1-l2tp-chap-auth-in-xl2tpd
80 1 Noel Kuntze
    also=rw-base
81 1 Noel Kuntze
    # reduce to the most secure combination the client can support, if absolutely required.
82 1 Noel Kuntze
    ike=aes128-sha1-modp3072
83 1 Noel Kuntze
    esp=aes128-sha1-modp3073
84 1 Noel Kuntze
    leftsubnet=%dynamic[/1701]
85 1 Noel Kuntze
    rightsubnet=%dynamic[/1701]
86 1 Noel Kuntze
    mark=%unique
87 1 Noel Kuntze
    leftauth=psk
88 1 Noel Kuntze
    rightauth=psk
89 1 Noel Kuntze
    type=transport
90 1 Noel Kuntze
    auto=add
91 1 Noel Kuntze
    
92 1 Noel Kuntze
# this conn is set up for l2tp support where the user authentication is happening
93 1 Noel Kuntze
# during the IKEv1 authentication. With L2TP, clients are usually not assigned
94 1 Noel Kuntze
# a virtual IP in IKE.
95 1 Noel Kuntze
# mark=%unique requires the connmark plugin.
96 1 Noel Kuntze
# this requires the xauth-generic plugin.
97 1 Noel Kuntze
conn ikev1-l2tp-xauth-in-ike
98 1 Noel Kuntze
    also=rw-base
99 1 Noel Kuntze
    # reduce to the most secure combination the client can support, if absolutely required.
100 1 Noel Kuntze
    ike=aes128-sha1-modp3072
101 1 Noel Kuntze
    esp=aes128-sha1-modp3073
102 1 Noel Kuntze
    leftsubnet=%dynamic[/1701]
103 1 Noel Kuntze
    rightsubnet=%dynamic[/1701]
104 1 Noel Kuntze
    mark=%unique
105 1 Noel Kuntze
    leftauth=psk
106 1 Noel Kuntze
    rightauth=psk
107 1 Noel Kuntze
    rightauth2=xauth-generic
108 9 Noel Kuntze
    xauth=server
109 1 Noel Kuntze
    # not possible with asymmetric authentication
110 1 Noel Kuntze
    reauth=no
111 1 Noel Kuntze
    rekey=no
112 1 Noel Kuntze
    type=transport
113 1 Noel Kuntze
    auto=add
114 1 Noel Kuntze
    
115 1 Noel Kuntze
# this requires the xauth-generic plugin.
116 1 Noel Kuntze
conn ikev1-psk-xauth
117 1 Noel Kuntze
    also=rw-config
118 1 Noel Kuntze
    leftauth=psk
119 1 Noel Kuntze
    rightauth=psk
120 1 Noel Kuntze
    rightauth2=xauth-generic
121 9 Noel Kuntze
    xauth=server
122 1 Noel Kuntze
    auto=add
123 1 Noel Kuntze
124 1 Noel Kuntze
# leftauth and rightauth default to "pubkey", so no change necessary.
125 1 Noel Kuntze
conn ikev1-pubkey
126 1 Noel Kuntze
    also=rw-config
127 1 Noel Kuntze
    auto=add
128 1 Noel Kuntze
129 1 Noel Kuntze
# this requires the xauth-generic plugin.
130 1 Noel Kuntze
conn ikev1-pubkey-xauth
131 1 Noel Kuntze
    also=rw-config
132 1 Noel Kuntze
    rightauth2=xauth-generic
133 9 Noel Kuntze
    xauth=server
134 1 Noel Kuntze
    auto=add
135 1 Noel Kuntze
136 1 Noel Kuntze
# this requires the xauth-generic plugin.
137 1 Noel Kuntze
conn ikev1-hybrid
138 1 Noel Kuntze
    also=rw-config
139 1 Noel Kuntze
    rightauth=xauth-generic
140 9 Noel Kuntze
    xauth=server
141 1 Noel Kuntze
142 1 Noel Kuntze
conn ikev2-pubkey
143 1 Noel Kuntze
    also=rw-config
144 1 Noel Kuntze
    auto=add
145 1 Noel Kuntze
146 1 Noel Kuntze
# this requires the eap-tls plugin.
147 1 Noel Kuntze
conn ikev2-eap-tls
148 1 Noel Kuntze
    also=rw-base
149 1 Noel Kuntze
    rightauth=eap-tls
150 1 Noel Kuntze
    eap_identity=%identity
151 1 Noel Kuntze
    auto=add
152 1 Noel Kuntze
153 1 Noel Kuntze
# this requires the eap-mschapv2 plugin.
154 1 Noel Kuntze
conn ikev2-eap-mschapv2
155 1 Noel Kuntze
    also=rw-config
156 1 Noel Kuntze
    rightauth=eap-mschapv2
157 1 Noel Kuntze
    eap_identity=%identity
158 1 Noel Kuntze
    auto=add
159 1 Noel Kuntze
</pre>
160 1 Noel Kuntze
}}
161 1 Noel Kuntze
162 1 Noel Kuntze
{{collapse(ipsec.secrets)
163 1 Noel Kuntze
<pre>
164 1 Noel Kuntze
: PSK "foobarblah"
165 1 Noel Kuntze
: RSA myprivatekey.pem
166 1 Noel Kuntze
carol : EAP "carolspassword"
167 1 Noel Kuntze
</pre>
168 1 Noel Kuntze
}}
169 9 Noel Kuntze
170 1 Noel Kuntze
171 1 Noel Kuntze
h2. Site-To-Site-Scenario
172 1 Noel Kuntze
173 1 Noel Kuntze
{{collapse(ipsec.conf)
174 1 Noel Kuntze
<pre>
175 1 Noel Kuntze
conn sts-base
176 1 Noel Kuntze
    fragmentation=yes
177 1 Noel Kuntze
    dpdaction=restart
178 1 Noel Kuntze
    ike=aes192gcm16-aes128gcm16-aes192-prfsha256-ecp256-ecp521,aes192-sha256-modp3072
179 1 Noel Kuntze
    esp=aes192gcm16-aes128gcm16-aes192-ecp256,aes192-sha256-modp3072#
180 1 Noel Kuntze
    keyingtries=%forever
181 1 Noel Kuntze
    leftcert=foobar.pem
182 1 Noel Kuntze
183 1 Noel Kuntze
# this conn is set up for a host with a static IP
184 1 Noel Kuntze
conn site-1-static-ip
185 1 Noel Kuntze
    also=sts-base
186 1 Noel Kuntze
    keyexchange=ikev2
187 1 Noel Kuntze
    leftsubnet=10.1.2.0/24,10.1.1.0/24
188 1 Noel Kuntze
    rightsubnet=10.1.3.0/24
189 1 Noel Kuntze
    right=1.2.3.4
190 1 Noel Kuntze
    rightcert=1.2.3.4.pem
191 1 Noel Kuntze
    auto=route
192 1 Noel Kuntze
193 1 Noel Kuntze
# this conn is set up for a host with a dynamic IP
194 1 Noel Kuntze
conn site-2-dynamic-ip
195 1 Noel Kuntze
    also=sts-base
196 1 Noel Kuntze
    keyexchange=ikev2
197 1 Noel Kuntze
    leftsubnet=10.1.2.0/24,10.1.1.0/24
198 1 Noel Kuntze
    rightsubnet=10.1.4.0/24
199 1 Noel Kuntze
    # for this to work, DNS must be usable and working.
200 1 Noel Kuntze
    right=%example.com
201 1 Noel Kuntze
    rightcert=example.com.pem
202 1 Noel Kuntze
    auto=route
203 1 Noel Kuntze
204 1 Noel Kuntze
# this conn is set up for IKEv1 compatibility. It shows how to define several subnets
205 1 Noel Kuntze
# with IKEv1. site-3-legacy-1 and site-3-legacy-2 keep the data for the CHILD_SA.
206 1 Noel Kuntze
# The same can be accomplished with implicit merging by specifying the same IKE_SA
207 1 Noel Kuntze
# configuration in two different conns. This set up is cleaner, though.
208 1 Noel Kuntze
# If you put "auto=route" into the "site-3-legacy-base conn", charon will route the
209 1 Noel Kuntze
# conn with the ts being the local IP that is used to communicate with the remote
210 1 Noel Kuntze
# peer and the remote's peer. If such a CHILD_SA is not configured on the peer, ICMP
211 1 Noel Kuntze
# error messages from the remote peer to the local peer will not be able to be transmitted.
212 1 Noel Kuntze
# So don't do that, unless your remote peer is configured for that.
213 1 Noel Kuntze
# This is an IKEv1 connection with PSK authentication. That means, that you need to know
214 1 Noel Kuntze
# the other side's IP.
215 1 Noel Kuntze
conn site-3-legacy-base
216 1 Noel Kuntze
    also=sts-base
217 1 Noel Kuntze
    keyexchange=ikev1
218 1 Noel Kuntze
    # IKE and ESP cipher settings are reconfigured, because in IKEv1 every 
219 1 Noel Kuntze
    # single cipher suite needs to be enumerated.
220 1 Noel Kuntze
    # It is not possible to define all supported ciphers in one suite.
221 1 Noel Kuntze
    # select apropriate and strong ciphers for your scenario.
222 1 Noel Kuntze
    ike=aes192gcm16-prfsha256-ecp256,aes128gcm16-prfsha256-ecp256,aes128gcm16-prfsha256-ecp521,aes192-sha256-modp3072
223 1 Noel Kuntze
    esp=aes192gcm16-ecp256,aes192-sha256-modp3072
224 1 Noel Kuntze
    rightsubnet=10.1.5.0/24
225 1 Noel Kuntze
    # for this to work, DNS must be usable and working.
226 1 Noel Kuntze
    right=example.com
227 1 Noel Kuntze
    leftauth=psk
228 1 Noel Kuntze
    rightauth=psk
229 1 Noel Kuntze
230 1 Noel Kuntze
conn site-3-legacy-1
231 1 Noel Kuntze
    leftsubnet=10.1.1.0/24
232 1 Noel Kuntze
    also=site-3-legacy-base
233 1 Noel Kuntze
    auto=route
234 1 Noel Kuntze
235 1 Noel Kuntze
conn site-3-legacy-2
236 1 Noel Kuntze
    leftsubnet=10.1.2.0/24
237 1 Noel Kuntze
    also=site-3-legacy-base
238 1 Noel Kuntze
    auto=route
239 1 Noel Kuntze
</pre>
240 1 Noel Kuntze
}}
241 1 Noel Kuntze
242 1 Noel Kuntze
{{collapse(ipsec.secrets)
243 1 Noel Kuntze
<pre>
244 1 Noel Kuntze
: RSA foobar.key
245 1 Noel Kuntze
remote.com : EAP "example"
246 1 Noel Kuntze
</pre>
247 1 Noel Kuntze
}}
248 5 Noel Kuntze
249 5 Noel Kuntze
h2. passthrough policy
250 5 Noel Kuntze
251 5 Noel Kuntze
{{collapse(ipsec.conf)
252 5 Noel Kuntze
<pre>
253 5 Noel Kuntze
conn passthrough-1
254 5 Noel Kuntze
    # makes sure those conns are excluded from every conn selection
255 5 Noel Kuntze
    left=127.0.0.1
256 5 Noel Kuntze
    right=127.0.0.1
257 5 Noel Kuntze
    # Those are just example values. Replace them with the apropriate ones!
258 5 Noel Kuntze
    leftsubnet=10.0.0.0/8
259 5 Noel Kuntze
    rightsubnet=10.0.0.0/8
260 5 Noel Kuntze
    # those two lines are critical.
261 5 Noel Kuntze
    type=passthrough
262 5 Noel Kuntze
    auto=route
263 5 Noel Kuntze
</pre>
264 5 Noel Kuntze
}}
265 7 Noel Kuntze
266 7 Noel Kuntze
h2. host-to-host opportunistic transport mode
267 7 Noel Kuntze
268 7 Noel Kuntze
Based on "the trap-any test scenario":https://www.strongswan.org/testing/testresults/ikev2/trap-any/.
269 7 Noel Kuntze
270 7 Noel Kuntze
The hosts involved are in the 192.168.1.0/24 subnet.
271 8 Noel Kuntze
The notes from Tobias' comment in issue #196 apply:
272 8 Noel Kuntze
> The hosts can be limited by specifying rightsubnet (e.g. rightsubnet=192.168.1.0/24,192.168.2.0/30,10.0.2.2/32). It is even possible to limit this to a specific protocol/port (for any remote host use %dynamic[<proto>/<port>], not 0.0.0.0/0[...]). A new test scenario (ikev2/trap-any, bb1d9e45) provides some examples.
273 8 Noel Kuntze
> 
274 8 Noel Kuntze
> Authentication can easily be done via certificates, but using PSKs is also possible. However, because there is no pattern/subnet matching for IP-based identities you need to either use a single secret for all hosts or use identities appropriately if you want to use different PSKs for different groups of hosts (e.g. use leftid=<host>@<group>.example.com and rightid=*@<group>.example.com in ipsec.conf and *@<group>.example.com : PSK "..." in ipsec.secrets).
275 7 Noel Kuntze
276 7 Noel Kuntze
{{collapse(ipsec.conf)
277 7 Noel Kuntze
<pre>conn host-to-host
278 7 Noel Kuntze
	ikelifetime=60m
279 7 Noel Kuntze
	keylife=20m
280 7 Noel Kuntze
	rekeymargin=3m
281 7 Noel Kuntze
	keyingtries=1
282 7 Noel Kuntze
283 7 Noel Kuntze
conn trap-any
284 7 Noel Kuntze
    also=host-to-host
285 7 Noel Kuntze
	right=%any
286 7 Noel Kuntze
	leftsubnet=192.168.1.0/24
287 7 Noel Kuntze
	rightsubnet=192.168.1.0/24
288 7 Noel Kuntze
	type=transport
289 7 Noel Kuntze
	authby=psk
290 7 Noel Kuntze
	auto=route
291 7 Noel Kuntze
</pre>
292 7 Noel Kuntze
}}