iptables port forwarding on dial-up connection

I have done this because I wanted to host a game of Live For Speed over a DSL-line. The following steps have to be applied:
  1. First thing to do is to enable IP-forwarding (obviously)
  2. Then we change the DESTINATION of packets coming in on ppp0
  3. Still the SOURCE of those packets points to some computer on the internet
This can be achieved with the following shell script (sh)
IPTNAT="$IPT -t nat -A"

echo "Activating forwarding... beware!"
echo "1" > /proc/sys/net/ipv4/ip_forward

#$IPT --flush -t nat

# packets coming in from $IF are routed to $SERVER
$IPTNAT PREROUTING -p tcp --dport $PORT -i $IF -j DNAT --to $SERVER:$PORT
$IPTNAT PREROUTING -p udp --dport $PORT -i $IF -j DNAT --to $SERVER:$PORT

# before leaving those packets are modified to look as if they came
# from $GW, so the return packets from $SERVER find their way back to $GW
$IPTNAT POSTROUTING -p tcp --dport $PORT -d $SERVER -j SNAT --to $GW
$IPTNAT POSTROUTING -p udp --dport $PORT -d $SERVER -j SNAT --to $GW

$IPT -L -t nat -vn

This was a really interesting post about IPv4. I had no idea that they were such a big part of the internet. I want to learn more. I will have to do some more research! Maybe I can find some good information at the library.
Emily Smith | http://iptrading.com/sell-ipv4/
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?