Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Jan 2007 11:32:23 -0500
From:      Dan Casey <dcasey@debtresolve.com>
To:        freebsd-ipfw@freebsd.org
Subject:   help converting iptables rule into ipfw
Message-ID:  <45BE2197.30509@debtresolve.com>

next in thread | raw e-mail | index | archive | help
I have a quick script that takes web traffic on one internal ip, and
redirects it to another internal ip.  This is working fine in iptables. 
Can anyone show me how to recreate this in ipfw?



<?php


$eth     ="eth0:38";
$int_ip  ="192.168.1.238";
$int_port="80";
$ext_ip  ="10.0.0.238";
$ext_port="80";



echo("Flushing NAT Tables\n");
//exec("/sbin/iptables -F");
//exec("/sbin/iptables -t nat -F");

echo("Setting up PREROUTING.--------\n");
exec("/sbin/iptables -t nat -A PREROUTING -p tcp -i $eth -d $int_ip "
   . "--dport $int_port -j DNAT --to $ext_ip:$ext_port");

echo("Setting up POSTROUTING.-------\n");
exec("/sbin/iptables -t nat -A POSTROUTING -o $eth -j MASQUERADE");

echo("Setting up FORWARD.-----------\n");
exec("/sbin/iptables -A FORWARD -p tcp -i $eth -d $ext_ip "
   . "--dport $ext_port -j ACCEPT");

echo("\n\n");
echo `/sbin/iptables -t nat -L`;


?>




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?45BE2197.30509>