0

Similar to How to set source address when sending using and UDP socket, but not identical:

I'm writing an experimental UDP packet relay. The code works so far, but the problem is that the relayed packets have the address and port of the relay (instead of the original sender) as sending address in the outgoing packets, so any responses would also go to the relay, and not to the original sender.

Is there a standard way (without manipulating the packets directly) to do this? Currently it has to work for IPv4 only.

U. Windl
  • 3,480
  • 26
  • 54
  • Isn't it generally desirable to have the traffic go through your relay? Otherwise, if you're doing some sort of transparent proxying, you might want to read about the sockopt `IP_TRANSPARENT`/TPROXY, and/or delve into raw/packet sockets. – Hasturkun Oct 25 '21 at 14:57
  • It would be a asymmetric relay: Responses should bypass it. Raw sockets would require to go down to the packet level which I'd like to avoid. So with `IP_TRANSPARENT` I'd have to re-bind the socket before each response, or would I have to create a completely new socket? – U. Windl Oct 28 '21 at 06:07

0 Answers0