← Back to Pull requests

Advertise only an IPv6-only server's own addresses behind NAT64 #3184

Closed
unknown closed this pull request without merging on Oct 23, 2026 05:24 UTC
View on GitHub
unknown unknown commented on Oct 23, 2026 03:28 UTC
Author

Summary

Behind NAT64, an IPv6-only server asked IPv4-only lookups for its public IP. The NAT64 gateway answered them, so the server advertised the gateway's IPv4 as its public IP and as a WireGuard endpoint (#3166).

 discover_network
+  ipv4_route = `ip -4 route get` 1.1.1.1 or 149.112.112.112 is not refused
+                                                            # refused: "Network is unreachable" or "No route to host"
+                                                            # anything else counts as a route, as before
   public IP lookup
-    api.ipify.org, ipinfo.io, ip-api.com                    # IPv4-only: answered via NAT64
+    with an IPv4 route:    the same three
+    without one:           api6.ipify.org only, and an IPv4 answer is dropped
 rediscover (every daemon start, for a server enrolled before this)
-  lookup found nothing → keep the stored public IP
+  lookup found nothing, no IPv4 route, stored IP is IPv4 → remove it   # it was the gateway's

DiscoveredNetwork.ipv4_route is in memory only. Nothing changes on the wire, in the Corrosion schema or in a stored format. A public IP removed this way goes through the existing PublicIpUpdate::Remove. A pinned public IP (server set --public-ip) is left alone.

The route check asks the kernel rather than reading the main table's default, so a policy-routing table or a 0.0.0.0/1 + 128.0.0.0/1 split (full-tunnel VPNs) still counts as an IPv4 route (review round 1). It probes one address in each half of IPv4, so a route refused to one destination doesn't read as having no IPv4 (review round 2).

#3167 is outside Ployz for Services. A Service Ployz deploys resolves through Ployz's DNS, which forwards to the host's IPv6 resolver. A container started with plain docker run on Docker's default network has only IPv4, so it reaches neither Docker's 8.8.8.8 nor any resolver you pass with --dns. docs/user/servers/add-a-server.md now says so and points to --network host or a Docker network with IPv6, in place of the known-issue note for both. Not covered here: BuildKit build steps run on their own IPv4 bridge, so on an IPv6-only server they have the same limit. That was already true before this PR.

DESIGN.md bets: none changed.

Fixes #3166
Fixes #3167

Evidence

  • Before: the tests fail on the old code.

  •   FAIL a_server_without_an_ipv4_route_asks_only_for_its_ipv6_address
      FAIL an_ipv4_answer_without_an_ipv4_route_is_a_nat64_gateways
      FAIL a_server_without_an_ipv4_route_drops_the_ipv4_public_ip_it_stored
        left: PublicIpLookupFailed   right: Updated(… public_ip: None …)
      

    After: they pass, with every rediscover_tests and network::endpoints test (14), including only_a_refused_route_lookup_means_no_ipv4_route and one_refused_destination_is_not_a_missing_ipv4_route. Clippy is clean.

  • Route check, network namespace with IPv4 but no main-table default:

  •                           old: ip -4 -json route show default    new: ip -4 route get 1.1.1.1
      policy table 100        []  → "no IPv4 route" (wrong)          1.1.1.1 via 192.0.2.1 table 100, exit 0
      0.0.0.0/1 + 128.0.0.0/1 []  → "no IPv4 route" (wrong)          1.1.1.1 via 192.0.2.1, exit 0
      default + unreachable 1.1.1.1/32                               1.1.1.1 refused, 149.112.112.112 exit 0 → route
      IPv6-only lab VM                                               both: Network is unreachable, exit 2
      

  • Live, Incus, IPv6-only VM behind NAT64/DNS64 (fix-2837's lab: tayga NAT64 on 64:ff9b::/96, unbound DNS64). The VM has only a ULA IPv6 address and no IPv4 route. Gateway address replaced with a documentation one.

  •   v0.3.1, ployz server add --standalone
        public ip = 203.0.113.7                      ← the NAT64 gateway's egress
        endpoints = [fd64:2890::10]:51820, 203.0.113.7:51820
      this branch's ployzd (with the kernel route check), same server, restart
        INFO rediscovered this Machine's addresses public_ip=None advertised_endpoints=[[fd64:2890::10]:51820]
        public ip = -
        endpoints = [fd64:2890::10]:51820
      

    The VM has no global IPv6, so api6.ipify.org can't reach it and it has no public IP. That's correct: nothing outside can reach it either.

    #3167 on the same VM:

      docker run alpine nslookup github.com                  → nameserver 8.8.4.4, times out
      docker run --dns fd64:2890::1 alpine nslookup …        → Network unreachable
      docker run --network host alpine nslookup github.com   → 64:ff9b::… (DNS64)
      ployz exec probe -- nslookup github.com                → via 127.0.0.11: github.com has 64:ff9b::… (DNS64), exit 0
      

    Merge Danger

    Door: two-way

    A revert restores the old lookup. A public IP this removed on an IPv6-only server would come back on the next rediscovery after a revert.

    Blast Radius: addresses

    Only servers with no IPv4 default route change: they stop advertising an IPv4 they don't own. Dual-stack and IPv4 servers make the same lookups as before.

    Diff: 626 lines (+469 / -157) across 7 files Reviewer: nick-potts Review duration: 116m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.50) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 626 lines diff across 7 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.385
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3184"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 50.3% (MEDIUM) · Higher = larger blast radius
    50.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21.8% · Safe to merge
    21.8%
    Repository