1
|
<?php
|
2
|
/*
|
3
|
vpn_ipsec_settings.php
|
4
|
|
5
|
Copyright (C) 2015 Electric Sheep Fencing, LLC
|
6
|
All rights reserved.
|
7
|
|
8
|
Redistribution and use in source and binary forms, with or without
|
9
|
modification, are permitted provided that the following conditions are met:
|
10
|
|
11
|
1. Redistributions of source code must retain the above copyright notice,
|
12
|
this list of conditions and the following disclaimer.
|
13
|
|
14
|
2. Redistributions in binary form must reproduce the above copyright
|
15
|
notice, this list of conditions and the following disclaimer in the
|
16
|
documentation and/or other materials provided with the distribution.
|
17
|
|
18
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
19
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
20
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
21
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
22
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
23
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
24
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
25
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
26
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27
|
POSSIBILITY OF SUCH DAMAGE.
|
28
|
*/
|
29
|
|
30
|
##|+PRIV
|
31
|
##|*IDENT=page-vpn-ipsec-settings
|
32
|
##|*NAME=VPN: IPsec: Settings page
|
33
|
##|*DESCR=Allow access to the 'VPN: IPsec: Settings' page.
|
34
|
##|*MATCH=vpn_ipsec_settings.php*
|
35
|
##|-PRIV
|
36
|
|
37
|
require("functions.inc");
|
38
|
require("guiconfig.inc");
|
39
|
require_once("filter.inc");
|
40
|
require_once("shaper.inc");
|
41
|
require_once("ipsec.inc");
|
42
|
require_once("vpn.inc");
|
43
|
|
44
|
foreach ($ipsec_loglevels as $lkey => $ldescr) {
|
45
|
if (!empty($config['ipsec']["ipsec_{$lkey}"])) {
|
46
|
$pconfig["ipsec_{$lkey}"] = $config['ipsec']["ipsec_{$lkey}"];
|
47
|
}
|
48
|
}
|
49
|
$pconfig['unityplugin'] = isset($config['ipsec']['unityplugin']);
|
50
|
$pconfig['strictcrlpolicy'] = isset($config['ipsec']['strictcrlpolicy']);
|
51
|
$pconfig['makebeforebreak'] = isset($config['ipsec']['makebeforebreak']);
|
52
|
$pconfig['noshuntlaninterfaces'] = isset($config['ipsec']['noshuntlaninterfaces']);
|
53
|
$pconfig['compression'] = isset($config['ipsec']['compression']);
|
54
|
$pconfig['enableinterfacesuse'] = isset($config['ipsec']['enableinterfacesuse']);
|
55
|
$pconfig['acceptunencryptedmainmode'] = isset($config['ipsec']['acceptunencryptedmainmode']);
|
56
|
$pconfig['maxmss_enable'] = isset($config['system']['maxmss_enable']);
|
57
|
$pconfig['maxmss'] = $config['system']['maxmss'];
|
58
|
$pconfig['uniqueids'] = $config['ipsec']['uniqueids'];
|
59
|
|
60
|
if ($_POST) {
|
61
|
|
62
|
unset($input_errors);
|
63
|
$pconfig = $_POST;
|
64
|
|
65
|
if (!in_array($pconfig['ipsec_dmn'], array('0', '1', '2', '3', '4', '5'), true)) {
|
66
|
$input_errors[] = "A valid value must be specified for Daemon debug.";
|
67
|
}
|
68
|
if (!in_array($pconfig['ipsec_mgr'], array('0', '1', '2', '3', '4', '5'), true)) {
|
69
|
$input_errors[] = "A valid value must be specified for SA Manager debug.";
|
70
|
}
|
71
|
if (!in_array($pconfig['ipsec_ike'], array('0', '1', '2', '3', '4', '5'), true)) {
|
72
|
$input_errors[] = "A valid value must be specified for IKE SA debug.";
|
73
|
}
|
74
|
if (!in_array($pconfig['ipsec_chd'], array('0', '1', '2', '3', '4', '5'), true)) {
|
75
|
$input_errors[] = "A valid value must be specified for IKE Child SA debug.";
|
76
|
}
|
77
|
if (!in_array($pconfig['ipsec_job'], array('0', '1', '2', '3', '4', '5'), true)) {
|
78
|
$input_errors[] = "A valid value must be specified for Job Processing debug.";
|
79
|
}
|
80
|
if (!in_array($pconfig['ipsec_cfg'], array('0', '1', '2', '3', '4', '5'), true)) {
|
81
|
$input_errors[] = "A valid value must be specified for Configuration backend debug.";
|
82
|
}
|
83
|
if (!in_array($pconfig['ipsec_knl'], array('0', '1', '2', '3', '4', '5'), true)) {
|
84
|
$input_errors[] = "A valid value must be specified for Kernel Interface debug.";
|
85
|
}
|
86
|
if (!in_array($pconfig['ipsec_net'], array('0', '1', '2', '3', '4', '5'), true)) {
|
87
|
$input_errors[] = "A valid value must be specified for Networking debug.";
|
88
|
}
|
89
|
if (!in_array($pconfig['ipsec_asn'], array('0', '1', '2', '3', '4', '5'), true)) {
|
90
|
$input_errors[] = "A valid value must be specified for ASN Encoding debug.";
|
91
|
}
|
92
|
if (!in_array($pconfig['ipsec_enc'], array('0', '1', '2', '3', '4', '5'), true)) {
|
93
|
$input_errors[] = "A valid value must be specified for Message encoding debug.";
|
94
|
}
|
95
|
if (!in_array($pconfig['ipsec_imc'], array('0', '1', '2', '3', '4', '5'), true)) {
|
96
|
$input_errors[] = "A valid value must be specified for Integrity checker debug.";
|
97
|
}
|
98
|
if (!in_array($pconfig['ipsec_imv'], array('0', '1', '2', '3', '4', '5'), true)) {
|
99
|
$input_errors[] = "A valid value must be specified for Integrity Verifier debug.";
|
100
|
}
|
101
|
if (!in_array($pconfig['ipsec_pts'], array('0', '1', '2', '3', '4', '5'), true)) {
|
102
|
$input_errors[] = "A valid value must be specified for Platform Trust Service debug.";
|
103
|
}
|
104
|
if (!in_array($pconfig['ipsec_tls'], array('0', '1', '2', '3', '4', '5'), true)) {
|
105
|
$input_errors[] = "A valid value must be specified for TLS Handler debug.";
|
106
|
}
|
107
|
if (!in_array($pconfig['ipsec_esp'], array('0', '1', '2', '3', '4', '5'), true)) {
|
108
|
$input_errors[] = "A valid value must be specified for IPsec Traffic debug.";
|
109
|
}
|
110
|
if (!in_array($pconfig['ipsec_lib'], array('0', '1', '2', '3', '4', '5'), true)) {
|
111
|
$input_errors[] = "A valid value must be specified for StrongSwan Lib debug.";
|
112
|
}
|
113
|
if (isset($pconfig['maxmss'])) {
|
114
|
if (!is_numericint($pconfig['maxmss']) && $pconfig['maxmss'] != '') {
|
115
|
$input_errors[] = "An integer must be specified for Maximum MSS.";
|
116
|
}
|
117
|
if ($pconfig['maxmss'] <> '' && $pconfig['maxmss'] < 576 || $pconfig['maxmss'] > 65535) {
|
118
|
$input_errors[] = "An integer between 576 and 65535 must be specified for Maximum MSS";
|
119
|
}
|
120
|
}
|
121
|
|
122
|
if (!$input_errors) {
|
123
|
|
124
|
foreach ($ipsec_loglevels as $lkey => $ldescr) {
|
125
|
if (empty($_POST["ipsec_{$lkey}"])) {
|
126
|
if (isset($config['ipsec']["ipsec_{$lkey}"])) {
|
127
|
unset($config['ipsec']["ipsec_{$lkey}"]);
|
128
|
}
|
129
|
} else {
|
130
|
$config['ipsec']["ipsec_{$lkey}"] = $_POST["ipsec_{$lkey}"];
|
131
|
}
|
132
|
}
|
133
|
|
134
|
$needsrestart = false;
|
135
|
|
136
|
if ($_POST['compression'] == "yes") {
|
137
|
if (!isset($config['ipsec']['compression'])) {
|
138
|
$needsrestart = true;
|
139
|
}
|
140
|
$config['ipsec']['compression'] = true;
|
141
|
} elseif (isset($config['ipsec']['compression'])) {
|
142
|
$needsrestart = true;
|
143
|
unset($config['ipsec']['compression']);
|
144
|
}
|
145
|
|
146
|
if ($_POST['enableinterfacesuse'] == "yes") {
|
147
|
if (!isset($config['ipsec']['enableinterfacesuse'])) {
|
148
|
$needsrestart = true;
|
149
|
}
|
150
|
$config['ipsec']['enableinterfacesuse'] = true;
|
151
|
} elseif (isset($config['ipsec']['enableinterfacesuse'])) {
|
152
|
$needsrestart = true;
|
153
|
unset($config['ipsec']['enableinterfacesuse']);
|
154
|
}
|
155
|
|
156
|
if ($_POST['unityplugin'] == "yes") {
|
157
|
if (!isset($config['ipsec']['unityplugin'])) {
|
158
|
$needsrestart = true;
|
159
|
}
|
160
|
$config['ipsec']['unityplugin'] = true;
|
161
|
} elseif (isset($config['ipsec']['unityplugin'])) {
|
162
|
$needsrestart = true;
|
163
|
unset($config['ipsec']['unityplugin']);
|
164
|
}
|
165
|
|
166
|
if ($_POST['strictcrlpolicy'] == "yes") {
|
167
|
$config['ipsec']['strictcrlpolicy'] = true;
|
168
|
} elseif (isset($config['ipsec']['strictcrlpolicy'])) {
|
169
|
unset($config['ipsec']['strictcrlpolicy']);
|
170
|
}
|
171
|
|
172
|
if ($_POST['makebeforebreak'] == "yes") {
|
173
|
$config['ipsec']['makebeforebreak'] = true;
|
174
|
} elseif (isset($config['ipsec']['makebeforebreak'])) {
|
175
|
unset($config['ipsec']['makebeforebreak']);
|
176
|
}
|
177
|
|
178
|
if ($_POST['noshuntlaninterfaces'] == "yes") {
|
179
|
if (isset($config['ipsec']['noshuntlaninterfaces'])) {
|
180
|
unset($config['ipsec']['noshuntlaninterfaces']);
|
181
|
}
|
182
|
} else {
|
183
|
$config['ipsec']['noshuntlaninterfaces'] = true;
|
184
|
}
|
185
|
|
186
|
if ($_POST['acceptunencryptedmainmode'] == "yes") {
|
187
|
if (!isset($config['ipsec']['acceptunencryptedmainmode'])) {
|
188
|
$needsrestart = true;
|
189
|
}
|
190
|
$config['ipsec']['acceptunencryptedmainmode'] = true;
|
191
|
} elseif (isset($config['ipsec']['acceptunencryptedmainmode'])) {
|
192
|
$needsrestart = true;
|
193
|
unset($config['ipsec']['acceptunencryptedmainmode']);
|
194
|
}
|
195
|
|
196
|
if (!empty($_POST['uniqueids'])) {
|
197
|
$config['ipsec']['uniqueids'] = $_POST['uniqueids'];
|
198
|
} else if (isset($config['ipsec']['uniqueids'])) {
|
199
|
unset($config['ipsec']['uniqueids']);
|
200
|
}
|
201
|
|
202
|
if ($_POST['maxmss_enable'] == "yes") {
|
203
|
$config['system']['maxmss_enable'] = true;
|
204
|
$config['system']['maxmss'] = $_POST['maxmss'];
|
205
|
} else {
|
206
|
if (isset($config['system']['maxmss_enable'])) {
|
207
|
unset($config['system']['maxmss_enable']);
|
208
|
}
|
209
|
if (isset($config['system']['maxmss'])) {
|
210
|
unset($config['system']['maxmss']);
|
211
|
}
|
212
|
}
|
213
|
|
214
|
write_config();
|
215
|
|
216
|
$retval = 0;
|
217
|
$retval = filter_configure();
|
218
|
if (stristr($retval, "error") <> true) {
|
219
|
$savemsg = get_std_save_message(gettext($retval));
|
220
|
} else {
|
221
|
$savemsg = gettext($retval);
|
222
|
}
|
223
|
|
224
|
vpn_ipsec_configure($needsrestart);
|
225
|
vpn_ipsec_configure_loglevels();
|
226
|
|
227
|
header("Location: vpn_ipsec_settings.php");
|
228
|
return;
|
229
|
}
|
230
|
|
231
|
// The logic value sent by $POST is opposite to the way it is stored in the config.
|
232
|
// Reset the $pconfig value so it reflects the opposite of what was $POSTed.
|
233
|
if ($_POST['noshuntlaninterfaces'] == "yes") {
|
234
|
$pconfig['noshuntlaninterfaces'] = false;
|
235
|
} else {
|
236
|
$pconfig['noshuntlaninterfaces'] = true;
|
237
|
}
|
238
|
}
|
239
|
|
240
|
$pgtitle = array(gettext("VPN"), gettext("IPsec"), gettext("Settings"));
|
241
|
$shortcut_section = "ipsec";
|
242
|
|
243
|
include("head.inc");
|
244
|
?>
|
245
|
|
246
|
<script type="text/javascript">
|
247
|
//<![CDATA[
|
248
|
|
249
|
function maxmss_checked(obj) {
|
250
|
if (obj.checked) {
|
251
|
jQuery('#maxmss').attr('disabled', false);
|
252
|
} else {
|
253
|
jQuery('#maxmss').attr('disabled', 'true');
|
254
|
}
|
255
|
}
|
256
|
|
257
|
//]]>
|
258
|
</script>
|
259
|
|
260
|
<?php
|
261
|
if ($savemsg) {
|
262
|
print_info_box($savemsg);
|
263
|
}
|
264
|
if ($input_errors) {
|
265
|
print_input_errors($input_errors);
|
266
|
}
|
267
|
?>
|
268
|
|
269
|
<?php
|
270
|
|
271
|
$tab_array = array();
|
272
|
$tab_array[0] = array(gettext("Tunnels"), false, "vpn_ipsec.php");
|
273
|
$tab_array[1] = array(gettext("Mobile clients"), false, "vpn_ipsec_mobile.php");
|
274
|
$tab_array[2] = array(gettext("Pre-Shared Key"), false, "vpn_ipsec_keys.php");
|
275
|
$tab_array[3] = array(gettext("Advanced Settings"), true, "vpn_ipsec_settings.php");
|
276
|
display_top_tabs($tab_array);
|
277
|
|
278
|
require('classes/Form.class.php');
|
279
|
$form = new Form;
|
280
|
|
281
|
$section = new Form_Section('Start IPsec in debug mode based on sections selected');
|
282
|
|
283
|
foreach ($ipsec_loglevels as $lkey => $ldescr)
|
284
|
{
|
285
|
$section->addInput(new Form_Select(
|
286
|
'ipsec_' . $lkey,
|
287
|
$ldescr,
|
288
|
$pconfig['ipsec_' . $lkey],
|
289
|
array('Silent', 'Audit', 'Control', 'Diag', 'Raw', 'Highest')
|
290
|
))->setWidth(2);
|
291
|
}
|
292
|
|
293
|
$section->addInput(new Form_StaticText('', ''))->setHelp(
|
294
|
'Launches IPsec in debug mode so that more verbose logs will be generated to aid in troubleshooting.'
|
295
|
);
|
296
|
|
297
|
$form->add($section);
|
298
|
|
299
|
$section = new Form_Section('IPsec Advanced Settings');
|
300
|
|
301
|
$section->addInput(new Form_Select(
|
302
|
'uniqueids',
|
303
|
'Configure Unique IDs as',
|
304
|
$pconfig['uniqueids'],
|
305
|
$ipsec_idhandling
|
306
|
))->setHelp(
|
307
|
'Whether a particular participant ID should be kept unique, with any new IKE_SA using an ID ' .
|
308
|
'deemed to replace all old ones using that ID. Participant IDs normally are unique, so a new ' .
|
309
|
'IKE_SA using the same ID is almost invariably intended to replace an old one. ' .
|
310
|
'The difference between <b>no</b> and <b>never</b> is that the old IKE_SAs will be replaced when receiving an ' .
|
311
|
'INITIAL_CONTACT notify if the option is no but will ignore these notifies if <b>never</b> is configured. ' .
|
312
|
'The daemon also accepts the value <b>keep</b> to reject ' .
|
313
|
'new IKE_SA setups and keep the duplicate established earlier. Defaults to Yes.'
|
314
|
);
|
315
|
|
316
|
$section->addInput(new Form_Checkbox(
|
317
|
'compression',
|
318
|
'IP Compression',
|
319
|
'Enable IPCompression',
|
320
|
$pconfig['compression']
|
321
|
))->setHelp('IPComp compression of content is proposed on the connection.');
|
322
|
|
323
|
$section->addInput(new Form_Checkbox(
|
324
|
'enableinterfacesuse',
|
325
|
'Strict interface binding',
|
326
|
'Enable strict interface binding',
|
327
|
$pconfig['enableinterfacesuse']
|
328
|
))->setHelp('Enable strongSwan\'s interfaces_use option to bind specific interfaces only. This option is known to break IPsec with dynamic IP interfaces. This is not recommended at this time.');
|
329
|
|
330
|
$section->addInput(new Form_Checkbox(
|
331
|
'acceptunencryptedmainmode',
|
332
|
'Unencrypted payloads in IKEv1 Main Mode',
|
333
|
'Accept unencrypted ID and HASH payloads in IKEv1 Main Mode',
|
334
|
$pconfig['acceptunencryptedmainmode']
|
335
|
))->setHelp(
|
336
|
'Some implementations send the third Main Mode message unencrypted, probably to find the PSKs for the specified ID for authentication.' .
|
337
|
'This is very similar to Aggressive Mode, and has the same security implications: ' .
|
338
|
'A passive attacker can sniff the negotiated Identity, and start brute forcing the PSK using the HASH payload.' .
|
339
|
'It is recommended to keep this option to no, unless you know exactly what the implications are and require compatibility to such devices (for example, some SonicWall boxes).'
|
340
|
);
|
341
|
|
342
|
$section->addInput(new Form_Checkbox(
|
343
|
'maxmss_enable',
|
344
|
'Enable Maximum MSS',
|
345
|
'Enable MSS clamping on VPN traffic',
|
346
|
$pconfig['maxmss_enable']
|
347
|
))->toggles('.toggle-maxmss', 'collapse');
|
348
|
|
349
|
$group = new Form_Group('Maximum MSS');
|
350
|
$group->addClass('toggle-maxmss collapse');
|
351
|
|
352
|
if (!empty($pconfig['maxmss_enable']))
|
353
|
$group->addClass('in');
|
354
|
|
355
|
$group->add(new Form_Input(
|
356
|
'maxmss',
|
357
|
'Maximum MSS',
|
358
|
'text',
|
359
|
($pconfig['maxmss'] ? $pconfig['maxmss'] : '1400')
|
360
|
))->setHelp(
|
361
|
'Enable MSS clamping on TCP flows over VPN. ' .
|
362
|
'This helps overcome problems with PMTUD on IPsec VPN links. If left blank, the default value is 1400 bytes. '
|
363
|
);
|
364
|
|
365
|
$section->add($group);
|
366
|
|
367
|
$section->addInput(new Form_Checkbox(
|
368
|
'unityplugin',
|
369
|
'Disable Cisco Extensions',
|
370
|
'Disable Unity Plugin',
|
371
|
$pconfig['unityplugin']
|
372
|
))->setHelp('Disable Unity Plugin which provides Cisco Extension support as Split-Include, Split-Exclude, Split-Dns, ...');
|
373
|
|
374
|
$section->addInput(new Form_Checkbox(
|
375
|
'shuntlaninterfaces',
|
376
|
'Bypass LAN address',
|
377
|
'Enable bypass for LAN interface ip',
|
378
|
$pconfig['shuntlaninterfaces']
|
379
|
))->setHelp('Prevent LAN ip address to be processed for IPsec traffic.');
|
380
|
|
381
|
$form->add($section);
|
382
|
|
383
|
print $form;
|
384
|
|
385
|
?>
|
386
|
|
387
|
<?php include("foot.inc"); ?>
|