Port forwarding in Linux with Iptables


I have one Linux Machine. It has 2 interfaces. eth0 will have Live IP and which will be accessible across the internet. eth1 will have internal IP and can only be connected across LAN.
Here I want to forward all request which come to my internetIP should get forwarded to my internal web server. To do this need to give following commands on linux machine:

#iptables -t nat -A PREROUTING -p tcp -i eth0 -d <Live IP / IP of outside interface of firewall> –dport 80 -j DNAT –to <Internal server’s IP / IP of the server where the request will forward to>:80

 
#iptables -A FORWARD -p tcp -i eth0 -d <Internal server’s IP / IP of the server where the request will forward to> –dport 80 -j ACCEPT
 

Neelesh Gurjar has written 122 articles

Leave a Reply