DynDNS: Automatic External IP Tracking & Periodic Host Resolution #724
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Discussion Invitation
This PR proposes adding a DynDNS-based external IP tracking fallback to complement (or replace when unavailable) UPnP-based discovery. It's aimed at improving inbound reachability for home users who disable UPnP but rely on static/manual port forwarding plus a dynamic DNS hostname. Feedback on ergonomics, defaults, naming, and refresh strategy is welcome before finalizing. Also checkout PR #2
Summary
Introduces an optional DynDNS resolver service that periodically resolves a user-specified hostname and updates the node’s advertised external address (
best_local_address) when the underlying WAN IP changes. If UPnP successfully yields a public external IP, DynDNS is skipped. If UPnP is disabled or produces no routable address, the DynDNS path performs:DynDnsExtendertask that refreshes on an adaptive interval (min→exponential backoff up to max) and notifies registered sinks upon change.The result: nodes behind manually forwarded routers (with UPnP off) can automatically keep their advertised address current without restarts when their ISP-assigned IP updates.
Motivation
Problem: Many home operators disable UPnP but still forward a port manually and operate behind a dynamic WAN IP served via an ISP or consumer router. Previously:
--externalip, the node could fail to advertise a valid routable address if interface auto-discovery yielded none.--externalip), future WAN IP rotations (DHCP/PPPoE lease renewal) required manual restarts to propagate the new address.Goal: Seamless external IP lifecycle management when UPnP is unavailable, leveraging an operator’s existing DynDNS hostname.
Key Changes
DynDnsExtender.try_initial_dyndns_resolve) if UPnP not active and a hostname is configured; prefers IPv4 inAutomode.set_best_local_addressalready used by both UPnP and DynDNS flows.ExternalIpChangeSinksubscribers (unchanged pattern) reused for DynDNS notifications.components/addressmanager/src/dyndns_extender.rs)IpVersionMode(Ipv4|Ipv6|Auto with IPv4 preference).on_external_ip_changed(new, old)).--external-dyndns-host=<HOSTNAME>--external-dyndns-min-refresh-sec=<N>(default 30)--external-dyndns-max-refresh-sec=<N>(default 300)--external-dyndns-ip-version=<auto|ipv4|ipv6>(default auto; auto prefers IPv4 if present)--disable-upnpand--disable-ipv6-interface-discoverycontinue to apply.IpVersionMode.AddressManager::new, wiring (if present) the dyn DNS extender service similarly to the UPnP extender (service start handled elsewhere in lifecycle).Behavior
Decision tree:
--disable-ipv6-interface-discovery).best_local_addressupdated (retains port from existing best or default P2P port).ExternalIpChangeSinks notified asynchronously (fire-and-forget).Configuration
Examples:
IPv6-only preference:
Force IPv4 only:
IP Selection Logic
Given resolved set R (filtered to publicly routable):
No persistence of multiple candidates—single best address advertised.
Testing / Verification Suggestions
Manual:
[AddrMan] UPnP extender active; DynDNS skipped.Initial DynDNS external IP set....--external-dyndns-ip-version=ipv6with dual-stack host:--disable-ipv6-interface-discoverywith only IPv6 routable interface + DynDNS providing IPv4:Limitations / Future Work
ToSocketAddrs(blocking DNS semantics) for the initial single resolve; background loop also synchronous per cycle—could offload to dedicated async DNS (e.g. trust-dns) if needed.Backward Compatibility
Operational Guidance
--externalipcan continue; DynDNS is optional and may reduce manual maintenance.Authorship Note
This description was drafted with AI assistance and reviewed by the author (p4bpj) to ensure accuracy of the represented changes.