summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2011-04-04 11:09:06 +0000
committerErmal <eri@pfsense.org>2011-04-04 11:09:06 +0000
commit1d60ed9bb4901c5b85813d0dab32630e8a135d41 (patch)
tree825970b04a13072b83b57a810b49150ecf93d0a3 /etc
parentf206afb57e34ea30c43477deea3dfabfe10ad565 (diff)
downloadpfsense-1d60ed9bb4901c5b85813d0dab32630e8a135d41.zip
pfsense-1d60ed9bb4901c5b85813d0dab32630e8a135d41.tar.gz
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.
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/gwlb.inc26
1 files changed, 25 insertions, 1 deletions
diff --git a/etc/inc/gwlb.inc b/etc/inc/gwlb.inc
index a192bd3..75dc775 100644
--- a/etc/inc/gwlb.inc
+++ b/etc/inc/gwlb.inc
@@ -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);
}
-?> \ No newline at end of file
+?>
OpenPOWER on IntegriCloud