diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc index 437e09609b..cd727a1c01 100644 --- a/etc/inc/filter.inc +++ b/etc/inc/filter.inc @@ -526,13 +526,13 @@ function filter_nat_rules_generate() { /* if item is an alias, expand */ if(alias_expand($rule['external-port'])) - $extport[0] = alias_expand($rule['external-port']); - else + $extport[0] = alias_expand_value($rule['external-port']); + else $extport = explode("-", $rule['external-port']); /* if item is an alias, expand */ if(alias_expand($rule['local-port'])) - $localport = alias_expand($rule['local-port']); + $localport = alias_expand_value($rule['local-port']); else $localport = $rule['local-port']; @@ -560,24 +560,15 @@ function filter_nat_rules_generate() { $lanif = $lancfg['if']; - - /* * 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($target); - if(alias_expand($localport)) - $localport = alias_expand($localport); if(alias_expand($extaddr)) $extaddr = alias_expand($extaddr); - if ((!$extport[1]) || ($extport[0] == $extport[1])) { if($rule['protocol'] == "tcp/udp") $natrules .= diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 96903fc7dc..cbf1967980 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -347,6 +347,17 @@ function is_alias($name) { global $aliastable; return isset($aliastable[$name]); +} + +function alias_expand_value($name) { + + global $aliastable, $config; + + foreach($config['aliases']['alias'] as $alias) { + if($alias['name'] == $name) + return $alias['address']; + } + } /* expand a host or network alias, if necessary */