mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Try to always keep pfSense with a default gateway to avoid errors for service running from pfSense itself. Previously PBR should be configured for such services. While PBR is a better fix this at least keeps users from complaining in simple setups. Reported by many.
This commit is contained in:
parent
f206afb57e
commit
1d60ed9bb4
@ -367,6 +367,30 @@ function return_gateway_groups_array() {
|
||||
$gateways_arr = return_gateways_array();
|
||||
$gateway_groups_array = array();
|
||||
|
||||
/*
|
||||
* NOTE: The code below is meant to replace the default gateway when it goes down.
|
||||
* This facilitates services running on pfSense itself and are not handled by a PBR to continue working.
|
||||
*/
|
||||
$upgw = "";
|
||||
$dfltgwdown = false;
|
||||
foreach ($gateways_arr as $gwname => $gwsttng) {
|
||||
if ($gwsttng['defaultgw'] == true && stristr($gateways_status[$gwname]['status'], "down"))
|
||||
$dfltgwdown = true;
|
||||
/* Keep a record of the last up gateway */
|
||||
if (empty($upgw) && !stristr($gateways_status[$gwname]['status'], "down"))
|
||||
$upgw = $gwname;
|
||||
if ($dfltgwdown == true && !empty($upgw)) {
|
||||
if ($gateways_arr[$upgw]['gateway'] == "dynamic")
|
||||
$gateways_arr[$upgw]['gateway'] = get_interface_gateway($gateways_arr[$upgw]['friendlyiface']);
|
||||
if (is_ipaddr($gateways_arr[$upgw]['gateway'])) {
|
||||
log_error("Default gateway down setting {$upgw} as default!");
|
||||
mwexec("/sbin/route delete -inet default; /sbin/route add -inet default {$gateways_arr[$upgw]['gateway']}");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
unset($upgw, $dfltgwdown, $gwname, $gwsttng);
|
||||
|
||||
if (is_array($config['gateways']['gateway_group'])) {
|
||||
foreach($config['gateways']['gateway_group'] as $group) {
|
||||
/* create array with group gateways members seperated by tier */
|
||||
@ -532,4 +556,4 @@ function get_interface_gateway($interface, &$dynamic = false) {
|
||||
return ($gw);
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user