redirect local traffic to another local IP. ?iptables
Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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!
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.
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:
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:
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.