socat udp packet forwarding with source address
Socat is a proxy, which means that it makes connections to a port/service/etc on behalf of something else. This means that from the perspective of your service, the connection originates with socat. There is in general no easy way to work around this behavior.
Linux does have "transparent proxy" support, but this requires explicit support in your proxy application and a quick search did not reveal anything that would work with UDP traffic.
Using iptables to redirect traffic would provide a cleaner solution.
Related videos on Youtube
![Rade_303](https://i.stack.imgur.com/mucWX.jpg?s=256&g=1)
Rade_303
programmer, musician, gamer (indies and oldies) JFreeChart is one of the most poorly written Java libraries I have ever worked with :(
Updated on September 18, 2022Comments
-
Rade_303 almost 2 years
I am trying to use socat (instead of iptables) for UDP port forwarding. I just need to redirect some traffic from UDP port 162 to 33162.
I am using something like this:
socat udp-listen:162,pktinfo,fork UDP:localhost:33162
The trouble is that in the app that is listening on port 33162 as the source address I see
127.0.0.1
, which is not desireable. I would like the traffic to keep its source address.Is this possible with socat?
-
Rade_303 about 9 yearsMy own googling led me to conclusion that this is correct and only answer. Unfortunately I have issues with iptables design which cannot be overcome easily. I might post a question concerning my difficulties with iptables, but currently there is no easy solution for the requirements and limitations I'm facing.
-
user2751502 about 9 yearsIf you do post a new question, feel free to tag me on it -- I'm curious what the complications are that prevent an iptables solution.