Author Topic: IPTables help needed  (Read 2022 times)

jetboy

  • Inner Core
  • Sr. Member
  • *
  • Posts: 433
  • Hens of warfare!
    • View Profile
    • Email
IPTables help needed
« 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?

jetboy

  • Inner Core
  • Sr. Member
  • *
  • Posts: 433
  • Hens of warfare!
    • View Profile
    • Email
Re: IPTables help needed
« Reply #1 on: November 01, 2011, 03:26:25 PM »
Code: [Select]
echo 1 > /proc/sys/net/ipv4/ip_forward
Code: [Select]
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

Code: [Select]
*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.