The Core

Why We Are Here => Web Development => Topic started by: jetboy on October 31, 2011, 09:29:09 PM

Title: IPTables help needed
Post by: jetboy on October 31, 2011, 09:29:09 PM
Does anyone know their way around IPTables? I'm trying to get NAT port forwarding to work, with the eventual aim of routing all SSH and ILO traffic through a single external IP into the rack on different ports. I can't even get the basics working though. This would be a good start:

. I open a browser on my home machine (IP 1.2.3.4) and put the public eth0 IP of my datacentre machine in a browser, with a port of 88 (5.6.7.8:88).
. I want to forward the request to Slashdot (216.34.181.45:80) so I see Slashdot in my browser.

How?
Title: Re: IPTables help needed
Post by: jetboy on November 01, 2011, 03:26:25 PM
echo 1 > /proc/sys/net/ipv4/ip_forward

iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 88 -j DNAT --to-destination 216.34.181.45:80
iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to-source 5.6.7.8


or

*nat
-A PREROUTING -p tcp -m tcp -i eth0 --dport 88 -j DNAT --to-destination 216.34.181.45:80
-A POSTROUTING -o eth0 -j SNAT --to-source 5.6.7.8
COMMIT


if it's in a .conf file. Sweet.