summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Buechler <cmb@pfsense.org>2015-11-25 22:25:09 -0600
committerChris Buechler <cmb@pfsense.org>2015-11-25 22:25:09 -0600
commitdfdb1c116a1dc7991b04915774f4aef84daef644 (patch)
treeaf89d67cb674b38213fe8d758d0a9baad8429523
parent09fe7cf9fffa7324053dcea56e0e2686d307ba8b (diff)
parentde34f1fc12f29db0348f8ff9b1bc8300d9fb74d2 (diff)
downloadpfsense-dfdb1c116a1dc7991b04915774f4aef84daef644.zip
pfsense-dfdb1c116a1dc7991b04915774f4aef84daef644.tar.gz
Merge pull request #2119 from PiBa-NL/gateway_interface_route_2.3
-rw-r--r--src/etc/inc/system.inc18
-rw-r--r--src/usr/local/www/system_gateways_edit.php15
2 files changed, 31 insertions, 2 deletions
diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc
index 7b40de1..ce58b10 100644
--- a/src/etc/inc/system.inc
+++ b/src/etc/inc/system.inc
@@ -586,6 +586,24 @@ function system_routing_configure($interface = "") {
}
}
+ $gateways_arr = return_gateways_array(false, true);
+ foreach($gateways_arr as $gateway) {
+ // setup static interface routes for nonlocal gateways
+ if (isset($gateway["nonlocalgateway"])) {
+ $srgatewayip = $gateway['gateway'];
+ $srinterfacegw = $gateway['interface'];
+ if (is_ipaddr($srgatewayip) && !empty($srinterfacegw)) {
+ $inet = (!is_ipaddrv4($srgatewayip) ? "-inet6" : "-inet");
+ $cmd = "/sbin/route change {$inet} " . escapeshellarg($srgatewayip) . " ";
+ mwexec($cmd . "-iface " . escapeshellarg($srinterfacegw));
+ if (isset($config['system']['route-debug'])) {
+ $mt = microtime();
+ log_error("ROUTING debug: $mt - $cmd -iface $srinterfacegw ");
+ }
+ }
+ }
+ }
+
if ($dont_add_route == false) {
if (!empty($interface) && $interface != $interfacegw) {
;
diff --git a/src/usr/local/www/system_gateways_edit.php b/src/usr/local/www/system_gateways_edit.php
index 47b19f5..5641924 100644
--- a/src/usr/local/www/system_gateways_edit.php
+++ b/src/usr/local/www/system_gateways_edit.php
@@ -124,6 +124,7 @@ if (isset($id) && $a_gateways[$id]) {
$pconfig['down'] = $a_gateways[$id]['down'];
$pconfig['monitor'] = $a_gateways[$id]['monitor'];
$pconfig['monitor_disable'] = isset($a_gateways[$id]['monitor_disable']);
+ $pconfig['nonlocalgateway'] = isset($a_gateways[$id]['nonlocalgateway']);
$pconfig['descr'] = $a_gateways[$id]['descr'];
$pconfig['attribute'] = $a_gateways[$id]['attribute'];
$pconfig['disabled'] = isset($a_gateways[$id]['disabled']);
@@ -190,7 +191,7 @@ if ($_POST) {
$parent_sn = get_interface_subnet($_POST['interface']);
if (empty($parent_ip) || empty($parent_sn)) {
$input_errors[] = gettext("Cannot add IPv4 Gateway Address because no IPv4 address could be found on the interface.");
- } else {
+ } elseif (!isset($_POST["nonlocalgateway"])) {
$subnets = array(gen_subnet($parent_ip, $parent_sn) . "/" . $parent_sn);
$vips = link_interface_to_vips($_POST['interface']);
if (is_array($vips)) {
@@ -221,7 +222,7 @@ if ($_POST) {
$parent_sn = get_interface_subnetv6($_POST['interface']);
if (empty($parent_ip) || empty($parent_sn)) {
$input_errors[] = gettext("Cannot add IPv6 Gateway Address because no IPv6 address could be found on the interface.");
- } else {
+ } elseif (!isset($_POST["nonlocalgateway"])) {
$subnets = array(gen_subnetv6($parent_ip, $parent_sn) . "/" . $parent_sn);
$vips = link_interface_to_vips($_POST['interface']);
if (is_array($vips)) {
@@ -515,6 +516,9 @@ if ($_POST) {
if ($_POST['monitor_disable'] == "yes") {
$gateway['monitor_disable'] = true;
}
+ if ($_POST['nonlocalgateway'] == "yes") {
+ $gateway['nonlocalgateway'] = true;
+ }
if ($_POST['force_down'] == "yes") {
$gateway['force_down'] = true;
}
@@ -966,6 +970,13 @@ $section->addInput(new Form_StaticText(
'</span>'
));
+$section->addInput(new Form_Checkbox(
+ 'nonlocalgateway',
+ 'Use nonlocal gateway',
+ 'Use nonlocal gateway through interface specific route.',
+ $pconfig['nonlocalgateway']
+))->setHelp('This will disable the check if the gateway is reachable using the interface subnet. This is usually means a configuration error, but is required for some scenarios.');
+
$form->add($section);
print $form;
OpenPOWER on IntegriCloud