Commit 804a22fa authored by Franco Fichtner's avatar Franco Fichtner

inc/filter: do not hardcode the target IP in auto NAT rules

Suggested by: Jim Thompson <jim@netgate.com>
parent 2811402f
...@@ -1406,21 +1406,26 @@ function filter_nat_rules_automatic_tonathosts($with_descr = false) { ...@@ -1406,21 +1406,26 @@ function filter_nat_rules_automatic_tonathosts($with_descr = false) {
return $tonathosts; return $tonathosts;
} }
function filter_nat_rules_outbound_automatic($src) { function filter_nat_rules_outbound_automatic($src)
{
global $config, $FilterIflist; global $config, $FilterIflist;
$rules = array(); $rules = array();
foreach ($FilterIflist as $if => $ifcfg) { foreach ($FilterIflist as $if => $ifcfg) {
if (substr($ifcfg['if'], 0, 4) == "ovpn") if (substr($ifcfg['if'], 0, 4) == 'ovpn') {
continue; continue;
if (!interface_has_gateway($if)) }
if (!interface_has_gateway($if)) {
continue; continue;
}
$natent = array(); $natent = array();
$natent['interface'] = $if; $natent['interface'] = $if;
$natent['source']['network'] = $src; $natent['source']['network'] = $src;
$natent['dstport'] = "500"; $natent['dstport'] = '500';
$natent['target'] = $ifcfg['ip']; $natent['target'] = '';
$natent['destination']['any'] = true; $natent['destination']['any'] = true;
$natent['staticnatport'] = true; $natent['staticnatport'] = true;
$natent['descr'] = gettext('Auto created rule for ISAKMP'); $natent['descr'] = gettext('Auto created rule for ISAKMP');
...@@ -1429,13 +1434,14 @@ function filter_nat_rules_outbound_automatic($src) { ...@@ -1429,13 +1434,14 @@ function filter_nat_rules_outbound_automatic($src) {
$natent = array(); $natent = array();
$natent['interface'] = $if; $natent['interface'] = $if;
$natent['source']['network'] = $src; $natent['source']['network'] = $src;
$natent['sourceport'] = ""; $natent['sourceport'] = '';
$natent['target'] = $ifcfg['ip']; $natent['target'] = '';
$natent['destination']['any'] = true; $natent['destination']['any'] = true;
$natent['natport'] = ""; $natent['natport'] = '';
$natent['descr'] = gettext('Auto created rule'); $natent['descr'] = gettext('Auto created rule');
if (isset($ifcfg['nonat'])) if (isset($ifcfg['nonat'])) {
$natent['nonat'] = true; $natent['nonat'] = true;
}
$rules[] = $natent; $rules[] = $natent;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment