LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-22-2010, 05:49 PM   #1
wooly
LQ Newbie
 
Registered: Nov 2010
Posts: 4

Rep: Reputation: 0
Traffic redirection using iptables


Hi, I have a portable pad device that is hardcoded to "call home" on startup and check for updates, if found they are downloaded. For arguments sake lets say the pad trys to connect to getmyupdate.com which equates to 111.111.111 as the IP address.

When the pad starts up I would like it to connect to gethackedupdate.com which equates to 222.222.222 as the IP address.

I am using a linux based router.
Using the following command within the router:

iptables -t nat -I PREROUTING -d 111.111.111 -j DNAT --to 222.222.222

I can issue a connect command to 111.111.111 from a computer and be connected to 222.222.222, which is fine as the rerouting took place, but when I use the command:

iptables -t nat -I PREROUTING -d getmyupdate.com -j DNAT --to 222.222.222

a connection to getmyupdate.com still goes to 111.111.111 i.e. no rerouting took place.

Can any one assist in getting me on th right track to being able to get a connection to getmyupdate.com to be rerouted to 222.222.222
 
Old 11-22-2010, 07:58 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
My apologies; the jail-breaking of pads per se
is legal; using the broken pad to get commercial
software for free is not. I was a bit overzealous,
and made a mistake.


Cheers,
Tink

Last edited by Tinkster; 11-22-2010 at 11:08 PM.
 
Old 11-22-2010, 11:24 PM   #3
wooly
LQ Newbie
 
Registered: Nov 2010
Posts: 4

Original Poster
Rep: Reputation: 0
Hi Tink, thanks for re-opening the thread. I sent a second PM explaining in more detail, I guess I was writing that at the same time you posted your latest message.

Hopefully someone can help me out with my question

Wooly
 
Old 11-23-2010, 12:17 AM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Just looking at the rule I'd say it should work, but... Did you check
whether myupdate.com translates to more than one address? I'm not
sure what iptables would do in that case... Also, it's not necessarily
a good idea to use names (just because of the time it may take on
start for iptables to do the look-ups).


Cheers,
Tink
 
Old 11-23-2010, 09:27 AM   #5
wooly
LQ Newbie
 
Registered: Nov 2010
Posts: 4

Original Poster
Rep: Reputation: 0
Hi,
myupdate.com does only translate to one address, but my thinking was (and heres the real ignorant part ..maybe)that when the pad sends the traffic it will have a header with myupdate.com as the destination, therefore the iptables entry would need to capture myupdate.com rather than 111.111.111.111 ???

If I enter myupdate.com into the iptables rule, and then go to view the rule myupdate.com has been replaced with an ip address that in no way resembles the correct ip address.

Having just written that, a light may have clicked on ..... even if I put the "longhand" address in the rule it will be translated, therefore just put in the correct ipaddress.

Sorry for the ramblings, thinking as I type!!!

Will try it later today

Wooly
 
Old 11-23-2010, 11:28 AM   #6
jwl17330536
Member
 
Registered: Feb 2010
Location: Raleigh, NC
Posts: 83

Rep: Reputation: 22
I may have completely missed something, but couldn't you accomplish what you want by changing the /etc/hosts file on the linux based router?

Add a line for "getmyupdate.com" with the IP of where you want it to actually get the update from... 222.222.222 in the example above I believe.
 
Old 11-23-2010, 01:21 PM   #7
smart_shell
Member
 
Registered: May 2009
Location: NYC
Distribution: Ubuntu 10.04 LTS
Posts: 52

Rep: Reputation: 0
Quote:
Originally Posted by wooly View Post
Hi, I have a portable pad device that is hardcoded to "call home" on startup and check for updates, if found they are downloaded. For arguments sake lets say the pad trys to connect to getmyupdate.com which equates to 111.111.111 as the IP address.

When the pad starts up I would like it to connect to gethackedupdate.com which equates to 222.222.222 as the IP address.

I am using a linux based router.
Using the following command within the router:

iptables -t nat -I PREROUTING -d 111.111.111 -j DNAT --to 222.222.222

I can issue a connect command to 111.111.111 from a computer and be connected to 222.222.222, which is fine as the rerouting took place, but when I use the command:

iptables -t nat -I PREROUTING -d getmyupdate.com -j DNAT --to 222.222.222

a connection to getmyupdate.com still goes to 111.111.111 i.e. no rerouting took place.

Can any one assist in getting me on th right track to being able to get a connection to getmyupdate.com to be rerouted to 222.222.222
The domain names of the resolv only once - when you add rules to the chain. Subsequently, corresponding to this name IP-address may change.
 
Old 11-23-2010, 08:29 PM   #8
wooly
LQ Newbie
 
Registered: Nov 2010
Posts: 4

Original Poster
Rep: Reputation: 0
Fixed!

So, the rule did work. The problem was the one that Tinks raised. The domain name did in fact translate to more than one address, so I put an entry into iptables for each of the translations.

I had no success with modifying /etc/hosts file, not sure why as it seemed an reasonable solution.

Thanks all for the help

Wooly
 
  


Reply


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
iptables redirection rexjenny Linux - Networking 2 03-26-2010 09:55 AM
[HELP] redirect traffic to spesific port based on Traffic Content using iptables summersgone Linux - Server 2 06-22-2009 12:26 PM
traffic redirection issue guillermo Linux - Networking 4 08-04-2008 05:20 PM
iptables redirection mallikk_in Linux - Networking 11 09-02-2007 02:00 AM
Intranet traffic restriction/redirection pircio Linux - Networking 2 02-17-2005 10:24 AM


All times are GMT -5. The time now is 06:23 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration