1
|
<?php
|
2
|
/*
|
3
|
* system_hasync.php
|
4
|
*
|
5
|
* part of pfSense (https://www.pfsense.org)
|
6
|
* Copyright (c) 2004-2013 BSD Perimeter
|
7
|
* Copyright (c) 2013-2016 Electric Sheep Fencing
|
8
|
* Copyright (c) 2014-2023 Rubicon Communications, LLC (Netgate)
|
9
|
* All rights reserved.
|
10
|
*
|
11
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
12
|
* you may not use this file except in compliance with the License.
|
13
|
* You may obtain a copy of the License at
|
14
|
*
|
15
|
* http://www.apache.org/licenses/LICENSE-2.0
|
16
|
*
|
17
|
* Unless required by applicable law or agreed to in writing, software
|
18
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
19
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
20
|
* See the License for the specific language governing permissions and
|
21
|
* limitations under the License.
|
22
|
*/
|
23
|
|
24
|
##|+PRIV
|
25
|
##|*IDENT=page-system-hasync
|
26
|
##|*NAME=System: High Availability Sync
|
27
|
##|*DESCR=Allow access to the 'System: High Availability Sync' page.
|
28
|
##|*MATCH=system_hasync.php*
|
29
|
##|-PRIV
|
30
|
|
31
|
require_once("guiconfig.inc");
|
32
|
|
33
|
init_config_arr(array('hasync'));
|
34
|
$a_hasync = &$config['hasync'];
|
35
|
|
36
|
$checkbox_names = array(
|
37
|
'pfsyncenabled',
|
38
|
'adminsync',
|
39
|
'synchronizeusers',
|
40
|
'synchronizeauthservers',
|
41
|
'synchronizecerts',
|
42
|
'synchronizerules',
|
43
|
'synchronizeschedules',
|
44
|
'synchronizealiases',
|
45
|
'synchronizenat',
|
46
|
'synchronizeipsec',
|
47
|
'synchronizeopenvpn',
|
48
|
'synchronizedhcpd',
|
49
|
'synchronizedhcrelay',
|
50
|
'synchronizedhcrelay6',
|
51
|
'synchronizewol',
|
52
|
'synchronizestaticroutes',
|
53
|
'synchronizevirtualip',
|
54
|
'synchronizetrafficshaper',
|
55
|
'synchronizetrafficshaperlimiter',
|
56
|
'synchronizednsforwarder',
|
57
|
'synchronizecaptiveportal');
|
58
|
|
59
|
if ($_POST) {
|
60
|
$pconfig = $_POST;
|
61
|
foreach ($checkbox_names as $name) {
|
62
|
$a_hasync[$name] = $pconfig[$name] ? $pconfig[$name] : false;
|
63
|
}
|
64
|
$old_pfhostid = isset($a_hasync['pfhostid']) ? $a_hasync['pfhostid'] : '';
|
65
|
$a_hasync['pfhostid'] = strtolower(trim($pconfig['pfhostid']));
|
66
|
$a_hasync['pfsyncpeerip'] = $pconfig['pfsyncpeerip'];
|
67
|
$a_hasync['pfsyncinterface'] = $pconfig['pfsyncinterface'];
|
68
|
$a_hasync['synchronizetoip'] = $pconfig['synchronizetoip'];
|
69
|
$a_hasync['username'] = $pconfig['username'];
|
70
|
|
71
|
if ($pconfig['passwordfld'] == $pconfig['passwordfld_confirm']) {
|
72
|
if ($pconfig['passwordfld'] != DMYPWD) {
|
73
|
$a_hasync['password'] = $pconfig['passwordfld'];
|
74
|
}
|
75
|
} else {
|
76
|
$input_errors[] = gettext("Password and confirmation must match.");
|
77
|
}
|
78
|
|
79
|
if ((!empty($pconfig['pfhostid']) &&
|
80
|
!(ctype_xdigit($pconfig['pfhostid']) &&
|
81
|
(strlen($pconfig['pfhostid']) <= 8))) ||
|
82
|
($pconfig['pfhostid'] === "0")) {
|
83
|
$input_errors[] = gettext("Invalid Host ID. Must be a non-zero hexadecimal string 8 characters or less.");
|
84
|
}
|
85
|
|
86
|
if (!empty($pconfig['pfsyncpeerip']) && !is_ipaddrv4($pconfig['pfsyncpeerip'])) {
|
87
|
$input_errors[] = gettext("pfsync Synchronize Peer IP must be an IPv4 IP.");
|
88
|
}
|
89
|
|
90
|
if (!empty($pconfig['synchronizetoip']) && !is_ipaddr($pconfig['synchronizetoip'])) {
|
91
|
$input_errors[] = gettext("Synchronize Config to IP must be a valid IP address.");
|
92
|
}
|
93
|
|
94
|
if (!$input_errors) {
|
95
|
write_config("Updated High Availability Sync configuration");
|
96
|
interfaces_sync_setup();
|
97
|
if ($old_pfhostid != $a_hasync['pfhostid']) {
|
98
|
filter_configure();
|
99
|
}
|
100
|
header("Location: system_hasync.php");
|
101
|
exit();
|
102
|
}
|
103
|
}
|
104
|
|
105
|
foreach ($checkbox_names as $name) {
|
106
|
$pconfig[$name] = $a_hasync[$name];
|
107
|
}
|
108
|
$pconfig['pfhostid'] = $a_hasync['pfhostid'];
|
109
|
$pconfig['pfsyncpeerip'] = $a_hasync['pfsyncpeerip'];
|
110
|
$pconfig['pfsyncinterface'] = $a_hasync['pfsyncinterface'];
|
111
|
$pconfig['synchronizetoip'] = $a_hasync['synchronizetoip'];
|
112
|
$pconfig['username'] = $a_hasync['username'];
|
113
|
$pconfig['passwordfld'] = $a_hasync['password'];
|
114
|
|
115
|
$ifaces = get_configured_interface_with_descr();
|
116
|
$ifaces["lo0"] = "loopback";
|
117
|
|
118
|
$pgtitle = array(gettext('System'), gettext('High Availability'));
|
119
|
$shortcut_section = 'carp';
|
120
|
|
121
|
// Build a list of available interfaces
|
122
|
$iflist = array();
|
123
|
foreach ($ifaces as $ifname => $iface) {
|
124
|
$iflist[$ifname] = $iface;
|
125
|
}
|
126
|
|
127
|
include("head.inc");
|
128
|
|
129
|
if ($input_errors) {
|
130
|
print_input_errors($input_errors);
|
131
|
}
|
132
|
|
133
|
$form = new Form;
|
134
|
|
135
|
$section = new Form_Section('State Synchronization Settings (pfsync)');
|
136
|
|
137
|
$section->addInput(new Form_Checkbox(
|
138
|
'pfsyncenabled',
|
139
|
'Synchronize states',
|
140
|
'pfsync transfers state insertion, update, and deletion messages between firewalls.',
|
141
|
($pconfig['pfsyncenabled'] === 'on'),
|
142
|
'on'
|
143
|
))->setHelp('Each firewall sends these messages out via multicast on a specified interface, using the PFSYNC protocol (IP Protocol 240).' .
|
144
|
' It also listens on that interface for similar messages from other firewalls, and imports them into the local state table.%1$s' .
|
145
|
'This setting should be enabled on all members of a failover group.%1$s' .
|
146
|
'Clicking "Save" will force a configuration sync if it is enabled! (see Configuration Synchronization Settings below)', '<br />');
|
147
|
|
148
|
$section->addInput(new Form_Select(
|
149
|
'pfsyncinterface',
|
150
|
'Synchronize Interface',
|
151
|
$pconfig['pfsyncinterface'],
|
152
|
$iflist
|
153
|
))->setHelp('If Synchronize States is enabled this interface will be used for communication.%1$s' .
|
154
|
'It is recommended to set this to an interface other than LAN! A dedicated interface works the best.%1$s' .
|
155
|
'An IP must be defined on each machine participating in this failover group.%1$s' .
|
156
|
'An IP must be assigned to the interface on any participating sync nodes.', '<br />');
|
157
|
|
158
|
$section->addInput(new Form_Input(
|
159
|
'pfhostid',
|
160
|
'Filter Host ID',
|
161
|
'text',
|
162
|
$pconfig['pfhostid'],
|
163
|
['placeholder' => substr(system_get_uniqueid(), -8)]
|
164
|
))->setHelp('Custom pf host identifier carried in state data to uniquely identify which host created a firewall state.%1$s' .
|
165
|
'Must be a non-zero hexadecimal string 8 characters or less (e.g. 1, 2, ff01, abcdef01).%1$s' .
|
166
|
'Each node participating in state synchronization must have a different ID.', '<br />');
|
167
|
|
168
|
$section->addInput(new Form_Input(
|
169
|
'pfsyncpeerip',
|
170
|
'pfsync Synchronize Peer IP',
|
171
|
'text',
|
172
|
$pconfig['pfsyncpeerip'],
|
173
|
['placeholder' => 'IP Address']
|
174
|
))->setHelp('Setting this option will force pfsync to synchronize its state table to this IP address. The default is directed multicast.');
|
175
|
|
176
|
$form->add($section);
|
177
|
|
178
|
$section = new Form_Section('Configuration Synchronization Settings (XMLRPC Sync)');
|
179
|
|
180
|
$section->addInput(new Form_Input(
|
181
|
'synchronizetoip',
|
182
|
'Synchronize Config to IP',
|
183
|
'text',
|
184
|
$pconfig['synchronizetoip'],
|
185
|
['placeholder' => 'IP Address']
|
186
|
))->setHelp('Enter the IP address of the firewall to which the selected configuration sections should be synchronized.%1$s%1$s' .
|
187
|
'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!%1$s' .
|
188
|
'Do not use the Synchronize Config to IP and password option on backup cluster members!', '<br />');
|
189
|
|
190
|
$section->addInput(new Form_Input(
|
191
|
'username',
|
192
|
'Remote System Username',
|
193
|
'text',
|
194
|
$pconfig['username'],
|
195
|
['autocomplete' => 'new-password']
|
196
|
))->setHelp('Enter the webConfigurator username of the system entered above for synchronizing the configuration.%1$s' .
|
197
|
'Do not use the Synchronize Config to IP and username option on backup cluster members!', '<br />');
|
198
|
|
199
|
$section->addPassword(new Form_Input(
|
200
|
'passwordfld',
|
201
|
'Remote System Password',
|
202
|
'password',
|
203
|
$pconfig['passwordfld']
|
204
|
))->setHelp('Enter the webConfigurator password of the system entered above for synchronizing the configuration.%1$s' .
|
205
|
'Do not use the Synchronize Config to IP and password option on backup cluster members!', '<br />');
|
206
|
|
207
|
$section->addInput(new Form_Checkbox(
|
208
|
'adminsync',
|
209
|
'Synchronize admin',
|
210
|
'synchronize admin accounts and autoupdate sync password.',
|
211
|
($pconfig['adminsync'] === 'on'),
|
212
|
'on'
|
213
|
))->setHelp('By default, the admin account does not synchronize, and each node may have a different admin password.%1$s' .
|
214
|
'This option automatically updates XMLRPC Remote System Password when the password is changed on
|
215
|
the Remote System Username account.', '<br />');
|
216
|
|
217
|
$group = new Form_MultiCheckboxGroup('Select options to sync');
|
218
|
|
219
|
$group->add(new Form_MultiCheckbox(
|
220
|
'synchronizeusers',
|
221
|
'Synchronize Users and Groups',
|
222
|
'User manager users and groups',
|
223
|
($pconfig['synchronizeusers'] === 'on'),
|
224
|
'on'
|
225
|
));
|
226
|
|
227
|
$group->add(new Form_MultiCheckbox(
|
228
|
'synchronizeauthservers',
|
229
|
'Synchronize Auth Servers',
|
230
|
'Authentication servers (e.g. LDAP, RADIUS)',
|
231
|
($pconfig['synchronizeauthservers'] === 'on'),
|
232
|
'on'
|
233
|
));
|
234
|
|
235
|
$group->add(new Form_MultiCheckbox(
|
236
|
'synchronizecerts',
|
237
|
'Synchronize Certificates',
|
238
|
'Certificate Authorities, Certificates, and Certificate Revocation Lists',
|
239
|
($pconfig['synchronizecerts'] === 'on'),
|
240
|
'on'
|
241
|
));
|
242
|
|
243
|
$group->add(new Form_MultiCheckbox(
|
244
|
'synchronizerules',
|
245
|
'Synchronize Rules',
|
246
|
'Firewall rules ',
|
247
|
($pconfig['synchronizerules'] === 'on'),
|
248
|
'on'
|
249
|
));
|
250
|
|
251
|
$group->add(new Form_MultiCheckbox(
|
252
|
'synchronizeschedules',
|
253
|
'Synchronize Firewall schedules',
|
254
|
'Firewall schedules ',
|
255
|
($pconfig['synchronizeschedules'] === 'on'),
|
256
|
'on'
|
257
|
));
|
258
|
|
259
|
$group->add(new Form_MultiCheckbox(
|
260
|
'synchronizealiases',
|
261
|
'Synchronize Firewall aliases',
|
262
|
'Firewall aliases ',
|
263
|
($pconfig['synchronizealiases'] === 'on'),
|
264
|
'on'
|
265
|
));
|
266
|
|
267
|
$group->add(new Form_MultiCheckbox(
|
268
|
'synchronizenat',
|
269
|
'Synchronize NAT',
|
270
|
'NAT configuration ',
|
271
|
($pconfig['synchronizenat'] === 'on'),
|
272
|
'on'
|
273
|
));
|
274
|
|
275
|
$group->add(new Form_MultiCheckbox(
|
276
|
'synchronizeipsec',
|
277
|
'Synchronize IPsec',
|
278
|
'IPsec configuration ',
|
279
|
($pconfig['synchronizeipsec'] === 'on'),
|
280
|
'on'
|
281
|
));
|
282
|
|
283
|
$group->add(new Form_MultiCheckbox(
|
284
|
'synchronizeopenvpn',
|
285
|
'Synchronize OpenVPN',
|
286
|
'OpenVPN configuration (Implies CA/Cert/CRL Sync) ',
|
287
|
($pconfig['synchronizeopenvpn'] === 'on'),
|
288
|
'on'
|
289
|
));
|
290
|
|
291
|
$group->add(new Form_MultiCheckbox(
|
292
|
'synchronizedhcpd',
|
293
|
'Synchronize DHCPD',
|
294
|
'DHCP Server settings ',
|
295
|
($pconfig['synchronizedhcpd'] === 'on'),
|
296
|
'on'
|
297
|
));
|
298
|
|
299
|
$group->add(new Form_MultiCheckbox(
|
300
|
'synchronizedhcrelay',
|
301
|
'Synchronize DHCP Relay',
|
302
|
'DHCP Relay settings ',
|
303
|
($pconfig['synchronizedhcrelay'] === 'on'),
|
304
|
'on'
|
305
|
));
|
306
|
|
307
|
$group->add(new Form_MultiCheckbox(
|
308
|
'synchronizedhcrelay6',
|
309
|
'Synchronize DHCPv6 Relay',
|
310
|
'DHCPv6 Relay settings',
|
311
|
($pconfig['synchronizedhcrelay6'] === 'on'),
|
312
|
'on'
|
313
|
));
|
314
|
|
315
|
$group->add(new Form_MultiCheckbox(
|
316
|
'synchronizewol',
|
317
|
'Synchronize Wake-on-LAN',
|
318
|
'WoL Server settings ',
|
319
|
($pconfig['synchronizewol'] === 'on'),
|
320
|
'on'
|
321
|
));
|
322
|
|
323
|
$group->add(new Form_MultiCheckbox(
|
324
|
'synchronizestaticroutes',
|
325
|
'Synchronize Static Routes',
|
326
|
'Static Route configuration ',
|
327
|
($pconfig['synchronizestaticroutes'] === 'on'),
|
328
|
'on'
|
329
|
));
|
330
|
|
331
|
$group->add(new Form_MultiCheckbox(
|
332
|
'synchronizevirtualip',
|
333
|
'Synchronize Virtual IPs',
|
334
|
'Virtual IPs ',
|
335
|
($pconfig['synchronizevirtualip'] === 'on'),
|
336
|
'on'
|
337
|
));
|
338
|
|
339
|
$group->add(new Form_MultiCheckbox(
|
340
|
'synchronizetrafficshaper',
|
341
|
'Synchronize traffic shaper (queues)',
|
342
|
'Traffic Shaper configuration ',
|
343
|
($pconfig['synchronizetrafficshaper'] === 'on'),
|
344
|
'on'
|
345
|
));
|
346
|
|
347
|
$group->add(new Form_MultiCheckbox(
|
348
|
'synchronizetrafficshaperlimiter',
|
349
|
'Synchronize traffic shaper (limiter)',
|
350
|
'Traffic Shaper Limiters configuration ',
|
351
|
($pconfig['synchronizetrafficshaperlimiter'] === 'on'),
|
352
|
'on'
|
353
|
));
|
354
|
|
355
|
$group->add(new Form_MultiCheckbox(
|
356
|
'synchronizednsforwarder',
|
357
|
'Synchronize DNS (Forwarder/Resolver)',
|
358
|
'DNS Forwarder and DNS Resolver configurations ',
|
359
|
($pconfig['synchronizednsforwarder'] === 'on'),
|
360
|
'on'
|
361
|
));
|
362
|
|
363
|
$group->add(new Form_MultiCheckbox(
|
364
|
'synchronizecaptiveportal',
|
365
|
'Synchronize Captive Portal)',
|
366
|
'Captive Portal ',
|
367
|
($pconfig['synchronizecaptiveportal'] === 'on'),
|
368
|
'on'
|
369
|
));
|
370
|
|
371
|
$section->add($group);
|
372
|
|
373
|
$form->add($section);
|
374
|
|
375
|
print($form);
|
376
|
|
377
|
include("foot.inc");
|