Friday, 13 May 2011

Linux Port Forwarding Using iptables.

Step 1: Setup a linux gateway server with public ip address.

Help: http://reddragon-linux.blogspot.com/2011/05/linux-internet-gateway-server-setup.html


Step 2: Find the service type which need the port forwading.

Eg: HTTP ( Port 80, TCP).

Public ip address : XXX.XXX.XXX.XXX
Local ip address : 192.168.1.2

/sbin/iptables -t nat -A PREROUTING -p tcp -i eth0 -d XXX.XXX.XXX.XXX --dport 80 -j DNAT --to 192.168.1.2:80
/sbin/iptables -A FORWARD -p tcp -i eth0 -d 192.168.1.2 --dport 80 -j ACCEPT

No comments:

Post a Comment

Post a Comment