Project

General

Profile

Usable Examples configurations » History » Version 1

Noel Kuntze, 03.10.2016 00:09
Some sane example configurations with general and usage notes.

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 1 Noel Kuntze
* Your responder (the proper word for "server" in ipsec talk) needs to identify
8 1 Noel Kuntze
  and authenticate itself to the initiator (the proper word for "client" in ipsec talk)
9 1 Noel Kuntze
  with the apropriate identity. If your initiator wants to talk to "foo.bar.com",
10 1 Noel Kuntze
  your responder needs to identify and authenticate itself as _foo.bar.com_.
11 1 Noel Kuntze
* Credentials are bound to identities. You can not successfully authenticate yourself
12 1 Noel Kuntze
  as the identitiy _foo.bar.com_ with a certificate if that certificate is not issued for that
13 1 Noel Kuntze
  identity. The identities that a certificate provide are its complete DN and the SAN fields.
14 1 Noel Kuntze
* The used cipher suite must be supported by both sides. Some implementations
15 1 Noel Kuntze
  only support weak crypto. Do not make concessions, unless necessary for 
16 1 Noel Kuntze
* XAUTH credentials are handled internally as EAP credentials. Both are valid for
17 1 Noel Kuntze
  XAUTH, EAP-GTC, EAP-MSCHAPv2 and whatever other cleartext or digest based
18 1 Noel Kuntze
  authentication might be implemented in the future.
19 1 Noel Kuntze
* The cipher settings are deliberately ordered by performance.
20 1 Noel Kuntze
  appears in front. That should make charon choose faster, but secure ones first.  
21 1 Noel Kuntze
* Do not use MD5, DES or 3DES. They are broken.
22 1 Noel Kuntze
* The algorithm your certificate uses and they algorithm the key exchange uses
23 1 Noel Kuntze
  do not have anything to do with each other.
24 1 Noel Kuntze
* strongSwan does not implement L2TP.
25 1 Noel Kuntze
* Read the documentation and use "the search function":https://wiki.strongswan.org/projects/strongswan/search.
26 1 Noel Kuntze
27 1 Noel Kuntze
h2. Roadwarrior scenario
28 1 Noel Kuntze
    
29 1 Noel Kuntze
This is an example configuration that provides support for several clients
30 1 Noel Kuntze
with several authentication styles.
31 1 Noel Kuntze
32 1 Noel Kuntze
{{collapse(ipsec.conf)
33 1 Noel Kuntze
<pre>
34 1 Noel Kuntze
conn rw-base
35 1 Noel Kuntze
    # enables IKE fragmentation 
36 1 Noel Kuntze
    fragmentation=yes
37 1 Noel Kuntze
    dpdaction=clear
38 1 Noel Kuntze
    # dpdtimeout is not honored for ikev2. For IKEv2, every message is used
39 1 Noel Kuntze
    # to determine the timeout, so the generic timeout value for IKEv2 messages
40 1 Noel Kuntze
    # is used. 
41 1 Noel Kuntze
    dpdtimeout=90s
42 1 Noel Kuntze
    dpddelay=30s
43 1 Noel Kuntze
44 1 Noel Kuntze
# this is used in every conn in which the client is assigned a "virtual" IP or
45 1 Noel Kuntze
# one or several DNS servers    
46 1 Noel Kuntze
# the cipher suits require the openssl plugin.
47 1 Noel Kuntze
conn rw-config
48 1 Noel Kuntze
    also=rw-base
49 1 Noel Kuntze
    rightsourceip=172.16.252.0/24
50 1 Noel Kuntze
    # set this to a local DNS server that the clients can reach with their assigned IPs.
51 1 Noel Kuntze
    # Think about routing.
52 1 Noel Kuntze
    rightdns=
53 1 Noel Kuntze
    leftsubnet=0.0.0.0/0
54 1 Noel Kuntze
    leftid=whatevertheclientusestoconnect
55 1 Noel Kuntze
    leftcert=mycertificate.pem
56 1 Noel Kuntze
    # not possible with asymmetric authentication
57 1 Noel Kuntze
    reauth=no
58 1 Noel Kuntze
    rekey=no
59 1 Noel Kuntze
    # sane cipher suits
60 1 Noel Kuntze
    ike=aes192gcm16-aes128gcm16-aes192-prfsha256-ecp256-ecp521,aes192-sha256-modp3072
61 1 Noel Kuntze
    esp=aes192gcm16-aes128gcm16-aes192-ecp256,aes192-sha256-modp3072#
62 1 Noel Kuntze
    leftsendcert=always
63 1 Noel Kuntze
    rightca="C=This, O=Is, OU=My, CN=CA"
64 1 Noel Kuntze
    
65 1 Noel Kuntze
# this conn is set up for l2tp support where the user authentication is happening
66 1 Noel Kuntze
# in the l2tp control connection. With L2TP, clients are usually not assigned
67 1 Noel Kuntze
# a virtual IP in IKE.
68 1 Noel Kuntze
# Charon is not an l2tp server. You need to install xl2tp for that and configure it correctly.
69 1 Noel Kuntze
# mark=%unique requires the connmark plugin.
70 1 Noel Kuntze
conn ikev1-l2tp-chap-auth-in-xl2tpd
71 1 Noel Kuntze
    also=rw-base
72 1 Noel Kuntze
    # reduce to the most secure combination the client can support, if absolutely required.
73 1 Noel Kuntze
    ike=aes128-sha1-modp3072
74 1 Noel Kuntze
    esp=aes128-sha1-modp3073
75 1 Noel Kuntze
    leftsubnet=%dynamic[/1701]
76 1 Noel Kuntze
    rightsubnet=%dynamic[/1701]
77 1 Noel Kuntze
    mark=%unique
78 1 Noel Kuntze
    leftauth=psk
79 1 Noel Kuntze
    rightauth=psk
80 1 Noel Kuntze
    type=transport
81 1 Noel Kuntze
    auto=add
82 1 Noel Kuntze
    
83 1 Noel Kuntze
# this conn is set up for l2tp support where the user authentication is happening
84 1 Noel Kuntze
# during the IKEv1 authentication. With L2TP, clients are usually not assigned
85 1 Noel Kuntze
# a virtual IP in IKE.
86 1 Noel Kuntze
# mark=%unique requires the connmark plugin.
87 1 Noel Kuntze
# this requires the xauth-generic plugin.
88 1 Noel Kuntze
conn ikev1-l2tp-xauth-in-ike
89 1 Noel Kuntze
    also=rw-base
90 1 Noel Kuntze
    # reduce to the most secure combination the client can support, if absolutely required.
91 1 Noel Kuntze
    ike=aes128-sha1-modp3072
92 1 Noel Kuntze
    esp=aes128-sha1-modp3073
93 1 Noel Kuntze
    leftsubnet=%dynamic[/1701]
94 1 Noel Kuntze
    rightsubnet=%dynamic[/1701]
95 1 Noel Kuntze
    mark=%unique
96 1 Noel Kuntze
    leftauth=psk
97 1 Noel Kuntze
    rightauth=psk
98 1 Noel Kuntze
    rightauth2=xauth-generic
99 1 Noel Kuntze
    # not possible with asymmetric authentication
100 1 Noel Kuntze
    reauth=no
101 1 Noel Kuntze
    rekey=no
102 1 Noel Kuntze
    type=transport
103 1 Noel Kuntze
    auto=add
104 1 Noel Kuntze
    
105 1 Noel Kuntze
# this requires the xauth-generic plugin.
106 1 Noel Kuntze
conn ikev1-psk-xauth
107 1 Noel Kuntze
    also=rw-config
108 1 Noel Kuntze
    leftauth=psk
109 1 Noel Kuntze
    rightauth=psk
110 1 Noel Kuntze
    rightauth2=xauth-generic
111 1 Noel Kuntze
    auto=add
112 1 Noel Kuntze
113 1 Noel Kuntze
# leftauth and rightauth default to "pubkey", so no change necessary.
114 1 Noel Kuntze
conn ikev1-pubkey
115 1 Noel Kuntze
    also=rw-config
116 1 Noel Kuntze
    auto=add
117 1 Noel Kuntze
118 1 Noel Kuntze
# this requires the xauth-generic plugin.
119 1 Noel Kuntze
conn ikev1-pubkey-xauth
120 1 Noel Kuntze
    also=rw-config
121 1 Noel Kuntze
    rightauth2=xauth-generic
122 1 Noel Kuntze
    auto=add
123 1 Noel Kuntze
124 1 Noel Kuntze
# this requires the xauth-generic plugin.
125 1 Noel Kuntze
conn ikev1-hybrid
126 1 Noel Kuntze
    also=rw-config
127 1 Noel Kuntze
    rightauth=xauth-generic
128 1 Noel Kuntze
129 1 Noel Kuntze
conn ikev2-pubkey
130 1 Noel Kuntze
    also=rw-config
131 1 Noel Kuntze
    auto=add
132 1 Noel Kuntze
133 1 Noel Kuntze
# this requires the eap-tls plugin.
134 1 Noel Kuntze
conn ikev2-eap-tls
135 1 Noel Kuntze
    also=rw-base
136 1 Noel Kuntze
    rightauth=eap-tls
137 1 Noel Kuntze
    eap_identity=%identity
138 1 Noel Kuntze
    auto=add
139 1 Noel Kuntze
140 1 Noel Kuntze
# this requires the eap-mschapv2 plugin.
141 1 Noel Kuntze
conn ikev2-eap-mschapv2
142 1 Noel Kuntze
    also=rw-config
143 1 Noel Kuntze
    rightauth=eap-mschapv2
144 1 Noel Kuntze
    eap_identity=%identity
145 1 Noel Kuntze
    auto=add
146 1 Noel Kuntze
</pre>
147 1 Noel Kuntze
}}
148 1 Noel Kuntze
149 1 Noel Kuntze
{{collapse(ipsec.secrets)
150 1 Noel Kuntze
<pre>
151 1 Noel Kuntze
: PSK "foobarblah"
152 1 Noel Kuntze
: RSA myprivatekey.pem
153 1 Noel Kuntze
carol : EAP "carolspassword"
154 1 Noel Kuntze
</pre>
155 1 Noel Kuntze
}}
156 1 Noel Kuntze
157 1 Noel Kuntze
h2. Site-To-Site-Scenario
158 1 Noel Kuntze
159 1 Noel Kuntze
{{collapse(ipsec.conf)
160 1 Noel Kuntze
<pre>
161 1 Noel Kuntze
conn sts-base
162 1 Noel Kuntze
    fragmentation=yes
163 1 Noel Kuntze
    dpdaction=restart
164 1 Noel Kuntze
    ike=aes192gcm16-aes128gcm16-aes192-prfsha256-ecp256-ecp521,aes192-sha256-modp3072
165 1 Noel Kuntze
    esp=aes192gcm16-aes128gcm16-aes192-ecp256,aes192-sha256-modp3072#
166 1 Noel Kuntze
    keyingtries=%forever
167 1 Noel Kuntze
    leftcert=foobar.pem
168 1 Noel Kuntze
169 1 Noel Kuntze
# this conn is set up for a host with a static IP
170 1 Noel Kuntze
conn site-1-static-ip
171 1 Noel Kuntze
    also=sts-base
172 1 Noel Kuntze
    keyexchange=ikev2
173 1 Noel Kuntze
    leftsubnet=10.1.2.0/24,10.1.1.0/24
174 1 Noel Kuntze
    rightsubnet=10.1.3.0/24
175 1 Noel Kuntze
    right=1.2.3.4
176 1 Noel Kuntze
    rightcert=1.2.3.4.pem
177 1 Noel Kuntze
    auto=route
178 1 Noel Kuntze
179 1 Noel Kuntze
# this conn is set up for a host with a dynamic IP
180 1 Noel Kuntze
conn site-2-dynamic-ip
181 1 Noel Kuntze
    also=sts-base
182 1 Noel Kuntze
    keyexchange=ikev2
183 1 Noel Kuntze
    leftsubnet=10.1.2.0/24,10.1.1.0/24
184 1 Noel Kuntze
    rightsubnet=10.1.4.0/24
185 1 Noel Kuntze
    # for this to work, DNS must be usable and working.
186 1 Noel Kuntze
    right=%example.com
187 1 Noel Kuntze
    rightcert=example.com.pem
188 1 Noel Kuntze
    auto=route
189 1 Noel Kuntze
190 1 Noel Kuntze
# this conn is set up for IKEv1 compatibility. It shows how to define several subnets
191 1 Noel Kuntze
# with IKEv1. site-3-legacy-1 and site-3-legacy-2 keep the data for the CHILD_SA.
192 1 Noel Kuntze
# The same can be accomplished with implicit merging by specifying the same IKE_SA
193 1 Noel Kuntze
# configuration in two different conns. This set up is cleaner, though.
194 1 Noel Kuntze
# If you put "auto=route" into the "site-3-legacy-base conn", charon will route the
195 1 Noel Kuntze
# conn with the ts being the local IP that is used to communicate with the remote
196 1 Noel Kuntze
# peer and the remote's peer. If such a CHILD_SA is not configured on the peer, ICMP
197 1 Noel Kuntze
# error messages from the remote peer to the local peer will not be able to be transmitted.
198 1 Noel Kuntze
# So don't do that, unless your remote peer is configured for that.
199 1 Noel Kuntze
# This is an IKEv1 connection with PSK authentication. That means, that you need to know
200 1 Noel Kuntze
# the other side's IP.
201 1 Noel Kuntze
conn site-3-legacy-base
202 1 Noel Kuntze
    also=sts-base
203 1 Noel Kuntze
    keyexchange=ikev1
204 1 Noel Kuntze
    # IKE and ESP cipher settings are reconfigured, because in IKEv1 every 
205 1 Noel Kuntze
    # single cipher suite needs to be enumerated.
206 1 Noel Kuntze
    # It is not possible to define all supported ciphers in one suite.
207 1 Noel Kuntze
    # select apropriate and strong ciphers for your scenario.
208 1 Noel Kuntze
    ike=aes192gcm16-prfsha256-ecp256,aes128gcm16-prfsha256-ecp256,aes128gcm16-prfsha256-ecp521,aes192-sha256-modp3072
209 1 Noel Kuntze
    esp=aes192gcm16-ecp256,aes192-sha256-modp3072
210 1 Noel Kuntze
    rightsubnet=10.1.5.0/24
211 1 Noel Kuntze
    # for this to work, DNS must be usable and working.
212 1 Noel Kuntze
    right=example.com
213 1 Noel Kuntze
    leftauth=psk
214 1 Noel Kuntze
    rightauth=psk
215 1 Noel Kuntze
216 1 Noel Kuntze
conn site-3-legacy-1
217 1 Noel Kuntze
    leftsubnet=10.1.1.0/24
218 1 Noel Kuntze
    also=site-3-legacy-base
219 1 Noel Kuntze
    auto=route
220 1 Noel Kuntze
221 1 Noel Kuntze
conn site-3-legacy-2
222 1 Noel Kuntze
    leftsubnet=10.1.2.0/24
223 1 Noel Kuntze
    also=site-3-legacy-base
224 1 Noel Kuntze
    auto=route
225 1 Noel Kuntze
</pre>
226 1 Noel Kuntze
}}
227 1 Noel Kuntze
228 1 Noel Kuntze
{{collapse(ipsec.secrets)
229 1 Noel Kuntze
<pre>
230 1 Noel Kuntze
: RSA foobar.key
231 1 Noel Kuntze
remote.com : EAP "example"
232 1 Noel Kuntze
</pre>
233 1 Noel Kuntze
}}