Port forwarding with iptables

2011-02-27 by xpheas
I am using a Linux gateway with an public IP-address to access the Internet.
To access an internal machine on port 80 beind the gateway from outside I created the following forwarding rule (iptables).
BASH-Code:
1
2
iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j DNAT --to 192.168.100.50:80
iptables -A INPUT -p tcp -m state --state NEW --dport 80 -i eth0 -j ACCEPT

The first rule does the forwaring job, the second allows new incomming connections on port 80.

Now the webserver on Port 80 behind the gateway is accessible over the public IP.

  « back

Feel Free to Leave a Comment

Name:*


Email: (not visible)


Website:


Comment:*