-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong source IP for UDP replies #177
Comments
This fixes an issue when phantun may choose a source IP different from the destination IP in the incoming packet. Closes dndx#177
This fixes an issue when phantun may choose a source IP different from the destination IP in the incoming packet. Closes dndx#177
Can you create a NAT rule to help Phantun SNAT to the correct source address? Phantun does not have any ability to track dynamically changing IPv6 address yet nor does it understands IPv6 privacy extension. |
Not really? If remote peer does use our temporary address then phantun should reply from the same address. I don't think it's possible to express that in netfilter. I'm pretty sure replies that originate from the wrong source would be considered a new conntrack entry.
My proposed fix (#178) is not about tracking anything. It's about replying using the same source address as remote UDP peer used as destination to contact us. |
This fixes an issue when phantun may choose a source IP different from the destination IP in the incoming packet. Closes dndx#177
Happy New Year! 🎄
Suppose I have a WireGuard interface configured like this:
The endpoint host/port pair is a phantun client. The host IP is a stable IPv6 address derived from the MAC address, and doesn't change.
When WireGuard does the handshake, we get this sequence of packets:
Note that the phantun client uses a different IP address for replies. Instead of
${PREFIX}:${EUI64}
it uses${PREFIX}:${TMP}
.It doesn't immediately break WireGuard, as it's tolerant to address changes, and simply updates the endpoint address to
${PREFIX}:${TMP}
and goes on.However, phantun keeps using this
TMP
addresses forever.See, the
TMP
is a temporary IPv6 address generated by the privacy extensions. These addresses are periodically rotated. Here is except fromip address
output:The address will become invalid after a week, and the connection will cease functioning.
I think we need to remember the destination IP on which UDP packet initially arrived, and use this IP as source. This is somewhat complicated, as it needs
IP_PKTINFO
sockopt to retrieve it, and then abind
call to set it. See, for example, quic-go fixing the same problem.We could let the kernel choose the source IP for every packet instead by forgoing
connect
and replacing it withbind
+sendto
, but even then it may break in some scenarios. If WireGuard connection becomes idle for a week, the peer may remember the old temporary address and never get an updated one before the old one becomes invalid.The text was updated successfully, but these errors were encountered: