Skip to content

Commit bad6be2

Browse files
committed
Firewall/SNAT, wrap interface as list to prevent "no IP address found for ..." in some scenario's (openvpn for example)
1 parent 49a2bc6 commit bad6be2

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/opnsense/mvc/app/library/OPNsense/Firewall/SNatRule.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,18 @@ private function parseNatRules()
7272
} elseif (empty($rule['target'])) {
7373
$interf = $rule['interface'];
7474
if (!empty($this->interfaceMapping[$interf])) {
75-
if (($this->isIpV4($rule) && !empty($this->interfaceMapping[$interf]['ifconfig']['ipv4'])) ||
76-
(!$this->isIpV4($rule) && !empty($this->interfaceMapping[$interf]['ifconfig']['ipv6']))
75+
$interf_settings = $this->interfaceMapping[$interf];
76+
if ((($this->isIpV4($rule) && !empty($interf_settings['ifconfig']['ipv4'])) ||
77+
(!$this->isIpV4($rule) && !empty($interf_settings['ifconfig']['ipv6'])))
78+
&& (!empty($rule['poolopts']) || $rule['poolopts'] != 'round-robin')
7779
) {
78-
$rule['target'] = $this->interfaceMapping[$interf]['if'];
80+
// When pool options are set, we may not specify our interface as a list
81+
// (which doesn't require the same network validations as single items do).
82+
$rule['target'] = "{$interf_settings['if']}";
83+
} elseif (!empty($interf_settings['if'])) {
84+
// Define target as list, to prevent "no IP address found for *Interface*" when pf can't
85+
// find an address on the interface for the same protocol family.
86+
$rule['target'] = "({$interf_settings['if']})";
7987
}
8088
}
8189
if (empty($rule['target'])) {

0 commit comments

Comments
 (0)