Project

General

Profile

Usable Examples configurations » History » Version 7

Noel Kuntze, 09.10.2016 23:29
host-to-host transport mode

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 1 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 1 Noel Kuntze
    # not possible with asymmetric authentication
109 1 Noel Kuntze
    reauth=no
110 1 Noel Kuntze
    rekey=no
111 1 Noel Kuntze
    type=transport
112 1 Noel Kuntze
    auto=add
113 1 Noel Kuntze
    
114 1 Noel Kuntze
# this requires the xauth-generic plugin.
115 1 Noel Kuntze
conn ikev1-psk-xauth
116 1 Noel Kuntze
    also=rw-config
117 1 Noel Kuntze
    leftauth=psk
118 1 Noel Kuntze
    rightauth=psk
119 1 Noel Kuntze
    rightauth2=xauth-generic
120 1 Noel Kuntze
    auto=add
121 1 Noel Kuntze
122 1 Noel Kuntze
# leftauth and rightauth default to "pubkey", so no change necessary.
123 1 Noel Kuntze
conn ikev1-pubkey
124 1 Noel Kuntze
    also=rw-config
125 1 Noel Kuntze
    auto=add
126 1 Noel Kuntze
127 1 Noel Kuntze
# this requires the xauth-generic plugin.
128 1 Noel Kuntze
conn ikev1-pubkey-xauth
129 1 Noel Kuntze
    also=rw-config
130 1 Noel Kuntze
    rightauth2=xauth-generic
131 1 Noel Kuntze
    auto=add
132 1 Noel Kuntze
133 1 Noel Kuntze
# this requires the xauth-generic plugin.
134 1 Noel Kuntze
conn ikev1-hybrid
135 1 Noel Kuntze
    also=rw-config
136 1 Noel Kuntze
    rightauth=xauth-generic
137 1 Noel Kuntze
138 1 Noel Kuntze
conn ikev2-pubkey
139 1 Noel Kuntze
    also=rw-config
140 1 Noel Kuntze
    auto=add
141 1 Noel Kuntze
142 1 Noel Kuntze
# this requires the eap-tls plugin.
143 1 Noel Kuntze
conn ikev2-eap-tls
144 1 Noel Kuntze
    also=rw-base
145 1 Noel Kuntze
    rightauth=eap-tls
146 1 Noel Kuntze
    eap_identity=%identity
147 1 Noel Kuntze
    auto=add
148 1 Noel Kuntze
149 1 Noel Kuntze
# this requires the eap-mschapv2 plugin.
150 1 Noel Kuntze
conn ikev2-eap-mschapv2
151 1 Noel Kuntze
    also=rw-config
152 1 Noel Kuntze
    rightauth=eap-mschapv2
153 1 Noel Kuntze
    eap_identity=%identity
154 1 Noel Kuntze
    auto=add
155 1 Noel Kuntze
</pre>
156 1 Noel Kuntze
}}
157 1 Noel Kuntze
158 1 Noel Kuntze
{{collapse(ipsec.secrets)
159 1 Noel Kuntze
<pre>
160 1 Noel Kuntze
: PSK "foobarblah"
161 1 Noel Kuntze
: RSA myprivatekey.pem
162 1 Noel Kuntze
carol : EAP "carolspassword"
163 1 Noel Kuntze
</pre>
164 1 Noel Kuntze
}}
165 1 Noel Kuntze
166 1 Noel Kuntze
h2. Site-To-Site-Scenario
167 1 Noel Kuntze
168 1 Noel Kuntze
{{collapse(ipsec.conf)
169 1 Noel Kuntze
<pre>
170 1 Noel Kuntze
conn sts-base
171 1 Noel Kuntze
    fragmentation=yes
172 1 Noel Kuntze
    dpdaction=restart
173 1 Noel Kuntze
    ike=aes192gcm16-aes128gcm16-aes192-prfsha256-ecp256-ecp521,aes192-sha256-modp3072
174 1 Noel Kuntze
    esp=aes192gcm16-aes128gcm16-aes192-ecp256,aes192-sha256-modp3072#
175 1 Noel Kuntze
    keyingtries=%forever
176 1 Noel Kuntze
    leftcert=foobar.pem
177 1 Noel Kuntze
178 1 Noel Kuntze
# this conn is set up for a host with a static IP
179 1 Noel Kuntze
conn site-1-static-ip
180 1 Noel Kuntze
    also=sts-base
181 1 Noel Kuntze
    keyexchange=ikev2
182 1 Noel Kuntze
    leftsubnet=10.1.2.0/24,10.1.1.0/24
183 1 Noel Kuntze
    rightsubnet=10.1.3.0/24
184 1 Noel Kuntze
    right=1.2.3.4
185 1 Noel Kuntze
    rightcert=1.2.3.4.pem
186 1 Noel Kuntze
    auto=route
187 1 Noel Kuntze
188 1 Noel Kuntze
# this conn is set up for a host with a dynamic IP
189 1 Noel Kuntze
conn site-2-dynamic-ip
190 1 Noel Kuntze
    also=sts-base
191 1 Noel Kuntze
    keyexchange=ikev2
192 1 Noel Kuntze
    leftsubnet=10.1.2.0/24,10.1.1.0/24
193 1 Noel Kuntze
    rightsubnet=10.1.4.0/24
194 1 Noel Kuntze
    # for this to work, DNS must be usable and working.
195 1 Noel Kuntze
    right=%example.com
196 1 Noel Kuntze
    rightcert=example.com.pem
197 1 Noel Kuntze
    auto=route
198 1 Noel Kuntze
199 1 Noel Kuntze
# this conn is set up for IKEv1 compatibility. It shows how to define several subnets
200 1 Noel Kuntze
# with IKEv1. site-3-legacy-1 and site-3-legacy-2 keep the data for the CHILD_SA.
201 1 Noel Kuntze
# The same can be accomplished with implicit merging by specifying the same IKE_SA
202 1 Noel Kuntze
# configuration in two different conns. This set up is cleaner, though.
203 1 Noel Kuntze
# If you put "auto=route" into the "site-3-legacy-base conn", charon will route the
204 1 Noel Kuntze
# conn with the ts being the local IP that is used to communicate with the remote
205 1 Noel Kuntze
# peer and the remote's peer. If such a CHILD_SA is not configured on the peer, ICMP
206 1 Noel Kuntze
# error messages from the remote peer to the local peer will not be able to be transmitted.
207 1 Noel Kuntze
# So don't do that, unless your remote peer is configured for that.
208 1 Noel Kuntze
# This is an IKEv1 connection with PSK authentication. That means, that you need to know
209 1 Noel Kuntze
# the other side's IP.
210 1 Noel Kuntze
conn site-3-legacy-base
211 1 Noel Kuntze
    also=sts-base
212 1 Noel Kuntze
    keyexchange=ikev1
213 1 Noel Kuntze
    # IKE and ESP cipher settings are reconfigured, because in IKEv1 every 
214 1 Noel Kuntze
    # single cipher suite needs to be enumerated.
215 1 Noel Kuntze
    # It is not possible to define all supported ciphers in one suite.
216 1 Noel Kuntze
    # select apropriate and strong ciphers for your scenario.
217 1 Noel Kuntze
    ike=aes192gcm16-prfsha256-ecp256,aes128gcm16-prfsha256-ecp256,aes128gcm16-prfsha256-ecp521,aes192-sha256-modp3072
218 1 Noel Kuntze
    esp=aes192gcm16-ecp256,aes192-sha256-modp3072
219 1 Noel Kuntze
    rightsubnet=10.1.5.0/24
220 1 Noel Kuntze
    # for this to work, DNS must be usable and working.
221 1 Noel Kuntze
    right=example.com
222 1 Noel Kuntze
    leftauth=psk
223 1 Noel Kuntze
    rightauth=psk
224 1 Noel Kuntze
225 1 Noel Kuntze
conn site-3-legacy-1
226 1 Noel Kuntze
    leftsubnet=10.1.1.0/24
227 1 Noel Kuntze
    also=site-3-legacy-base
228 1 Noel Kuntze
    auto=route
229 1 Noel Kuntze
230 1 Noel Kuntze
conn site-3-legacy-2
231 1 Noel Kuntze
    leftsubnet=10.1.2.0/24
232 1 Noel Kuntze
    also=site-3-legacy-base
233 1 Noel Kuntze
    auto=route
234 1 Noel Kuntze
</pre>
235 1 Noel Kuntze
}}
236 1 Noel Kuntze
237 1 Noel Kuntze
{{collapse(ipsec.secrets)
238 1 Noel Kuntze
<pre>
239 1 Noel Kuntze
: RSA foobar.key
240 1 Noel Kuntze
remote.com : EAP "example"
241 1 Noel Kuntze
</pre>
242 1 Noel Kuntze
}}
243 5 Noel Kuntze
244 5 Noel Kuntze
h2. passthrough policy
245 5 Noel Kuntze
246 5 Noel Kuntze
{{collapse(ipsec.conf)
247 5 Noel Kuntze
<pre>
248 5 Noel Kuntze
conn passthrough-1
249 5 Noel Kuntze
    # makes sure those conns are excluded from every conn selection
250 5 Noel Kuntze
    left=127.0.0.1
251 5 Noel Kuntze
    right=127.0.0.1
252 5 Noel Kuntze
    # Those are just example values. Replace them with the apropriate ones!
253 5 Noel Kuntze
    leftsubnet=10.0.0.0/8
254 5 Noel Kuntze
    rightsubnet=10.0.0.0/8
255 5 Noel Kuntze
    # those two lines are critical.
256 5 Noel Kuntze
    type=passthrough
257 5 Noel Kuntze
    auto=route
258 5 Noel Kuntze
</pre>
259 5 Noel Kuntze
}}
260 7 Noel Kuntze
261 7 Noel Kuntze
h2. host-to-host opportunistic transport mode
262 7 Noel Kuntze
263 7 Noel Kuntze
Based on "the trap-any test scenario":https://www.strongswan.org/testing/testresults/ikev2/trap-any/.
264 7 Noel Kuntze
265 7 Noel Kuntze
The hosts involved are in the 192.168.1.0/24 subnet.
266 7 Noel Kuntze
267 7 Noel Kuntze
{{collapse(ipsec.conf)
268 7 Noel Kuntze
<pre>conn host-to-host
269 7 Noel Kuntze
	ikelifetime=60m
270 7 Noel Kuntze
	keylife=20m
271 7 Noel Kuntze
	rekeymargin=3m
272 7 Noel Kuntze
	keyingtries=1
273 7 Noel Kuntze
274 7 Noel Kuntze
conn trap-any
275 7 Noel Kuntze
    also=host-to-host
276 7 Noel Kuntze
	right=%any
277 7 Noel Kuntze
	leftsubnet=192.168.1.0/24
278 7 Noel Kuntze
	rightsubnet=192.168.1.0/24
279 7 Noel Kuntze
	type=transport
280 7 Noel Kuntze
	authby=psk
281 7 Noel Kuntze
	auto=route
282 7 Noel Kuntze
</pre>
283 7 Noel Kuntze
}}