-   Linux - Networking (
-   -   Using iptables as hosts file (

Fourthbean 03-25-2006 01:04 PM

Using iptables as hosts file
I would like to redirect a web address to a different ip. This can be done in a hosts file, but it would affect everone else on the shared hosting server. I was pointed towards iptables. Is it possible to create an iptables entry that would forward any packet going to instead to suchandsuchip, but only if the packet is coming from

Hopefully this made sense.

The server is linux btw.


acid_kewpie 03-25-2006 05:41 PM

that'd be a nat rule:

iptables -t nat -A PREROUTING -t nat -p tcp -d --dport 80 -j DNAT --to

so all data the box sees going to port 80 on ip gets sent to on the same port.

Fourthbean 03-26-2006 09:20 PM

Thank you so much. I love Linux :) And of course the people that help the noobs with it :)

acid_kewpie 03-27-2006 06:27 AM

no probs... maybe you'd like to give this opinion here... :)

Fourthbean 03-28-2006 12:20 AM

Wow, what a thread.

I have come back for more help though. I looked in the man page and if I want to send to multiple destination ip's it appears it does a round robin. I would like to send to multiple destinations redundandtly instead of load balancing. Is that possible?

acid_kewpie 03-28-2006 01:52 AM

There's plenty of close sounding things in the iptables manpage... check the DNAT section for obselete references, also the SAME section for -to ranges, and there's also the --tee option in the ROUTE section, which clones the packet. wether these can be assimiliated into a solution for you, i'm not sure... worth a play though

All times are GMT -5. The time now is 03:03 PM.