Project

General

Profile

Download (10.3 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 8f585441 Luiz Souza
 * Copyright (c) 2014-2021 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 76d6d925 Stephen Beaver
	$a_hasync['pfsyncpeerip'] = $pconfig['pfsyncpeerip'];
65 f97a5b04 Darren Embry
	$a_hasync['pfsyncinterface'] = $pconfig['pfsyncinterface'];
66
	$a_hasync['synchronizetoip'] = $pconfig['synchronizetoip'];
67 76d6d925 Stephen Beaver
	$a_hasync['username'] = $pconfig['username'];
68 c8b10b4c Stephen Beaver
69
	if ($pconfig['passwordfld'] == $pconfig['passwordfld_confirm']) {
70 76d6d925 Stephen Beaver
		if ($pconfig['passwordfld'] != DMYPWD) {
71
				$a_hasync['password'] = $pconfig['passwordfld'];
72
		}
73 c8b10b4c Stephen Beaver
	} else {
74
		$input_errors[] = gettext("Password and confirmation must match.");
75
	}
76
77 1c3a5b0b Viktor G
	if (!empty($pconfig['pfsyncpeerip']) && !is_ipaddrv4($pconfig['pfsyncpeerip'])) {
78
		$input_errors[] = gettext("pfsync Synchronize Peer IP must be an IPv4 IP.");
79
	}
80
81
	if (!empty($pconfig['synchronizetoip']) && !is_ipaddr($pconfig['synchronizetoip'])) {
82 bf9d8809 Viktor G
		$input_errors[] = gettext("Synchronize Config to IP must be a valid IP address.");
83 0eb688c5 Chris Buechler
	}
84
85 c8b10b4c Stephen Beaver
	if (!$input_errors) {
86
		write_config("Updated High Availability Sync configuration");
87
		interfaces_sync_setup();
88
		header("Location: system_hasync.php");
89
		exit();
90
	}
91 f97a5b04 Darren Embry
}
92
93
foreach ($checkbox_names as $name) {
94
	$pconfig[$name] = $a_hasync[$name];
95
}
96 cb7b3761 sbeaver
$pconfig['pfsyncpeerip']	= $a_hasync['pfsyncpeerip'];
97 f97a5b04 Darren Embry
$pconfig['pfsyncinterface'] = $a_hasync['pfsyncinterface'];
98
$pconfig['synchronizetoip'] = $a_hasync['synchronizetoip'];
99 cb7b3761 sbeaver
$pconfig['username']		= $a_hasync['username'];
100
$pconfig['passwordfld']	 = $a_hasync['password'];
101 f97a5b04 Darren Embry
102
$ifaces = get_configured_interface_with_descr();
103
$ifaces["lo0"] = "loopback";
104
105 d38bd840 Phil Davis
$pgtitle = array(gettext("System"), gettext("High Availability Sync"));
106 345ce722 jim-p
$shortcut_section = "carp";
107 cb7b3761 sbeaver
108
// Build a list of available interfaces
109
$iflist = array();
110
foreach ($ifaces as $ifname => $iface) {
111
	$iflist[$ifname] = $iface;
112
}
113
114 f97a5b04 Darren Embry
include("head.inc");
115 cb7b3761 sbeaver
116 c8b10b4c Stephen Beaver
if ($input_errors) {
117
	print_input_errors($input_errors);
118
}
119
120 38e06c66 Sjon Hortensius
$form = new Form;
121 cb7b3761 sbeaver
122
$section = new Form_Section('State Synchronization Settings (pfsync)');
123
124
$section->addInput(new Form_Checkbox(
125
	'pfsyncenabled',
126
	'Synchronize states',
127
	'pfsync transfers state insertion, update, and deletion messages between firewalls.',
128
	($pconfig['pfsyncenabled'] === 'on'),
129
	'on'
130
))->setHelp('Each firewall sends these messages out via multicast on a specified interface, using the PFSYNC protocol (IP Protocol 240).' .
131 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' .
132
			'This setting should be enabled on all members of a failover group.%1$s' .
133
			'Clicking "Save" will force a configuration sync if it is enabled! (see Configuration Synchronization Settings below)', '<br />');
134 cb7b3761 sbeaver
135
$section->addInput(new Form_Select(
136
	'pfsyncinterface',
137 11482216 Luiz Otavio O Souza
	'Synchronize Interface',
138 cb7b3761 sbeaver
	$pconfig['pfsyncinterface'],
139
	$iflist
140 781d9ce4 Phil Davis
))->setHelp('If Synchronize States is enabled this interface will be used for communication.%1$s' .
141
			'It is recommended to set this to an interface other than LAN! A dedicated interface works the best.%1$s' .
142
			'An IP must be defined on each machine participating in this failover group.%1$s' .
143
			'An IP must be assigned to the interface on any participating sync nodes.', '<br />');
144 cb7b3761 sbeaver
145
$section->addInput(new Form_Input(
146
	'pfsyncpeerip',
147
	'pfsync Synchronize Peer IP',
148
	'text',
149
	$pconfig['pfsyncpeerip'],
150
	['placeholder' => 'IP Address']
151 e14a94af doktornotor
))->setHelp('Setting this option will force pfsync to synchronize its state table to this IP address. The default is directed multicast.');
152 cb7b3761 sbeaver
153
$form->add($section);
154
155
$section = new Form_Section('Configuration Synchronization Settings (XMLRPC Sync)');
156
157
$section->addInput(new Form_Input(
158
	'synchronizetoip',
159
	'Synchronize Config to IP',
160
	'text',
161
	$pconfig['synchronizetoip'],
162
	['placeholder' => 'IP Address']
163 781d9ce4 Phil Davis
))->setHelp('Enter the IP address of the firewall to which the selected configuration sections should be synchronized.%1$s%1$s' .
164
			'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' .
165
			'Do not use the Synchronize Config to IP and password option on backup cluster members!', '<br />');
166 cb7b3761 sbeaver
167
$section->addInput(new Form_Input(
168
	'username',
169
	'Remote System Username',
170
	'text',
171 659a8a26 jim-p
	$pconfig['username'],
172
	['autocomplete' => 'new-password']
173 781d9ce4 Phil Davis
))->setHelp('Enter the webConfigurator username of the system entered above for synchronizing the configuration.%1$s' .
174
			'Do not use the Synchronize Config to IP and username option on backup cluster members!', '<br />');
175 cb7b3761 sbeaver
176 c8b10b4c Stephen Beaver
$section->addPassword(new Form_Input(
177 cb7b3761 sbeaver
	'passwordfld',
178
	'Remote System Password',
179
	'password',
180
	$pconfig['passwordfld']
181 781d9ce4 Phil Davis
))->setHelp('Enter the webConfigurator password of the system entered above for synchronizing the configuration.%1$s' .
182
			'Do not use the Synchronize Config to IP and password option on backup cluster members!', '<br />');
183 cb7b3761 sbeaver
184 f9ed5d57 James Webb
$section->addInput(new Form_Checkbox(
185
	'adminsync',
186
	'Synchronize admin',
187
	'synchronize admin accounts and autoupdate sync password.',
188
	($pconfig['adminsync'] === 'on'),
189
	'on'
190
))->setHelp('By default, the admin account does not synchronize, and each node may have a different admin password.%1$s' .
191
			'This option automatically updates XMLRPC Remote System Password when the password is changed on 
192
			the Remote System Username account.', '<br />');
193
194 52d7947c Sjon Hortensius
$group = new Form_MultiCheckboxGroup('Select options to sync');
195
196
$group->add(new Form_MultiCheckbox(
197 cb7b3761 sbeaver
	'synchronizeusers',
198
	'Synchronize Users and Groups',
199 3599c525 Chris Buechler
	'User manager users and groups',
200 cb7b3761 sbeaver
	($pconfig['synchronizeusers'] === 'on'),
201
	'on'
202
));
203
204 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
205 cb7b3761 sbeaver
	'synchronizeauthservers',
206
	'Synchronize Auth Servers',
207 3599c525 Chris Buechler
	'Authentication servers (e.g. LDAP, RADIUS)',
208 cb7b3761 sbeaver
	($pconfig['synchronizeauthservers'] === 'on'),
209
	'on'
210
));
211
212 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
213 cb7b3761 sbeaver
	'synchronizecerts',
214
	'Synchronize Certificates',
215 3599c525 Chris Buechler
	'Certificate Authorities, Certificates, and Certificate Revocation Lists',
216 cb7b3761 sbeaver
	($pconfig['synchronizecerts'] === 'on'),
217
	'on'
218
));
219
220 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
221 cb7b3761 sbeaver
	'synchronizerules',
222
	'Synchronize Rules',
223 3599c525 Chris Buechler
	'Firewall rules ',
224 cb7b3761 sbeaver
	($pconfig['synchronizerules'] === 'on'),
225
	'on'
226
));
227
228 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
229 cb7b3761 sbeaver
	'synchronizeschedules',
230
	'Synchronize Firewall schedules',
231 3599c525 Chris Buechler
	'Firewall schedules ',
232 cb7b3761 sbeaver
	($pconfig['synchronizeschedules'] === 'on'),
233
	'on'
234
));
235
236 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
237 cb7b3761 sbeaver
	'synchronizealiases',
238 3599c525 Chris Buechler
	'Synchronize Firewall aliases',
239
	'Firewall aliases ',
240
	($pconfig['synchronizealiases'] === 'on'),
241 cb7b3761 sbeaver
	'on'
242
));
243
244 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
245 cb7b3761 sbeaver
	'synchronizenat',
246
	'Synchronize NAT',
247 3599c525 Chris Buechler
	'NAT configuration ',
248 cb7b3761 sbeaver
	($pconfig['synchronizenat'] === 'on'),
249
	'on'
250
));
251
252 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
253 cb7b3761 sbeaver
	'synchronizeipsec',
254
	'Synchronize IPsec',
255 3599c525 Chris Buechler
	'IPsec configuration ',
256 cb7b3761 sbeaver
	($pconfig['synchronizeipsec'] === 'on'),
257
	'on'
258
));
259
260 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
261 cb7b3761 sbeaver
	'synchronizeopenvpn',
262
	'Synchronize OpenVPN',
263 9f3b87d8 jim-p
	'OpenVPN configuration (Implies CA/Cert/CRL Sync) ',
264 cb7b3761 sbeaver
	($pconfig['synchronizeopenvpn'] === 'on'),
265
	'on'
266
));
267
268 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
269 cb7b3761 sbeaver
	'synchronizedhcpd',
270
	'Synchronize DHCPD',
271 3599c525 Chris Buechler
	'DHCP Server settings ',
272 cb7b3761 sbeaver
	($pconfig['synchronizedhcpd'] === 'on'),
273
	'on'
274
));
275
276 30169caa Viktor G
$group->add(new Form_MultiCheckbox(
277
	'synchronizedhcrelay',
278
	'Synchronize DHCP Relay',
279
	'DHCP Relay settings ',
280
	($pconfig['synchronizedhcrelay'] === 'on'),
281
	'on'
282
));
283
284
$group->add(new Form_MultiCheckbox(
285
	'synchronizedhcrelay6',
286
	'Synchronize DHCPv6 Relay',
287
	'DHCPv6 Relay settings',
288
	($pconfig['synchronizedhcrelay6'] === 'on'),
289
	'on'
290
));
291
292 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
293 cb7b3761 sbeaver
	'synchronizewol',
294 7ca42d47 k-paulius
	'Synchronize Wake-on-LAN',
295 3599c525 Chris Buechler
	'WoL Server settings ',
296 cb7b3761 sbeaver
	($pconfig['synchronizewol'] === 'on'),
297
	'on'
298
));
299
300 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
301 cb7b3761 sbeaver
	'synchronizestaticroutes',
302
	'Synchronize Static Routes',
303 3599c525 Chris Buechler
	'Static Route configuration ',
304 cb7b3761 sbeaver
	($pconfig['synchronizestaticroutes'] === 'on'),
305
	'on'
306
));
307
308 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
309 cb7b3761 sbeaver
	'synchronizevirtualip',
310
	'Synchronize Virtual IPs',
311 3599c525 Chris Buechler
	'Virtual IPs ',
312 cb7b3761 sbeaver
	($pconfig['synchronizevirtualip'] === 'on'),
313
	'on'
314
));
315
316 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
317 cb7b3761 sbeaver
	'synchronizetrafficshaper',
318
	'Synchronize traffic shaper (queues)',
319 3599c525 Chris Buechler
	'Traffic Shaper configuration ',
320 cb7b3761 sbeaver
	($pconfig['synchronizetrafficshaper'] === 'on'),
321
	'on'
322
));
323
324 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
325 cb7b3761 sbeaver
	'synchronizetrafficshaperlimiter',
326
	'Synchronize traffic shaper (limiter)',
327 3599c525 Chris Buechler
	'Traffic Shaper Limiters configuration ',
328 cb7b3761 sbeaver
	($pconfig['synchronizetrafficshaperlimiter'] === 'on'),
329
	'on'
330
));
331
332 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
333 cb7b3761 sbeaver
	'synchronizednsforwarder',
334 8e41aa41 Phil Davis
	'Synchronize DNS (Forwarder/Resolver)',
335 3599c525 Chris Buechler
	'DNS Forwarder and DNS Resolver configurations ',
336 cb7b3761 sbeaver
	($pconfig['synchronizednsforwarder'] === 'on'),
337
	'on'
338
));
339
340 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
341 cb7b3761 sbeaver
	'synchronizecaptiveportal',
342
	'Synchronize Captive Portal)',
343 3599c525 Chris Buechler
	'Captive Portal ',
344 cb7b3761 sbeaver
	($pconfig['synchronizecaptiveportal'] === 'on'),
345
	'on'
346
));
347
348 52d7947c Sjon Hortensius
$section->add($group);
349
350 cb7b3761 sbeaver
$form->add($section);
351
352
print($form);
353
354 e14a94af doktornotor
include("foot.inc");