LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Using iptables as hosts file (https://www.linuxquestions.org/questions/linux-networking-3/using-iptables-as-hosts-file-428403/)

Fourthbean 03-25-2006 12: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 bf2web.gamespy.com instead to suchandsuchip, but only if the packet is coming from 207.210.238.174?

Hopefully this made sense.

The server is linux btw.

Thanks!
Fourthbean

acid_kewpie 03-25-2006 04:41 PM

that'd be a nat rule:

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

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

Fourthbean 03-26-2006 08: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 05:27 AM

no probs... maybe you'd like to give this opinion here... http://www.linuxquestions.org/questi...74#post2170274 :)

Fourthbean 03-27-2006 11:20 PM

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 12: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 02:49 PM.