Project

General

Profile

Download (11.2 KB) Statistics
| Branch: | Tag: | Revision:
1 f97a5b04 Darren Embry
<?php
2
/*
3 c5d81585 Renato Botelho
 * system_hasync.php
4 b9043cdc Stephen Beaver
 *
5 c5d81585 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6 38809d47 Renato Botelho do Couto
 * Copyright (c) 2004-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8 a68f7a3d Luiz Otavio O Souza
 * Copyright (c) 2014-2024 Rubicon Communications, LLC (Netgate)
9 c5d81585 Renato Botelho
 * All rights reserved.
10 b9043cdc Stephen Beaver
 *
11 b12ea3fb Renato Botelho
 * 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 b9043cdc Stephen Beaver
 *
15 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
16 b9043cdc Stephen Beaver
 *
17 b12ea3fb Renato Botelho
 * 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 b9043cdc Stephen Beaver
 */
23 f97a5b04 Darren Embry
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 c81ef6e2 Phil Davis
require_once("guiconfig.inc");
32 f97a5b04 Darren Embry
33 c6c398c6 jim-p
init_config_arr(array('hasync'));
34 f97a5b04 Darren Embry
$a_hasync = &$config['hasync'];
35
36 d38bd840 Phil Davis
$checkbox_names = array(
37
	'pfsyncenabled',
38 f9ed5d57 James Webb
	'adminsync',
39 d38bd840 Phil Davis
	'synchronizeusers',
40
	'synchronizeauthservers',
41
	'synchronizecerts',
42
	'synchronizerules',
43
	'synchronizeschedules',
44
	'synchronizealiases',
45
	'synchronizenat',
46
	'synchronizeipsec',
47
	'synchronizeopenvpn',
48
	'synchronizedhcpd',
49 30169caa Viktor G
	'synchronizedhcrelay',
50
	'synchronizedhcrelay6',
51 d38bd840 Phil Davis
	'synchronizewol',
52
	'synchronizestaticroutes',
53
	'synchronizevirtualip',
54
	'synchronizetrafficshaper',
55
	'synchronizetrafficshaperlimiter',
56
	'synchronizednsforwarder',
57
	'synchronizecaptiveportal');
58 f97a5b04 Darren Embry
59
if ($_POST) {
60
	$pconfig = $_POST;
61
	foreach ($checkbox_names as $name) {
62
		$a_hasync[$name] = $pconfig[$name] ? $pconfig[$name] : false;
63
	}
64 062972b3 Jim Pingle
	$old_pfhostid = isset($a_hasync['pfhostid']) ? $a_hasync['pfhostid'] : '';
65
	$a_hasync['pfhostid'] = strtolower(trim($pconfig['pfhostid']));
66 76d6d925 Stephen Beaver
	$a_hasync['pfsyncpeerip'] = $pconfig['pfsyncpeerip'];
67 f97a5b04 Darren Embry
	$a_hasync['pfsyncinterface'] = $pconfig['pfsyncinterface'];
68
	$a_hasync['synchronizetoip'] = $pconfig['synchronizetoip'];
69 76d6d925 Stephen Beaver
	$a_hasync['username'] = $pconfig['username'];
70 c8b10b4c Stephen Beaver
71
	if ($pconfig['passwordfld'] == $pconfig['passwordfld_confirm']) {
72 76d6d925 Stephen Beaver
		if ($pconfig['passwordfld'] != DMYPWD) {
73
				$a_hasync['password'] = $pconfig['passwordfld'];
74
		}
75 c8b10b4c Stephen Beaver
	} else {
76
		$input_errors[] = gettext("Password and confirmation must match.");
77
	}
78
79 062972b3 Jim Pingle
	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 1c3a5b0b Viktor G
	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 bf9d8809 Viktor G
		$input_errors[] = gettext("Synchronize Config to IP must be a valid IP address.");
92 0eb688c5 Chris Buechler
	}
93
94 c8b10b4c Stephen Beaver
	if (!$input_errors) {
95
		write_config("Updated High Availability Sync configuration");
96
		interfaces_sync_setup();
97 062972b3 Jim Pingle
		if ($old_pfhostid != $a_hasync['pfhostid']) {
98
			filter_configure();
99
		}
100 c8b10b4c Stephen Beaver
		header("Location: system_hasync.php");
101
		exit();
102
	}
103 f97a5b04 Darren Embry
}
104
105
foreach ($checkbox_names as $name) {
106
	$pconfig[$name] = $a_hasync[$name];
107
}
108 062972b3 Jim Pingle
$pconfig['pfhostid']	= $a_hasync['pfhostid'];
109 cb7b3761 sbeaver
$pconfig['pfsyncpeerip']	= $a_hasync['pfsyncpeerip'];
110 f97a5b04 Darren Embry
$pconfig['pfsyncinterface'] = $a_hasync['pfsyncinterface'];
111
$pconfig['synchronizetoip'] = $a_hasync['synchronizetoip'];
112 cb7b3761 sbeaver
$pconfig['username']		= $a_hasync['username'];
113
$pconfig['passwordfld']	 = $a_hasync['password'];
114 f97a5b04 Darren Embry
115
$ifaces = get_configured_interface_with_descr();
116
$ifaces["lo0"] = "loopback";
117
118 c8014348 Christian McDonald
$pgtitle = array(gettext('System'), gettext('High Availability'));
119
$shortcut_section = 'carp';
120 cb7b3761 sbeaver
121
// Build a list of available interfaces
122
$iflist = array();
123
foreach ($ifaces as $ifname => $iface) {
124
	$iflist[$ifname] = $iface;
125
}
126
127 f97a5b04 Darren Embry
include("head.inc");
128 cb7b3761 sbeaver
129 c8b10b4c Stephen Beaver
if ($input_errors) {
130
	print_input_errors($input_errors);
131
}
132
133 38e06c66 Sjon Hortensius
$form = new Form;
134 cb7b3761 sbeaver
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 781d9ce4 Phil Davis
			' 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 cb7b3761 sbeaver
148
$section->addInput(new Form_Select(
149
	'pfsyncinterface',
150 11482216 Luiz Otavio O Souza
	'Synchronize Interface',
151 cb7b3761 sbeaver
	$pconfig['pfsyncinterface'],
152
	$iflist
153 781d9ce4 Phil Davis
))->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 cb7b3761 sbeaver
158 062972b3 Jim Pingle
$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 cb7b3761 sbeaver
$section->addInput(new Form_Input(
169
	'pfsyncpeerip',
170
	'pfsync Synchronize Peer IP',
171
	'text',
172
	$pconfig['pfsyncpeerip'],
173
	['placeholder' => 'IP Address']
174 e14a94af doktornotor
))->setHelp('Setting this option will force pfsync to synchronize its state table to this IP address. The default is directed multicast.');
175 cb7b3761 sbeaver
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 781d9ce4 Phil Davis
))->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 cb7b3761 sbeaver
190
$section->addInput(new Form_Input(
191
	'username',
192
	'Remote System Username',
193
	'text',
194 659a8a26 jim-p
	$pconfig['username'],
195
	['autocomplete' => 'new-password']
196 781d9ce4 Phil Davis
))->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 cb7b3761 sbeaver
199 c8b10b4c Stephen Beaver
$section->addPassword(new Form_Input(
200 cb7b3761 sbeaver
	'passwordfld',
201
	'Remote System Password',
202
	'password',
203
	$pconfig['passwordfld']
204 781d9ce4 Phil Davis
))->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 cb7b3761 sbeaver
207 f9ed5d57 James Webb
$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 c8014348 Christian McDonald
			'This option automatically updates XMLRPC Remote System Password when the password is changed on
215 f9ed5d57 James Webb
			the Remote System Username account.', '<br />');
216
217 52d7947c Sjon Hortensius
$group = new Form_MultiCheckboxGroup('Select options to sync');
218
219
$group->add(new Form_MultiCheckbox(
220 cb7b3761 sbeaver
	'synchronizeusers',
221
	'Synchronize Users and Groups',
222 3599c525 Chris Buechler
	'User manager users and groups',
223 cb7b3761 sbeaver
	($pconfig['synchronizeusers'] === 'on'),
224
	'on'
225
));
226
227 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
228 cb7b3761 sbeaver
	'synchronizeauthservers',
229
	'Synchronize Auth Servers',
230 3599c525 Chris Buechler
	'Authentication servers (e.g. LDAP, RADIUS)',
231 cb7b3761 sbeaver
	($pconfig['synchronizeauthservers'] === 'on'),
232
	'on'
233
));
234
235 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
236 cb7b3761 sbeaver
	'synchronizecerts',
237
	'Synchronize Certificates',
238 3599c525 Chris Buechler
	'Certificate Authorities, Certificates, and Certificate Revocation Lists',
239 cb7b3761 sbeaver
	($pconfig['synchronizecerts'] === 'on'),
240
	'on'
241
));
242
243 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
244 cb7b3761 sbeaver
	'synchronizerules',
245
	'Synchronize Rules',
246 3599c525 Chris Buechler
	'Firewall rules ',
247 cb7b3761 sbeaver
	($pconfig['synchronizerules'] === 'on'),
248
	'on'
249
));
250
251 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
252 cb7b3761 sbeaver
	'synchronizeschedules',
253
	'Synchronize Firewall schedules',
254 3599c525 Chris Buechler
	'Firewall schedules ',
255 cb7b3761 sbeaver
	($pconfig['synchronizeschedules'] === 'on'),
256
	'on'
257
));
258
259 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
260 cb7b3761 sbeaver
	'synchronizealiases',
261 3599c525 Chris Buechler
	'Synchronize Firewall aliases',
262
	'Firewall aliases ',
263
	($pconfig['synchronizealiases'] === 'on'),
264 cb7b3761 sbeaver
	'on'
265
));
266
267 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
268 cb7b3761 sbeaver
	'synchronizenat',
269
	'Synchronize NAT',
270 3599c525 Chris Buechler
	'NAT configuration ',
271 cb7b3761 sbeaver
	($pconfig['synchronizenat'] === 'on'),
272
	'on'
273
));
274
275 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
276 cb7b3761 sbeaver
	'synchronizeipsec',
277
	'Synchronize IPsec',
278 3599c525 Chris Buechler
	'IPsec configuration ',
279 cb7b3761 sbeaver
	($pconfig['synchronizeipsec'] === 'on'),
280
	'on'
281
));
282
283 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
284 cb7b3761 sbeaver
	'synchronizeopenvpn',
285
	'Synchronize OpenVPN',
286 9f3b87d8 jim-p
	'OpenVPN configuration (Implies CA/Cert/CRL Sync) ',
287 cb7b3761 sbeaver
	($pconfig['synchronizeopenvpn'] === 'on'),
288
	'on'
289
));
290
291 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
292 cb7b3761 sbeaver
	'synchronizedhcpd',
293
	'Synchronize DHCPD',
294 3599c525 Chris Buechler
	'DHCP Server settings ',
295 cb7b3761 sbeaver
	($pconfig['synchronizedhcpd'] === 'on'),
296
	'on'
297
));
298
299 30169caa Viktor G
$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 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
316 cb7b3761 sbeaver
	'synchronizewol',
317 7ca42d47 k-paulius
	'Synchronize Wake-on-LAN',
318 3599c525 Chris Buechler
	'WoL Server settings ',
319 cb7b3761 sbeaver
	($pconfig['synchronizewol'] === 'on'),
320
	'on'
321
));
322
323 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
324 cb7b3761 sbeaver
	'synchronizestaticroutes',
325
	'Synchronize Static Routes',
326 3599c525 Chris Buechler
	'Static Route configuration ',
327 cb7b3761 sbeaver
	($pconfig['synchronizestaticroutes'] === 'on'),
328
	'on'
329
));
330
331 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
332 cb7b3761 sbeaver
	'synchronizevirtualip',
333
	'Synchronize Virtual IPs',
334 3599c525 Chris Buechler
	'Virtual IPs ',
335 cb7b3761 sbeaver
	($pconfig['synchronizevirtualip'] === 'on'),
336
	'on'
337
));
338
339 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
340 cb7b3761 sbeaver
	'synchronizetrafficshaper',
341
	'Synchronize traffic shaper (queues)',
342 3599c525 Chris Buechler
	'Traffic Shaper configuration ',
343 cb7b3761 sbeaver
	($pconfig['synchronizetrafficshaper'] === 'on'),
344
	'on'
345
));
346
347 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
348 cb7b3761 sbeaver
	'synchronizetrafficshaperlimiter',
349
	'Synchronize traffic shaper (limiter)',
350 3599c525 Chris Buechler
	'Traffic Shaper Limiters configuration ',
351 cb7b3761 sbeaver
	($pconfig['synchronizetrafficshaperlimiter'] === 'on'),
352
	'on'
353
));
354
355 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
356 cb7b3761 sbeaver
	'synchronizednsforwarder',
357 8e41aa41 Phil Davis
	'Synchronize DNS (Forwarder/Resolver)',
358 3599c525 Chris Buechler
	'DNS Forwarder and DNS Resolver configurations ',
359 cb7b3761 sbeaver
	($pconfig['synchronizednsforwarder'] === 'on'),
360
	'on'
361
));
362
363 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
364 cb7b3761 sbeaver
	'synchronizecaptiveportal',
365
	'Synchronize Captive Portal)',
366 3599c525 Chris Buechler
	'Captive Portal ',
367 cb7b3761 sbeaver
	($pconfig['synchronizecaptiveportal'] === 'on'),
368
	'on'
369
));
370
371 52d7947c Sjon Hortensius
$section->add($group);
372
373 cb7b3761 sbeaver
$form->add($section);
374
375
print($form);
376
377 e14a94af doktornotor
include("foot.inc");