Friday, June 09, 2006

DNAT with iptables

#!/bin/sh

#Params for dnat
DNAT_SERVER=x.x.x.x
WEB_SERVER=y.y.y.y
DNAT_PORT=p1
WEB_PORT=p2

echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -F
iptables -t nat -X
iptables -t nat -A POSTROUTING -j MASQUERADE
iptables -P FORWARD ACCEPT
iptables -t nat -A PREROUTING -p tcp -d $DNAT_SERVER --dport $DNAT_PORT -j DNAT --to-destination $WEB_SERVER:$WEB_PORT

0 Comments:

Post a Comment

<< Home