IPTables help needed

Started by jetboy, October 31, 2011, 09:29:09 PM

Previous topic - Next topic

jetboy

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?

jetboy

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.