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)
#!/bin/sh
IF=ppp0
IPT=iptables
IPTNAT="$IPT -t nat -A"
PORT=63392
SERVER=insert_ip_here
GW=insert_ip_here

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



Comments:
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/
 
This comment has been removed by the author.
 
I was searching online to get some help with hosting a game over my line. The steps you have shared here had been very helpful for me to complete the task.
Thanks. Hailey | IPv4Mall
 
Very helpful post. Thanks
 
Post a Comment

<< Home

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