diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2005-07-29 22:05:37 +0000 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2005-07-29 22:05:37 +0000 |
commit | e63cca08e0a91b811337754a811f37d6b40c817e (patch) | |
tree | 96701fc7e71649c49e7babbb0efdd7e961b64cc8 /etc | |
parent | 14249fdadd129ea95eecb9352d5a864c132d4f0c (diff) | |
download | pfsense-e63cca08e0a91b811337754a811f37d6b40c817e.zip pfsense-e63cca08e0a91b811337754a811f37d6b40c817e.tar.gz |
Expand NAT aliases
Ticket #273
Diffstat (limited to 'etc')
-rw-r--r-- | etc/inc/filter.inc | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc index 12609dc..92c1149 100644 --- a/etc/inc/filter.inc +++ b/etc/inc/filter.inc @@ -1005,10 +1005,24 @@ function filter_nat_rules_generate() { $extport = explode("-", $rule['external-port']); $target = alias_expand_host($rule['target']); + $localport = $rule['local-port']; if (!$target) continue; /* unresolvable alias */ + /* + * Expand aliases + * XXX: may want to integrate this into pf macros + */ + if(alias_expand($extport[0])) + $extport[0] = alias_expand($extport[0]); + if(alias_expand($extport[1])) + $extport[1] = alias_expand($extport[1]); + if(alias_expand($target)) + $target = alias_expand($extport[1]); + if(alias_expand($localport)) + $localport = alias_expand($localport); + if ($rule['external-address']) if($rule['external-address'] <> "any") $extaddr = $rule['external-address'] . "/32"; @@ -1029,10 +1043,10 @@ function filter_nat_rules_generate() { if ((!$extport[1]) || ($extport[0] == $extport[1])) { if($rule['protocol'] == "tcp/udp") $natrules .= - "rdr on $natif proto { tcp udp } from any to {$extaddr} port {$extport[0]} -> {$target} port {$rule['local-port']}"; + "rdr on $natif proto { tcp udp } from any to {$extaddr} port {$extport[0]} -> {$target} port {$localport}"; else $natrules .= - "rdr on $natif proto " . $rule['protocol'] . " from any to {$extaddr} port {$extport[0]} -> {$target} port {$rule['local-port']}"; + "rdr on $natif proto " . $rule['protocol'] . " from any to {$extaddr} port {$extport[0]} -> {$target} port {$localport}"; } else { if($rule['protocol'] == "tcp/udp") |