[PR #5905] DNS-aware dial for HTTP reverse proxy — use NetBird nameservers for hostname resolution #24281

Open
opened 2026-08-05 06:08:30 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/5905
Author: @aturkenov
Created: 4/16/2026
Status: 🔄 Open

Base: mainHead: feature/internal-reverse-proxy


📝 Commits (1)

  • 4cb8a42 [proxy] Implement DNS resolution for dial context in NetBird client for custom domains in target reverse proxy

📊 Changes

6 files changed (+130 additions, -1 deletions)

View changed files

📝 client/embed/embed.go (+11 -0)
📝 client/internal/dns/mock_server.go (+4 -0)
📝 client/internal/dns/server.go (+7 -0)
📝 client/internal/engine.go (+16 -0)
proxy/internal/roundtrip/dns.go (+91 -0)
📝 proxy/internal/roundtrip/netbird.go (+1 -1)

📄 Description

Problem

The HTTP reverse proxy transport (dialWithDNSResolution in dns.go) was a stub. As a result, target URLs that contained hostnames (e.g. https://myapp.netbird.cloud/) could not be dialled — only literal IP addresses worked. Users wanting to forward traffic to a domain couldn't do so through a resource group or peer proxy target.

Solution

Route hostname resolution through NetBird's own DNS infrastructure (custom zones, nameserver groups configured in the management UI) instead of the host-OS resolver or a hardcoded list of DNS servers.

The embedded NetBird client already runs an internal DNS server (bound to the last IP of the WireGuard network on port 53 in netstack/userspace mode). This server already knows about all NetBird-managed zones and upstream nameserver groups. We now query it directly during each dial that involves a hostname.

current state:
image

expected result:
image

Summary by CodeRabbit

Release Notes

  • New Features
    • Added DNS server address and port retrieval capabilities to the client.
    • Enhanced network operations with automatic hostname resolution that uses the NetBird DNS server when available and falls back to the system default resolver.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/5905 **Author:** [@aturkenov](https://github.com/aturkenov) **Created:** 4/16/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feature/internal-reverse-proxy` --- ### 📝 Commits (1) - [`4cb8a42`](https://github.com/netbirdio/netbird/commit/4cb8a42d4b7b103df7f5e720f1d9670eea83837e) [proxy] Implement DNS resolution for dial context in NetBird client for custom domains in target reverse proxy ### 📊 Changes **6 files changed** (+130 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `client/embed/embed.go` (+11 -0) 📝 `client/internal/dns/mock_server.go` (+4 -0) 📝 `client/internal/dns/server.go` (+7 -0) 📝 `client/internal/engine.go` (+16 -0) ➕ `proxy/internal/roundtrip/dns.go` (+91 -0) 📝 `proxy/internal/roundtrip/netbird.go` (+1 -1) </details> ### 📄 Description ### Problem The HTTP reverse proxy transport (`dialWithDNSResolution` in dns.go) was a stub. As a result, target URLs that contained **hostnames** (e.g. `https://myapp.netbird.cloud/`) could not be dialled — only literal IP addresses worked. Users wanting to forward traffic to a domain couldn't do so through a resource group or peer proxy target. ### Solution Route hostname resolution through NetBird's **own DNS infrastructure** (custom zones, nameserver groups configured in the management UI) instead of the host-OS resolver or a hardcoded list of DNS servers. The embedded NetBird client already runs an internal DNS server (bound to the last IP of the WireGuard network on port 53 in netstack/userspace mode). This server already knows about all NetBird-managed zones and upstream nameserver groups. We now query it directly during each dial that involves a hostname. current state: <img width="680" height="608" alt="image" src="https://github.com/user-attachments/assets/9f592903-5578-45fa-ba9d-2945d5f8c319" /> expected result: <img width="680" height="608" alt="image" src="https://github.com/user-attachments/assets/95deed94-37fa-4017-af6c-4d2539d2aa4a" /> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **New Features** * Added DNS server address and port retrieval capabilities to the client. * Enhanced network operations with automatic hostname resolution that uses the NetBird DNS server when available and falls back to the system default resolver. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 06:08:30 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#24281