Save the following (caution, line wraps !!)
to /etc/e-smith/templates/etc/rc.d/init.d/60SetPortFW
run /sbin/e-smith/expand-template /etc/rc.d/init.d/masq
followed by a
/etc/init.d/masq restart
This currently only allows TCP forwards. I didn't check for the UDP ones yet.
This is a quick hack ! use at your own risk.
{
local %services = ( masq => $masq );
$OUT = "";
local $me = "portfw";
local $status = db_get_prop(\%services, 'masq', 'status') || "disabled";
local $loadme = db_get_prop(\%services, 'masq', $me) || "yes";
if ( ($status eq "enabled") and ($loadme eq "yes") )
{
local %tcp_forwards =
split(/,/,
db_get_prop(\%services, 'masq', 'TCPForwards') || '');
foreach my $port (keys %tcp_forwards)
{
$OUT .= " /sbin/iptables --table nat --append PREROUTING ";
# Set up local port to forward
$OUT .= "-d $ExternalIP -p tcp --dport ${port} ";
# Set up the remote port to forward to
$OUT .= "-j DNAT --to $tcp_forwards{$port}:$port\n";
}
local %udp_forwards =
split(/,/,
db_get_prop(\%services, 'masq', 'UDPForwards') || '');
#foreach my $port (keys %udp_forwards)
#{
# $OUT .= " /sbin/iptables portfw -a -P udp ";
# # Set up local port to forward
# $OUT .= "-L $ExternalIP $port ";
# # Set up the remote port to forward to
# $OUT .= "-R $tcp_forwards{$port} $port\n";
# # And accept the incoming packets
# $OUT .= " /sbin/iptables --append input -p udp -s 0/0 ";
# $OUT .= "-d \$OUTERNET ${port} -j ACCEPT\n";
#}
}
}