Firwall/Nat, when using "Reflection for port forwards" we should only add nat rules for interfaces with configured addresses.

Although this looks a bit duplicate at first, when the nat interface itself (e.g. openvpn) is missing a network, we should add a rdr, but skip the nat rule.

closes https://github.com/opnsense/core/issues/3023
This commit is contained in:
Ad Schellevis 2018-12-09 19:52:23 +01:00
parent 6b848aba4a
commit d8f23d5210

View File

@ -156,8 +156,13 @@ class ForwardRule extends Rule
$rule = $tmp;
// automatically generate nat rule when enablenatreflectionhelper is set
if (!$rule['disabled'] && empty($rule['nordr']) && !empty($rule['enablenatreflectionhelper'])) {
$rule['rule_types'][] = "rdr_nat";
$rule['staticnatport'] = !empty($rule['staticnatport']);
if (!empty($this->interfaceMapping[$rule['interface']]) && (
!empty($this->interfaceMapping[$rule['interface']]['ifconfig']['ipv4']) ||
!empty($this->interfaceMapping[$rule['interface']]['ifconfig']['ipv6'])
)) {
$rule['rule_types'][] = "rdr_nat";
$rule['staticnatport'] = !empty($rule['staticnatport']);
}
}
$rule['interface'] = $interf;
yield $rule;