mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Be more intelligent when managing OpenVPN client connections bound to CARP VIPs. If the interface is in BACKUP status, do not start the client. Add a section to rc.carpmaster and rc.carpbackup to trigger this start/stop.
If an OpenVPN client is active on both the master and backup system, they will cause conflicting connections to the server. Servers do not care as they only accept, not initiate.
This commit is contained in:
parent
731de7112a
commit
9ea0cb90a6
@ -672,6 +672,10 @@ function openvpn_restart($mode, $settings) {
|
||||
if (isset($settings['disable']))
|
||||
return;
|
||||
|
||||
/* Do not start if we are a CARP backup on this vip! */
|
||||
if ((substr($settings['interface'], 0, 3) == "vip") && (get_carp_interface_status($settings['interface']) == "BACKUP"))
|
||||
return;
|
||||
|
||||
/* start the new process */
|
||||
$fpath = $g['varetc_path']."/openvpn/{$mode_id}.conf";
|
||||
mwexec_bg("/usr/local/sbin/openvpn --config {$fpath}");
|
||||
|
||||
@ -32,10 +32,20 @@
|
||||
require_once("functions.inc");
|
||||
require_once("config.inc");
|
||||
require_once("notices.inc");
|
||||
require_once("openvpn.inc");
|
||||
|
||||
$notificationmsg = "A carp cluster member has resumed the state 'BACKUP'";
|
||||
|
||||
notify_via_smtp($notificationmsg);
|
||||
notify_via_growl($notificationmsg);
|
||||
|
||||
/* Stop OpenVPN clients running on this VIP, since multiple active OpenVPN clients on a CARP cluster can be problematic. */
|
||||
global $config;
|
||||
foreach ($config['openvpn']['openvpn-client'] as $settings) {
|
||||
if ($settings['interface'] == $argv[1]) {
|
||||
log_error("Stopping OpenVPN instance on {$settings['interface']} because of transition to CARP backup.");
|
||||
openvpn_restart('client', $settings);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -32,10 +32,20 @@
|
||||
require_once("functions.inc");
|
||||
require_once("config.inc");
|
||||
require_once("notices.inc");
|
||||
require_once("openvpn.inc");
|
||||
|
||||
$notificationmsg = "A carp cluster member has resumed the state 'MASTER'";
|
||||
|
||||
notify_via_smtp($notificationmsg);
|
||||
notify_via_growl($notificationmsg);
|
||||
|
||||
/* Start OpenVPN clients running on this VIP, since they should be in the stopped state while the VIP is CARP Backup. */
|
||||
global $config;
|
||||
foreach ($config['openvpn']['openvpn-client'] as $settings) {
|
||||
if ($settings['interface'] == $argv[1]) {
|
||||
log_error("Starting OpenVPN instance on {$settings['interface']} because of transition to CARP master.");
|
||||
openvpn_restart('client', $settings);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user