LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices



Reply
 
Search this Thread
Old 03-25-2006, 01:04 PM   #1
Fourthbean
LQ Newbie
 
Registered: Aug 2005
Posts: 8

Rep: Reputation: 0
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
 
Old 03-25-2006, 05:41 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
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.
 
Old 03-26-2006, 09:20 PM   #3
Fourthbean
LQ Newbie
 
Registered: Aug 2005
Posts: 8

Original Poster
Rep: Reputation: 0
Thank you so much. I love Linux And of course the people that help the noobs with it
 
Old 03-27-2006, 06:27 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
no probs... maybe you'd like to give this opinion here... http://www.linuxquestions.org/questi...74#post2170274
 
Old 03-28-2006, 12:20 AM   #5
Fourthbean
LQ Newbie
 
Registered: Aug 2005
Posts: 8

Original Poster
Rep: Reputation: 0
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?
 
Old 03-28-2006, 01:52 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
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
 
  


Reply

Tags
iptables


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to allow range of hosts in Iptables irfanhab Linux - Security 2 01-14-2006 10:36 AM
Iptables - Group Of Hosts xathras Linux - Security 1 04-01-2005 02:56 PM
iptables and hosts.allow bwreath Linux - Security 2 02-25-2005 04:43 PM
iptables vs hosts.deny ryedunn Linux - Security 2 01-11-2005 07:56 PM
does the /etc/hosts file work same as the M$ hosts file? Lleb_KCir Linux - Software 6 04-03-2004 05:33 PM


All times are GMT -5. The time now is 04:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration