Skip to content

Commit

Permalink
Firewall/SNAT, wrap interface as list to prevent "no IP address found…
Browse files Browse the repository at this point in the history
… for ..." in some scenario's (openvpn for example)
  • Loading branch information
AdSchellevis committed Feb 5, 2018
1 parent 49a2bc6 commit bad6be2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/opnsense/mvc/app/library/OPNsense/Firewall/SNatRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,18 @@ private function parseNatRules()
} elseif (empty($rule['target'])) {
$interf = $rule['interface'];
if (!empty($this->interfaceMapping[$interf])) {
if (($this->isIpV4($rule) && !empty($this->interfaceMapping[$interf]['ifconfig']['ipv4'])) ||
(!$this->isIpV4($rule) && !empty($this->interfaceMapping[$interf]['ifconfig']['ipv6']))
$interf_settings = $this->interfaceMapping[$interf];
if ((($this->isIpV4($rule) && !empty($interf_settings['ifconfig']['ipv4'])) ||
(!$this->isIpV4($rule) && !empty($interf_settings['ifconfig']['ipv6'])))
&& (!empty($rule['poolopts']) || $rule['poolopts'] != 'round-robin')
) {
$rule['target'] = $this->interfaceMapping[$interf]['if'];
// When pool options are set, we may not specify our interface as a list
// (which doesn't require the same network validations as single items do).
$rule['target'] = "{$interf_settings['if']}";
} elseif (!empty($interf_settings['if'])) {
// Define target as list, to prevent "no IP address found for *Interface*" when pf can't
// find an address on the interface for the same protocol family.
$rule['target'] = "({$interf_settings['if']})";
}
}
if (empty($rule['target'])) {
Expand Down

0 comments on commit bad6be2

Please sign in to comment.