Fix UDP response source IP symmetry on multi-homed hosts#1739
Fix UDP response source IP symmetry on multi-homed hosts#1739IngmarStein wants to merge 1 commit intoTechnitiumSoftware:masterfrom
Conversation
|
Thanks for the PR. If you configure For DHCP server case of relay agents, the relay agent and the end client is expected to be able to reach the DHCP server via proper routing. So, this issue does not occur here as the server is expected to be able to route to the packet properly. |
There's a difference: this change also works with [::] or 0.0.0.0 as local endpoints - it'll select the right IP also in that case. Oh and as far as I know, all other major DNS implementation (BIND, Unbound, PowerDNS, dnsdist, Knot, …) use this approach. |
The code is searching for socket that is bound to the address in packet info. So that requires you to configure |
|
The |
|
Searching through the sockets is for completeness. The crucial part is setting the |
The PacketInformation is already being read with the |
d6be82b to
bce3fe7
Compare
|
So I think there are two concepts here:
They are related, but not the same. If 1) is set to specific addresses, then 2) is already solved - the source address is the same as the matching endpoint. However, 2) can also be solved when 1) is set to ANY - we just need to set the correct source address. https://blog.powerdns.com/2012/10/08/on-binding-datagram-udp-sockets-to-the-any-addresses has more details. |
|
Ya, this is an issue which would be good to solve to do away user needing to do additional config. Thanks for the link. Will read it and get back. |
This change enables the 'PacketInformation' socket option (IP_PKTINFO / IPV6_RECVPKTINFO) to capture the destination IP address of incoming DNS and DHCP UDP requests. The captured IPPacketInformation is then used to select the most appropriate socket for sending the response. On multi-homed hosts, if the server is bound to multiple specific IP addresses, this ensures that the response is sent from the exact same IP address that received the request, preventing clients from discarding the response due to IP mismatch. Summary: - Enabled PacketInformation socket options on UDP and DHCP listeners. - Captured IPPacketInformation using ReceiveMessageFromAsync. - Added logic to select a specifically-bound socket (if available) for the response to ensure source IP symmetry. - Updated SendToAsync calls to use ReadOnlyMemory<byte> for better performance.
bce3fe7 to
34129ab
Compare
This change enables the 'PacketInformation' socket option (
IP_PKTINFO/IPV6_RECVPKTINFO) to capture the destination IP address of incoming DNS and DHCP UDP requests. The captured IPPacketInformation is then used to select the most appropriate socket for sending the response.On multi-homed hosts, if the server is bound to multiple specific IP addresses, this ensures that the response is sent from the exact same IP address that received the request, preventing clients from discarding the response due to IP mismatch.
Summary: