Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

iptables rerouting 1

Status
Not open for further replies.

disturbedone

Vendor
Sep 28, 2006
781
AU
I am new to iptables and have what, I hope, is a relatively simple request.

* Ubuntu 11.04 (just built, no other config done)
* Virtual Machine
* Single NIC 10.100.0.9/16
* Anything coming in on port 80 to redirect to 10.11.0.19/16

What commands are required to achieve that? I've seen various forums with similar queries and I've tried something but haven't got it to work exactly.

Then, where are config files stored in Ubuntu? I've seen various forums pointing to /etc/sysconfig/ but there's no such folder in Ubuntu.

Thx
 
Ok, I worked out these commands get this to work.

Code:
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 10.11.0.19:8080
sudo iptables -t nat -A POSTROUTING -j MASQUERADE

The problem now is getting them to work on reboot. I've tried this but it doesn't seem to stick. Even the first command that enables forwarding at all doesn't stick. Any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top