Howto force Nginx resolver to use new source UDP port

jeanpaul nginx-forum at
Thu Nov 17 10:17:06 UTC 2022

We're using Nginx as ingress controller in a Kubernetes environment. Nginx
uses a DNS service inside k8s with 1 single service-IP and multiple DNS PODs
behind that.

The translation from service-IP to any of the multiple DNS PODs is done via
DNAT rules.

The problem:
- Nginx establishes an UDP 'connection' on for example localIP
source-port 12345 towards serviceIP
- DNAT translates this as sourceport 12345 towards any DNS-POD; for example
- If DNS-POD terminates Nginx is not aware of this because of the
'connection' towards serviceIP
- Nginx will send all future DNS request using the same tuple of
serviceIP:sourcePort, so ->
- This will result in a timeout because the destination POD isn't there

Is it possible to force Nginx to use different source UDP ports every X
seconds, of after a timeout?

Posted at Nginx Forum:,295794,295794#msg-295794

More information about the nginx mailing list