1
|
<?php
|
2
|
/*
|
3
|
* system_hasync.php
|
4
|
*
|
5
|
* part of pfSense (https://www.pfsense.org)
|
6
|
* Copyright (c) 2004-2016 Electric Sheep Fencing, LLC
|
7
|
* All rights reserved.
|
8
|
*
|
9
|
* Redistribution and use in source and binary forms, with or without
|
10
|
* modification, are permitted provided that the following conditions are met:
|
11
|
*
|
12
|
* 1. Redistributions of source code must retain the above copyright notice,
|
13
|
* this list of conditions and the following disclaimer.
|
14
|
*
|
15
|
* 2. Redistributions in binary form must reproduce the above copyright
|
16
|
* notice, this list of conditions and the following disclaimer in
|
17
|
* the documentation and/or other materials provided with the
|
18
|
* distribution.
|
19
|
*
|
20
|
* 3. All advertising materials mentioning features or use of this software
|
21
|
* must display the following acknowledgment:
|
22
|
* "This product includes software developed by the pfSense Project
|
23
|
* for use in the pfSense® software distribution. (http://www.pfsense.org/).
|
24
|
*
|
25
|
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
26
|
* endorse or promote products derived from this software without
|
27
|
* prior written permission. For written permission, please contact
|
28
|
* coreteam@pfsense.org.
|
29
|
*
|
30
|
* 5. Products derived from this software may not be called "pfSense"
|
31
|
* nor may "pfSense" appear in their names without prior written
|
32
|
* permission of the Electric Sheep Fencing, LLC.
|
33
|
*
|
34
|
* 6. Redistributions of any form whatsoever must retain the following
|
35
|
* acknowledgment:
|
36
|
*
|
37
|
* "This product includes software developed by the pfSense Project
|
38
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
39
|
*
|
40
|
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
41
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
42
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
43
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
44
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
45
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
46
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
47
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
48
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
49
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
50
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
51
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
52
|
*/
|
53
|
|
54
|
##|+PRIV
|
55
|
##|*IDENT=page-system-hasync
|
56
|
##|*NAME=System: High Availability Sync
|
57
|
##|*DESCR=Allow access to the 'System: High Availability Sync' page.
|
58
|
##|*MATCH=system_hasync.php*
|
59
|
##|-PRIV
|
60
|
|
61
|
require_once("guiconfig.inc");
|
62
|
|
63
|
if (!is_array($config['hasync'])) {
|
64
|
$config['hasync'] = array();
|
65
|
}
|
66
|
|
67
|
$a_hasync = &$config['hasync'];
|
68
|
|
69
|
$checkbox_names = array(
|
70
|
'pfsyncenabled',
|
71
|
'synchronizeusers',
|
72
|
'synchronizeauthservers',
|
73
|
'synchronizecerts',
|
74
|
'synchronizerules',
|
75
|
'synchronizeschedules',
|
76
|
'synchronizealiases',
|
77
|
'synchronizenat',
|
78
|
'synchronizeipsec',
|
79
|
'synchronizeopenvpn',
|
80
|
'synchronizedhcpd',
|
81
|
'synchronizewol',
|
82
|
'synchronizestaticroutes',
|
83
|
'synchronizelb',
|
84
|
'synchronizevirtualip',
|
85
|
'synchronizetrafficshaper',
|
86
|
'synchronizetrafficshaperlimiter',
|
87
|
'synchronizednsforwarder',
|
88
|
'synchronizecaptiveportal');
|
89
|
|
90
|
if ($_POST) {
|
91
|
$pconfig = $_POST;
|
92
|
foreach ($checkbox_names as $name) {
|
93
|
$a_hasync[$name] = $pconfig[$name] ? $pconfig[$name] : false;
|
94
|
}
|
95
|
$a_hasync['pfsyncpeerip'] = $pconfig['pfsyncpeerip'];
|
96
|
$a_hasync['pfsyncinterface'] = $pconfig['pfsyncinterface'];
|
97
|
$a_hasync['synchronizetoip'] = $pconfig['synchronizetoip'];
|
98
|
$a_hasync['username'] = $pconfig['username'];
|
99
|
|
100
|
if ($pconfig['passwordfld'] == $pconfig['passwordfld_confirm']) {
|
101
|
if ($pconfig['passwordfld'] != DMYPWD) {
|
102
|
$a_hasync['password'] = $pconfig['passwordfld'];
|
103
|
}
|
104
|
} else {
|
105
|
$input_errors[] = gettext("Password and confirmation must match.");
|
106
|
}
|
107
|
|
108
|
if ($pconfig['pfsyncpeerip'] != "") {
|
109
|
if (!is_ipaddrv4($pconfig['pfsyncpeerip'])) {
|
110
|
$input_errors[] = gettext("pfsync Synchronize Peer IP must be an IPv4 IP.");
|
111
|
}
|
112
|
}
|
113
|
|
114
|
if (!$input_errors) {
|
115
|
write_config("Updated High Availability Sync configuration");
|
116
|
interfaces_sync_setup();
|
117
|
header("Location: system_hasync.php");
|
118
|
exit();
|
119
|
}
|
120
|
}
|
121
|
|
122
|
foreach ($checkbox_names as $name) {
|
123
|
$pconfig[$name] = $a_hasync[$name];
|
124
|
}
|
125
|
$pconfig['pfsyncpeerip'] = $a_hasync['pfsyncpeerip'];
|
126
|
$pconfig['pfsyncinterface'] = $a_hasync['pfsyncinterface'];
|
127
|
$pconfig['synchronizetoip'] = $a_hasync['synchronizetoip'];
|
128
|
$pconfig['username'] = $a_hasync['username'];
|
129
|
$pconfig['passwordfld'] = $a_hasync['password'];
|
130
|
|
131
|
$ifaces = get_configured_interface_with_descr();
|
132
|
$ifaces["lo0"] = "loopback";
|
133
|
|
134
|
$pgtitle = array(gettext("System"), gettext("High Availability Sync"));
|
135
|
$shortcut_section = "carp";
|
136
|
|
137
|
// Build a list of available interfaces
|
138
|
$iflist = array();
|
139
|
foreach ($ifaces as $ifname => $iface) {
|
140
|
$iflist[$ifname] = $iface;
|
141
|
}
|
142
|
|
143
|
include("head.inc");
|
144
|
|
145
|
if ($input_errors) {
|
146
|
print_input_errors($input_errors);
|
147
|
}
|
148
|
|
149
|
$form = new Form;
|
150
|
|
151
|
$section = new Form_Section('State Synchronization Settings (pfsync)');
|
152
|
|
153
|
$section->addInput(new Form_Checkbox(
|
154
|
'pfsyncenabled',
|
155
|
'Synchronize states',
|
156
|
'pfsync transfers state insertion, update, and deletion messages between firewalls.',
|
157
|
($pconfig['pfsyncenabled'] === 'on'),
|
158
|
'on'
|
159
|
))->setHelp('Each firewall sends these messages out via multicast on a specified interface, using the PFSYNC protocol (IP Protocol 240).' .
|
160
|
' It also listens on that interface for similar messages from other firewalls, and imports them into the local state table.<br />' .
|
161
|
'This setting should be enabled on all members of a failover group.<br />' .
|
162
|
'Clicking "Save" will force a configuration sync if it is enabled! (see Configuration Synchronization Settings below)');
|
163
|
|
164
|
$section->addInput(new Form_Select(
|
165
|
'pfsyncinterface',
|
166
|
'Synchronize Interface',
|
167
|
$pconfig['pfsyncinterface'],
|
168
|
$iflist
|
169
|
))->setHelp('If Synchronize States is enabled this interface will be used for communication.<br />' .
|
170
|
'It is recommended to set this to an interface other than LAN! A dedicated interface works the best.<br />' .
|
171
|
'An IP must be defined on each machine participating in this failover group.<br />' .
|
172
|
'An IP must be assigned to the interface on any participating sync nodes.');
|
173
|
|
174
|
$section->addInput(new Form_Input(
|
175
|
'pfsyncpeerip',
|
176
|
'pfsync Synchronize Peer IP',
|
177
|
'text',
|
178
|
$pconfig['pfsyncpeerip'],
|
179
|
['placeholder' => 'IP Address']
|
180
|
))->setHelp('Setting this option will force pfsync to synchronize its state table to this IP address. The default is directed multicast.');
|
181
|
|
182
|
$form->add($section);
|
183
|
|
184
|
$section = new Form_Section('Configuration Synchronization Settings (XMLRPC Sync)');
|
185
|
|
186
|
$section->addInput(new Form_Input(
|
187
|
'synchronizetoip',
|
188
|
'Synchronize Config to IP',
|
189
|
'text',
|
190
|
$pconfig['synchronizetoip'],
|
191
|
['placeholder' => 'IP Address']
|
192
|
))->setHelp('Enter the IP address of the firewall to which the selected configuration sections should be synchronized.<br /><br />' .
|
193
|
'XMLRPC sync is currently only supported over connections using the same protocol and port as this system - make sure the remote system\'s port and protocol are set accordingly!<br />' .
|
194
|
'Do not use the Synchronize Config to IP and password option on backup cluster members!');
|
195
|
|
196
|
$section->addInput(new Form_Input(
|
197
|
'username',
|
198
|
'Remote System Username',
|
199
|
'text',
|
200
|
$pconfig['username']
|
201
|
))->setHelp('Enter the webConfigurator username of the system entered above for synchronizing the configuration.<br />' .
|
202
|
'Do not use the Synchronize Config to IP and username option on backup cluster members!');
|
203
|
|
204
|
$section->addPassword(new Form_Input(
|
205
|
'passwordfld',
|
206
|
'Remote System Password',
|
207
|
'password',
|
208
|
$pconfig['passwordfld']
|
209
|
))->setHelp('Enter the webConfigurator password of the system entered above for synchronizing the configuration.<br />' .
|
210
|
'Do not use the Synchronize Config to IP and password option on backup cluster members!');
|
211
|
|
212
|
$group = new Form_MultiCheckboxGroup('Select options to sync');
|
213
|
|
214
|
$group->add(new Form_MultiCheckbox(
|
215
|
'synchronizeusers',
|
216
|
'Synchronize Users and Groups',
|
217
|
'User manager users and groups',
|
218
|
($pconfig['synchronizeusers'] === 'on'),
|
219
|
'on'
|
220
|
));
|
221
|
|
222
|
$group->add(new Form_MultiCheckbox(
|
223
|
'synchronizeauthservers',
|
224
|
'Synchronize Auth Servers',
|
225
|
'Authentication servers (e.g. LDAP, RADIUS)',
|
226
|
($pconfig['synchronizeauthservers'] === 'on'),
|
227
|
'on'
|
228
|
));
|
229
|
|
230
|
$group->add(new Form_MultiCheckbox(
|
231
|
'synchronizecerts',
|
232
|
'Synchronize Certificates',
|
233
|
'Certificate Authorities, Certificates, and Certificate Revocation Lists',
|
234
|
($pconfig['synchronizecerts'] === 'on'),
|
235
|
'on'
|
236
|
));
|
237
|
|
238
|
$group->add(new Form_MultiCheckbox(
|
239
|
'synchronizerules',
|
240
|
'Synchronize Rules',
|
241
|
'Firewall rules ',
|
242
|
($pconfig['synchronizerules'] === 'on'),
|
243
|
'on'
|
244
|
));
|
245
|
|
246
|
$group->add(new Form_MultiCheckbox(
|
247
|
'synchronizeschedules',
|
248
|
'Synchronize Firewall schedules',
|
249
|
'Firewall schedules ',
|
250
|
($pconfig['synchronizeschedules'] === 'on'),
|
251
|
'on'
|
252
|
));
|
253
|
|
254
|
$group->add(new Form_MultiCheckbox(
|
255
|
'synchronizealiases',
|
256
|
'Synchronize Firewall aliases',
|
257
|
'Firewall aliases ',
|
258
|
($pconfig['synchronizealiases'] === 'on'),
|
259
|
'on'
|
260
|
));
|
261
|
|
262
|
$group->add(new Form_MultiCheckbox(
|
263
|
'synchronizenat',
|
264
|
'Synchronize NAT',
|
265
|
'NAT configuration ',
|
266
|
($pconfig['synchronizenat'] === 'on'),
|
267
|
'on'
|
268
|
));
|
269
|
|
270
|
$group->add(new Form_MultiCheckbox(
|
271
|
'synchronizeipsec',
|
272
|
'Synchronize IPsec',
|
273
|
'IPsec configuration ',
|
274
|
($pconfig['synchronizeipsec'] === 'on'),
|
275
|
'on'
|
276
|
));
|
277
|
|
278
|
$group->add(new Form_MultiCheckbox(
|
279
|
'synchronizeopenvpn',
|
280
|
'Synchronize OpenVPN',
|
281
|
'OpenVPN configuration ',
|
282
|
($pconfig['synchronizeopenvpn'] === 'on'),
|
283
|
'on'
|
284
|
));
|
285
|
|
286
|
$group->add(new Form_MultiCheckbox(
|
287
|
'synchronizedhcpd',
|
288
|
'Synchronize DHCPD',
|
289
|
'DHCP Server settings ',
|
290
|
($pconfig['synchronizedhcpd'] === 'on'),
|
291
|
'on'
|
292
|
));
|
293
|
|
294
|
$group->add(new Form_MultiCheckbox(
|
295
|
'synchronizewol',
|
296
|
'Synchronize Wake-on-LAN',
|
297
|
'WoL Server settings ',
|
298
|
($pconfig['synchronizewol'] === 'on'),
|
299
|
'on'
|
300
|
));
|
301
|
|
302
|
$group->add(new Form_MultiCheckbox(
|
303
|
'synchronizestaticroutes',
|
304
|
'Synchronize Static Routes',
|
305
|
'Static Route configuration ',
|
306
|
($pconfig['synchronizestaticroutes'] === 'on'),
|
307
|
'on'
|
308
|
));
|
309
|
|
310
|
$group->add(new Form_MultiCheckbox(
|
311
|
'synchronizelb',
|
312
|
'Synchronize Load Balancer',
|
313
|
'Load Balancer configuration ',
|
314
|
($pconfig['synchronizelb'] === 'on'),
|
315
|
'on'
|
316
|
));
|
317
|
|
318
|
$group->add(new Form_MultiCheckbox(
|
319
|
'synchronizevirtualip',
|
320
|
'Synchronize Virtual IPs',
|
321
|
'Virtual IPs ',
|
322
|
($pconfig['synchronizevirtualip'] === 'on'),
|
323
|
'on'
|
324
|
));
|
325
|
|
326
|
$group->add(new Form_MultiCheckbox(
|
327
|
'synchronizetrafficshaper',
|
328
|
'Synchronize traffic shaper (queues)',
|
329
|
'Traffic Shaper configuration ',
|
330
|
($pconfig['synchronizetrafficshaper'] === 'on'),
|
331
|
'on'
|
332
|
));
|
333
|
|
334
|
$group->add(new Form_MultiCheckbox(
|
335
|
'synchronizetrafficshaperlimiter',
|
336
|
'Synchronize traffic shaper (limiter)',
|
337
|
'Traffic Shaper Limiters configuration ',
|
338
|
($pconfig['synchronizetrafficshaperlimiter'] === 'on'),
|
339
|
'on'
|
340
|
));
|
341
|
|
342
|
$group->add(new Form_MultiCheckbox(
|
343
|
'synchronizednsforwarder',
|
344
|
'Synchronize DNS (Forwarder/Resolver)',
|
345
|
'DNS Forwarder and DNS Resolver configurations ',
|
346
|
($pconfig['synchronizednsforwarder'] === 'on'),
|
347
|
'on'
|
348
|
));
|
349
|
|
350
|
$group->add(new Form_MultiCheckbox(
|
351
|
'synchronizecaptiveportal',
|
352
|
'Synchronize Captive Portal)',
|
353
|
'Captive Portal ',
|
354
|
($pconfig['synchronizecaptiveportal'] === 'on'),
|
355
|
'on'
|
356
|
));
|
357
|
|
358
|
$section->add($group);
|
359
|
|
360
|
$form->add($section);
|
361
|
|
362
|
print($form);
|
363
|
|
364
|
include("foot.inc");
|