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, which is not desireable. I would like the traffic to keep its source address.

Is this possible with socat?


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.

  • My 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. – Rade_303 Jun 11 '15 at 10:36
  • 1
    If 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. – larsks Jun 11 '15 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.