LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 07-29-2014, 02:03 PM   #1
jschwalbe
LQ Newbie
 
Registered: Jul 2014
Posts: 3

Rep: Reputation: Disabled
redirect local traffic to another local IP. ?iptables


Greetings.

I'm trying to redirect (actually, capture) traffic from one internal device to another. They are all on the same network, which is run by a dd-wrt router. I was working with DNSMasq (which allowed me to set the Gateway to my proxy server and collect externally destined traffic), but I wasn't able to catch info between the two devices.

From the router I tried a few iptables commands, namely:
iptables -A PREROUTING -s 192.168.10.130 -p tcp -j DNAT --to-destination 192.168.15.134
iptables -A PREROUTING -d 192.168.10.114 -p tcp -j DNAT --to-destination 192.168.15.134
iptables -A PREROUTING -d 192.168.10.114 -p tcp -j DNAT --to-destination 192.168.15.134 -t nat
without any success.

192.168.10.130 = a device trying to connect to another device, the handshake I'd like to catch.
192.168.10.114 = the second device, to which it is communicating
192.168.10.134 = my personal computer with a proxy set up (could use nc instead but mitmproxy works well for most things)

The ports I believe the two devices to talk on are 8080, 9000 and 10000.

Any suggestions on how to redirect all internal traffic from 192.168.10.130 to 192.168.10.134? Many thanks!
 
Old 07-29-2014, 03:24 PM   #2
mcresist
LQ Newbie
 
Registered: Jun 2014
Location: Michigian
Distribution: CentOS5/6/7
Posts: 19

Rep: Reputation: 3
Howdy,

Quote:
Any suggestions on how to redirect all internal traffic from 192.168.10.130 to 192.168.10.134? Many thanks!
I believe you are missing a rule that allows FORWARDING

See: http://www.fclose.com/816/port-forwa...sing-iptables/

Try something like this:

Code:
iptables -A PREROUTING -s 192.168.10.130 -p tcp -j DNAT --to-destination 192.168.10.134
iptables -A FORWARD -p tcp -d 192.168.10.134 -j ACCEPT
Hope this helps.
 
Old 07-30-2014, 10:40 AM   #3
jschwalbe
LQ Newbie
 
Registered: Jul 2014
Posts: 3

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by mcresist View Post
Hope this helps.
Thank you for your time on this, and also the link to read up on. Unfortunately that did not solve my problem. I tried it with another device as well, without any success.
 
Old 07-30-2014, 11:31 AM   #4
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
Maybe your router has a hardware switch which directly send packets to another port. Can you specify which router it is and how these computers are connected to it? You can log traffic and see if anything is going by your router by:
Code:
iptables -t raw -I PREROUTING -s 192.168.10.130 -j LOG
By the way, if you use NAT, rules should go to "nat" table, like:
Code:
iptables -t nat -A PREROUTING -s 192.168.10.130 -p tcp -j DNAT --to-destination 192.168.15.134

Last edited by eSelix; 07-30-2014 at 11:33 AM.
 
Old 07-30-2014, 02:38 PM   #5
jschwalbe
LQ Newbie
 
Registered: Jul 2014
Posts: 3

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by eSelix View Post
Maybe your router has a hardware switch which directly send packets to another port. Can you specify which router it is and how these computers are connected to it? You can log traffic and see if anything is going by your router by:
Code:
iptables -t raw -I PREROUTING -s 192.168.10.130 -j LOG
By the way, if you use NAT, rules should go to "nat" table, like:
Code:
iptables -t nat -A PREROUTING -s 192.168.10.130 -p tcp -j DNAT --to-destination 192.168.15.134
eSelix, thanks for the help. The above commands DID indeed work, specifically when I added 'iptables -t nat -A POSTROUTING -j MASQUERADE' to the mix. However, it only worked for traffic destined OUT of my network. It appears the devices don't care what iptables has to say about them communicating with eachother. Unless there is a rule explicitly stating that they can freely communicate..? Guess I'm not well enough versed in iptables to know that answer. Happy to run and copy/paste a command if that might shed more light.

As far as my equipment: bare bones. Run of the mill Linksys E1200 wireless router, with 4 LAN + 1 WAN port, but it is running dd-wrt.
 
  


Reply



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
Redirect traffic from local ip address to another local ip rbaker Linux - Networking 1 03-11-2014 05:03 AM
iptables redirect local ip traffic roof-us Linux - Networking 3 12-07-2011 09:56 AM
[SOLVED] Iptables redirect from one local port to another dr_doom Linux - Networking 2 02-28-2011 10:19 PM
[SOLVED] iptables redirect : local to remote public host paziulek Linux - Networking 2 05-17-2010 02:34 PM
iptables loopback local traffic with masc? jfuerst Linux - Networking 1 03-22-2010 07:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:47 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
Open Source Consulting | Domain Registration