system_hasync.php 15.9 KB
Newer Older
Ad Schellevis's avatar
Ad Schellevis committed
1
<?php
2

Ad Schellevis's avatar
Ad Schellevis committed
3
/*
4
	Copyright (C) 2014-2015 Deciso B.V.
Ad Schellevis's avatar
Ad Schellevis committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
	Copyright (C) 2012 Darren Embry <dse@webonastick.com>.
	All rights reserved.

	Redistribution and use in source and binary forms, with or without
	modification, are permitted provided that the following conditions are met:

	1. Redistributions of source code must retain the above copyright notice,
	   this list of conditions and the following disclaimer.

	2. Redistributions in binary form must reproduce the above copyright
	   notice, this list of conditions and the following disclaimer in the
	   documentation and/or other materials provided with the distribution.

	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
	POSSIBILITY OF SUCH DAMAGE.
*/

30
require_once("guiconfig.inc");
31
require_once("interfaces.inc");
Ad Schellevis's avatar
Ad Schellevis committed
32 33 34

$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/system_hasync.php');

Ad Schellevis's avatar
Ad Schellevis committed
35
if (!isset($config['hasync']) || !is_array($config['hasync'])) {
36 37
    $config['hasync'] = array();
}
Ad Schellevis's avatar
Ad Schellevis committed
38 39 40

$a_hasync = &$config['hasync'];

41 42
$checkbox_names = array(
            'pfsyncenabled',
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
            'synchronizeusers',
            'synchronizeauthservers',
            'synchronizecerts',
            'synchronizerules',
            'synchronizeschedules',
            'synchronizealiases',
            'synchronizenat',
            'synchronizeipsec',
            'synchronizeopenvpn',
            'synchronizedhcpd',
            'synchronizewol',
            'synchronizestaticroutes',
            'synchronizelb',
            'synchronizevirtualip',
            'synchronizednsforwarder',
58
);
Ad Schellevis's avatar
Ad Schellevis committed
59 60

if ($_POST) {
61 62
    $pconfig = $_POST;
    foreach ($checkbox_names as $name) {
63 64 65 66 67
	if (isset($pconfig[$name])) {
		$a_hasync[$name] = $pconfig[$name];
	} else {
		$a_hasync[$name] = false;
	}
68 69 70 71 72 73 74 75 76 77
    }
    $a_hasync['pfsyncpeerip']    = $pconfig['pfsyncpeerip'];
    $a_hasync['pfsyncinterface'] = $pconfig['pfsyncinterface'];
    $a_hasync['synchronizetoip'] = $pconfig['synchronizetoip'];
    $a_hasync['username']        = $pconfig['username'];
    $a_hasync['password']        = $pconfig['password'];
    write_config("Updated High Availability configuration");
    interfaces_carp_setup();
    header("Location: system_hasync.php");
    exit();
Ad Schellevis's avatar
Ad Schellevis committed
78 79 80
}

foreach ($checkbox_names as $name) {
Ad Schellevis's avatar
Ad Schellevis committed
81 82 83 84
    if (isset($a_hasync[$name])) {
        $pconfig[$name] = $a_hasync[$name];
    } else {
        $pconfig[$name] = null;
85
    }
Ad Schellevis's avatar
Ad Schellevis committed
86 87 88 89 90 91 92
}
foreach (array('pfsyncpeerip','pfsyncinterface','synchronizetoip','username','password') as $tag) {
	if (isset($a_hasync[$tag])) {
		$pconfig[$tag] = $a_hasync[$tag];
	} else {
		$pconfig[$tag] = null;
	}
Ad Schellevis's avatar
Ad Schellevis committed
93 94 95 96 97
}

$ifaces = get_configured_interface_with_descr();
$ifaces["lo0"] = "loopback";

98
$pgtitle = array(gettext('System'), gettext('High Availability'), gettext('Synchronization'));
Ad Schellevis's avatar
Ad Schellevis committed
99 100 101
include("head.inc");
?>

102 103
<body>
<?php include("fbegin.inc"); ?>
Ad Schellevis's avatar
Ad Schellevis committed
104

105
<!-- row -->
106

107 108
<section class="page-content-main">
	<div class="container-fluid">
109

110
        <div class="row">
111

112
            <section class="col-xs-12">
113 114
                <div class="content-box">

115
                    <div class="table-responsive">
Ad Schellevis's avatar
Ad Schellevis committed
116

117
                        <form action="system_hasync.php" method="post" name="iform" id="iform">
118

Jos Schellevis's avatar
Jos Schellevis committed
119
				<table class="table table-primary table-striped" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
120 121 122 123 124 125 126 127 128
				<thead>
					<tr>
						<th colspan="2" class="listtopic">State Synchronization Settings (pfsync)</th>
					</tr>
				</thead>
				<tbody>
					<tr valign="top">
						<td width="22%" class="vncell">Synchronize States</td>
						<td class="vtable">
129 130 131
							<input id='pfsyncenabled' type='checkbox' name='pfsyncenabled' value='on' <?php if ($pconfig['pfsyncenabled'] === "on") {
                                echo "checked='checked'";
} ?> />
132
							pfsync transfers state insertion, update, and deletion messages between firewalls.<br/>
133
							Each firewall sends these messages out via multicast on a specified interface, using the PFSYNC protocol <a href="http://www.openbsd.org/faq/pf/carp.html" target="_blank">(IP Protocol 240)</a>.
134 135 136
							<br/>It also listens on that interface for similar messages from other firewalls, and imports them into the local state table.
							<br/>This setting should be enabled on all members of a failover group.
							<div class="well well-sm" ><b>Clicking save will force a configuration sync if it is enabled! (see Configuration Synchronization Settings below)</b></div>
137 138 139 140 141
						</td>
					</tr>
					<tr valign="top">
						<td width="22%" class="vncell">Synchronize Interface</td>
						<td class="vtable">
142
							<select id='pfsyncinterface' name="pfsyncinterface" class="selectpicker" data-style="btn-default" data-live-search="true" data-width="auto">
143 144
							<?php foreach ($ifaces as $ifname => $iface) {
?>
145
								<?php $selected = ($pconfig['pfsyncinterface'] === $ifname) ? 'selected="selected"' : ''; ?>
146 147 148 149
								<option value="<?= htmlentities($ifname);
?>" <?= $selected ?>><?= htmlentities($iface); ?></option>
							<?php
} ?>
150
							</select>
151 152 153 154 155 156 157 158
							If Synchronize States is enabled, it will utilize this interface for communication.<br/><br/>
							<div class="well">
								<lu>
								<li>We recommend setting this to a interface other than LAN!  A dedicated interface works the best.</li>
								<li>You must define a IP on each machine participating in this failover group.</li>
								<li>You must have an IP assigned to the interface on any participating sync nodes.</li>
								</lu>
							</div>
159 160 161 162 163
						</td>
					</tr>
					<tr valign="top">
						<td width="22%" class="vncell">pfsync Synchronize Peer IP</td>
						<td class="vtable">
164
							<input  id='pfsyncpeerip' name='pfsyncpeerip' type='text' class='formfld unknown' value='<?= htmlentities($pconfig['pfsyncpeerip']); ?>' />
165 166 167 168
							Setting this option will force pfsync to synchronize its state table to this IP address.  The default is directed multicast.
						</td>
					</tr>
					<tr>
169
                                        <td></td>
170 171 172 173 174
						<td>&nbsp;</td>
					</tr>
				</tbody>
				</table>

Jos Schellevis's avatar
Jos Schellevis committed
175
				<table class="table table-primary table-striped" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
176 177 178 179 180 181 182 183 184
				<thead>
					<tr>
						<th colspan="2" class="listtopic">Configuration Synchronization Settings (XMLRPC Sync)</th>
					</tr>
				</thead>
				<tbody>
					<tr valign="top">
						<td width="22%" class="vncell">Synchronize Config to IP</td>
						<td class="vtable">
185
							<input  id='synchronizetoip' name='synchronizetoip' type='text' class='formfld unknown' value='<?= htmlentities($pconfig['synchronizetoip']); ?>' />
186
							Enter the IP address of the firewall to which the selected configuration sections should be synchronized.<br />
187 188 189 190 191 192
							<div class="well">
								<lu>
									<li>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!</li>
									<li><b>Do not use the Synchronize Config to IP and password option on backup cluster members!</b></li>
								</lu>
							</div>
193 194 195 196 197
						</td>
					</tr>
					<tr valign="top">
						<td width="22%" class="vncell">Remote System Username</td>
						<td class="vtable">
198
							<input  id='username' name='username' type='text' class='formfld unknown' value='<?= htmlentities($pconfig['username']); ?>' />
199 200
							<br />
							Enter the webConfigurator username of the system entered above for synchronizing your configuration.<br />
201 202 203
							<div class="well well-sm">
								<b>Do not use the Synchronize Config to IP and username option on backup cluster members!</b>
							</div>
204 205 206 207 208
						</td>
					</tr>
					<tr valign="top">
						<td width="22%" class="vncell">Remote System Password</td>
						<td class="vtable">
209
							<input  id='password' type='password' name='password' class='formfld pwd' value='<?= htmlentities($pconfig['password']); ?>' />
210 211
							<br />
							Enter the webConfigurator password of the system entered above for synchronizing your configuration.<br />
212 213 214
							<div class="well well-sm">
								<b>Do not use the Synchronize Config to IP and password option on backup cluster members!</b>
							</div>
215 216 217 218 219
						</td>
					</tr>
					<tr valign="top">
						<td width="22%" class="vncell">Synchronize Users and Groups</td>
						<td class="vtable">
220 221 222
							<input id='synchronizeusers' type='checkbox' name='synchronizeusers' value='on' <?php if ($pconfig['synchronizeusers'] === "on") {
                                echo "checked='checked'";
} ?> />
223
							Automatically sync the users and groups over to the other HA host when changes are made.
224 225 226 227 228
						</td>
					</tr>
					<tr valign="top">
						<td width="22%" class="vncell">Synchronize Auth Servers</td>
						<td class="vtable">
229 230 231
							<input id='synchronizeauthservers' type='checkbox' name='synchronizeauthservers' value='on' <?php if ($pconfig['synchronizeauthservers'] === "on") {
                                echo "checked='checked'";
} ?> />
232
							Automatically sync the authentication servers (e.g. LDAP, RADIUS) over to the other HA host when changes are made.
233 234 235 236 237
						</td>
					</tr>
					<tr valign="top">
						<td width="22%" class="vncell">Synchronize Certificates</td>
						<td class="vtable">
238 239 240
							<input id='synchronizecerts' type='checkbox' name='synchronizecerts' value='on' <?php if ($pconfig['synchronizecerts'] === "on") {
                                echo "checked='checked'";
} ?> />
241
							Automatically sync the Certificate Authorities, Certificates, and Certificate Revocation Lists over to the other HA host when changes are made.
242 243 244 245 246
						</td>
					</tr>
					<tr valign="top">
						<td width="22%" class="vncell">Synchronize rules</td>
						<td class="vtable">
247 248 249
							<input id='synchronizerules' type='checkbox' name='synchronizerules' value='on' <?php if ($pconfig['synchronizerules'] === "on") {
                                echo "checked='checked'";
} ?> />
250
							Automatically sync the firewall rules to the other HA host when changes are made.
251 252 253 254 255
						</td>
					</tr>
					<tr valign="top">
						<td width="22%" class="vncell">Synchronize Firewall Schedules</td>
						<td class="vtable">
256 257 258
							<input id='synchronizeschedules' type='checkbox' name='synchronizeschedules' value='on' <?php if ($pconfig['synchronizeschedules'] === "on") {
                                echo "checked='checked'";
} ?> />
259
							Automatically sync the firewall schedules to the other HA host when changes are made.
260 261 262 263 264
						</td>
					</tr>
					<tr valign="top">
						<td width="22%" class="vncell">Synchronize aliases</td>
						<td class="vtable">
265 266 267
							<input id='synchronizealiases' type='checkbox' name='synchronizealiases' value='on' <?php if ($pconfig['synchronizealiases'] === "on") {
                                echo "checked='checked'";
} ?> />
268
							Automatically sync the aliases over to the other HA host when changes are made.
269 270 271 272 273
						</td>
					</tr>
					<tr valign="top">
						<td width="22%" class="vncell">Synchronize NAT</td>
						<td class="vtable">
274 275 276
							<input id='synchronizenat' type='checkbox' name='synchronizenat' value='on' <?php if ($pconfig['synchronizenat'] === "on") {
                                echo "checked='checked'";
} ?> />
277
							Automatically sync the NAT rules over to the other HA host when changes are made.
278 279 280 281 282
						</td>
					</tr>
					<tr valign="top">
						<td width="22%" class="vncell">Synchronize IPsec</td>
						<td class="vtable">
283 284 285
							<input id='synchronizeipsec' type='checkbox' name='synchronizeipsec' value='on' <?php if ($pconfig['synchronizeipsec'] === "on") {
                                echo "checked='checked'";
} ?> />
286
							Automatically sync the IPsec configuration to the other HA host when changes are made.
287 288 289 290 291
						</td>
					</tr>
					<tr valign="top">
						<td width="22%" class="vncell">Synchronize OpenVPN</td>
						<td class="vtable">
292 293 294
							<input id='synchronizeopenvpn' type='checkbox' name='synchronizeopenvpn' value='on' <?php if ($pconfig['synchronizeopenvpn'] === "on") {
                                echo "checked='checked'";
} ?> />
295 296
							Automatically sync the OpenVPN configuration to the other HA host when changes are made.
							<div class="well well-sm"><b>Using this option implies "Synchronize Certificates" as they are required for OpenVPN.</b></div>
297 298 299 300 301
						</td>
					</tr>
					<tr valign="top">
						<td width="22%" class="vncell">Synchronize DHCPD</td>
						<td class="vtable">
302 303 304
							<input id='synchronizedhcpd' type='checkbox' name='synchronizedhcpd' value='on' <?php if ($pconfig['synchronizedhcpd'] === "on") {
                                echo "checked='checked'";
} ?> />
305
							Automatically sync the DHCP Server settings over to the other HA host when changes are made. This only applies to DHCP for IPv4.
306 307 308 309 310
						</td>
					</tr>
					<tr valign="top">
						<td width="22%" class="vncell">Synchronize Wake on LAN</td>
						<td class="vtable">
311 312 313
							<input id='synchronizewol' type='checkbox' name='synchronizewol' value='on' <?php if ($pconfig['synchronizewol'] === "on") {
                                echo "checked='checked'";
} ?> />
314
							Automatically sync the WoL configuration to the other HA host when changes are made.
315 316 317 318 319
						</td>
					</tr>
					<tr valign="top">
						<td width="22%" class="vncell">Synchronize Static Routes</td>
						<td class="vtable">
320 321 322
							<input id='synchronizestaticroutes' type='checkbox' name='synchronizestaticroutes' value='on' <?php if ($pconfig['synchronizestaticroutes'] === "on") {
                                echo "checked='checked'";
} ?> />
323
							Automatically sync the Static Route configuration to the other HA host when changes are made.
324 325 326 327 328
						</td>
					</tr>
					<tr valign="top">
						<td width="22%" class="vncell">Synchronize Load Balancer</td>
						<td class="vtable">
329 330 331
							<input id='synchronizelb' type='checkbox' name='synchronizelb' value='on' <?php if ($pconfig['synchronizelb'] === "on") {
                                echo "checked='checked'";
} ?> />
332
							Automatically sync the Load Balancer configuration to the other HA host when changes are made.
333 334 335 336 337
						</td>
					</tr>
					<tr valign="top">
						<td width="22%" class="vncell">Synchronize Virtual IPs</td>
						<td class="vtable">
338 339 340
							<input id='synchronizevirtualip' type='checkbox' name='synchronizevirtualip' value='on' <?php if ($pconfig['synchronizevirtualip'] === "on") {
                                echo "checked='checked'";
} ?> />
341
							Automatically sync the CARP Virtual IPs to the other HA host when changes are made.
342 343 344 345 346
						</td>
					</tr>
					<tr valign="top">
						<td width="22%" class="vncell">Synchronize DNS Forwarder</td>
						<td class="vtable">
347 348 349
							<input id='synchronizednsforwarder' type='checkbox' name='synchronizednsforwarder' value='on' <?php if ($pconfig['synchronizednsforwarder'] === "on") {
                                echo "checked='checked'";
} ?> />
350
							Automatically sync the DNS Forwarder configuration to the other HA host when changes are made.
351 352 353 354 355 356 357
						</td>
					</tr>
					<tr>
						<td width="22%" valign="top">&nbsp;</td>
						<td width="78%">
							<input name="id" type="hidden" value="0" />
							<input name="Submit" type="submit" class="btn btn-primary" value="Save" />
358 359
							<input type="button" class="btn btn-default" value="<?=gettext("Cancel");
?>" onclick="window.location.href='<?=$referer;?>'" />
360 361 362
						</td>
					</tr>
				</tbody>
363 364
                            </table>
                        </form>
365

366
                       </div>
367

368 369
                </div>
            </section>
370

371
        </div>
372

373
	</div>
374 375 376
</section>


377
<?php include("foot.inc");