I have a Node.JS application receiving UDP packets, which I have recently moved into a Docker container for easy deployment. The application relies on distinguishing multiple UDP streams based on the source IP (using rinfo.address on the 'message' event).

For some of these streams, the source IP is reported as, which is just the IP of the "outside" as seen from inside the Docker container.

How can I reliably get the actual origin IP of UDP packets inside a Docker container?

  • Check the firewall of the Docker host. In particular the nat table. – Michael Hampton Apr 14 '19 at 16:19

I found a solution - but my understanding of it is limited.

Running sudo conntrack -D -p udp in the host apparently resets something and allows for the real origin IP addresses to be reported.

Apparently this needs to be done after any restart of the container.

Credits: https://github.com/moby/moby/issues/8795#issuecomment-64946289

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.