Skip to content

feat(gateway): deprecate the NAT64 module - #8383

Merged
thomaseizinger merged 9 commits into
mainfrom
chore/feature-flag-icmp-error
Mar 27, 2025
Merged

feat(gateway): deprecate the NAT64 module#8383
thomaseizinger merged 9 commits into
mainfrom
chore/feature-flag-icmp-error

Conversation

@thomaseizinger

@thomaseizinger thomaseizinger commented Mar 7, 2025

Copy link
Copy Markdown
Member

At present, the Gateway implements a NAT64 conversion that can convert IPv4 packets to IPv6 and vice versa. Doing this efficiently creates a fair amount of complexity within our ip-packet crate. In addition, routing ICMP errors back through our NAT is also complicated by this because we may have to translate the packet embedded in the ICMP error as well.

The NAT64 module was originally conceived as a result of the new stub resolver-based DNS architecture. When the Client resolves IPs for a domain, it doesn't know whether the domain will actually resolve to IPv4 AND IPv6 addresses so it simply assigns 4 of each to every domain. Thus, when receiving an IPv6 packet for such a DNS resource, the Gateway may only have IPv4 addresses available and can therefore not route the packet (unless it translates it).

This problem is not novel. In fact, an IP being unroutable or a particular route disappearing happens all the time on the Internet. ICMP was conceived to handle this problem and it is doing a pretty good job at it. We can make use of that and simply return an ICMP unreachable error back to the client whenever it picks an IP that we cannot map to one that we resolved.

In this PR, we leave all of the NAT64 code intact and only add a feature-flag that - when active - sends aforementioned ICMP error. While offline (and thus also for our tests), the feature-flag evaluates to false. It is however set to true in the backend, meaning on staging and later in production, we will send these ICMP errors.

Once this is rolled out and indeed proving to be working as intended, we can simplify our codebase and rip out the NAT64 module. At that point, we will also have to adapt the test-suite.

@vercel

vercel Bot commented Mar 7, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
firezone ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 27, 2025 0:39am

@thomaseizinger

Copy link
Copy Markdown
Member Author

@jamilbk I tested this locally with the compose setup and github.com. Trying to clone over SSH by forcing IPv6 did not work and instantly failed with a "Network unreachable" error. This shows that SSH can correctly decode our ICMP error and will fall back to IPv4 in a happy-eyeballs scenario.

@thomaseizinger thomaseizinger changed the title chore(connlib): send ICMP unreachable instead of NAT64 feat(gateway): deprecate the NAT64 module Mar 24, 2025
Comment thread rust/connlib/tunnel/src/peer.rs Outdated
Comment on lines +454 to +460
// TODO: Should we use the source IP of the packet?
let icmp_error = match dst {
IpAddr::V4(inside_dst) => icmpv4_unreachable(inside_dst, self.client_tun.v4, packet)?,
IpAddr::V6(inside_dst) => icmpv6_unreachable(inside_dst, self.client_tun.v6, packet)?,
};

Ok(TranslateOutboundResult::DestinationUnreachable(icmp_error))

@jamilbk jamilbk Mar 26, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, yeah I would think you want the source address here to be the Gateway's tunnel IP address right? That's the "sender" after all.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point, I'll try and see if that works.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep works but doesn't make a difference in my testing.

Comment thread rust/connlib/tunnel/src/peer.rs Outdated
@thomaseizinger
thomaseizinger added this pull request to the merge queue Mar 27, 2025
Merged via the queue into main with commit 19c5bc5 Mar 27, 2025
@thomaseizinger
thomaseizinger deleted the chore/feature-flag-icmp-error branch March 27, 2025 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants