Unable to configure local resolver address and port using NB_DNS_RESOLVER_ADDRESS environment variable #1210

Open
opened 2025-11-20 05:26:03 -05:00 by saavagebueno · 0 comments
Owner

Originally created by @gene1wood on GitHub (Sep 3, 2024).

Describe the problem

I'd like to be able to run the pihole DNS server and Netbird on the same computer. I'm figuring that the best way to do this is to

This way netbird addresses resolve correctly, and all other addresses get sent onto Pihole.

My Netbird installation works and can set up the local netbird resolver on port 53 of the CGNAT IP.

My Ubuntu 22.04 server uses systemd. Netbird 0.28.9 launches via systemd and consumes environment variables out of /etc/sysconfig/netbird.

I've created an /etc/sysconfig/netbird file with the contents of

NB_DNS_RESOLVER_ADDRESS=127.0.0.1:5053
NB_LOG_LEVEL=debug

I've done this to try to get netbird's local resolver to listen not on port 53 but instead 5053. I'm figuring this would work as the --dns-resolver-address command line flag for the up command says that it

Sets a custom address for NetBird's local DNS resolver. If set, the agent won't attempt to discover the best ip and port to listen on. An empty string "" clears the previous configuration. E.g. --dns-resolver-address 127.0.0.1:5053 or --dns-resolver-address ""

I've confirmed that the /etc/sysconfig/netbird file is working because when I add the NB_LOG_LEVEL=debug line, the /var/log/netbird/client.log file begins logging debug information.

Netbird however continues to follow it's native logic for determining the local resolver address and port.

I know it's not following the NB_DNS_RESOLVER_ADDRESS environment variable because the logs show this

2024-09-04T00:52:54Z DEBG client/internal/dns/service_listener.go:69: starting dns on 100.105.159.203:53
2024-09-04T00:52:54Z DEBG client/internal/dns/file_unix.go:97: creating managed file /etc/resolv.conf
2024-09-04T00:52:54Z INFO client/internal/dns/file_unix.go:107: created a NetBird managed /etc/resolv.conf file with the DNS settings. Added 2 search domains. Search list: [netbird.cloud .]

And when I run lsof -i :53 it shows that netbird continues to listen on port 53

What am I overlooking that's preventing me from being able to override the DNS resolver address using the NB_DNS_RESOLVER_ADDRESS environment variable?

To Reproduce

Steps to reproduce the behavior:

  1. Install Netbird on an Ubuntu 22.04 system or any system that uses systemd
  2. Create an /etc/sysconfig/netbird file as described above to set the local resolver address and port to 127.0.0.1:5053
  3. Restart netbird by running systemctl restart netbird.service

Expected behavior

The logs should show that netbird's local resolver is listening on 127.0.0.1:5053 and when checking what ports the process has open, it should show 5053

Are you using NetBird Cloud?

Yes

NetBird version

0.28.9

NetBird status -dA output:

This is included in the output below from netbird debug for 1m -AS

Do you face any (non-mobile) client issues?

Please provide the file created by netbird debug for 1m -AS.

netbird.debug.3677564285.zip

Originally created by @gene1wood on GitHub (Sep 3, 2024). **Describe the problem** I'd like to be able to run the [pihole DNS server](https://pi-hole.net/) and Netbird on the same computer. I'm figuring that the best way to do this is to * Configure Netbird local resolver to listen on `5053` * Configure Pihole DNS server to listen on `53` * Configure [Netbird in the web UI to use a custom nameserver](https://docs.netbird.io/how-to/manage-dns-in-your-network#creating-custom-nameservers) of the local Pihole instance This way netbird addresses resolve correctly, and all other addresses get sent onto Pihole. My Netbird installation works and can set up the local netbird resolver on port 53 of the CGNAT IP. My Ubuntu 22.04 server uses `systemd`. Netbird 0.28.9 launches via `systemd` and consumes [environment variables out of `/etc/sysconfig/netbird`](https://docs.netbird.io/how-to/troubleshooting-client#on-linux-with-systemd). I've created an `/etc/sysconfig/netbird` file with the contents of ``` NB_DNS_RESOLVER_ADDRESS=127.0.0.1:5053 NB_LOG_LEVEL=debug ``` I've done this to try to get netbird's local resolver to listen not on port `53` but instead `5053`. I'm figuring this would work as the [`--dns-resolver-address` command line flag for the `up` command](https://docs.netbird.io/how-to/cli#up ) says that it > Sets a custom address for NetBird's local DNS resolver. If set, the agent won't attempt to discover the best ip and port to listen on. An empty string "" clears the previous configuration. E.g. --dns-resolver-address 127.0.0.1:5053 or --dns-resolver-address "" I've confirmed that the `/etc/sysconfig/netbird` file is working because when I add the `NB_LOG_LEVEL=debug` line, the `/var/log/netbird/client.log` file begins logging debug information. Netbird however continues to follow it's [native logic for determining the local resolver address and port](https://github.com/netbirdio/netbird/blob/v0.28.9/client/internal/dns/service_listener.go#L137-L163). I know it's not following the `NB_DNS_RESOLVER_ADDRESS` environment variable because the logs show this ``` 2024-09-04T00:52:54Z DEBG client/internal/dns/service_listener.go:69: starting dns on 100.105.159.203:53 2024-09-04T00:52:54Z DEBG client/internal/dns/file_unix.go:97: creating managed file /etc/resolv.conf 2024-09-04T00:52:54Z INFO client/internal/dns/file_unix.go:107: created a NetBird managed /etc/resolv.conf file with the DNS settings. Added 2 search domains. Search list: [netbird.cloud .] ``` And when I run `lsof -i :53` it shows that netbird continues to listen on port `53` What am I overlooking that's preventing me from being able to override the DNS resolver address using the `NB_DNS_RESOLVER_ADDRESS` environment variable? **To Reproduce** Steps to reproduce the behavior: 1. Install Netbird on an Ubuntu 22.04 system or any system that uses systemd 2. Create an `/etc/sysconfig/netbird` file as described above to set the local resolver address and port to `127.0.0.1:5053` 3. Restart netbird by running `systemctl restart netbird.service` **Expected behavior** The logs should show that netbird's local resolver is listening on `127.0.0.1:5053` and when checking what ports the process has open, it should show `5053` **Are you using NetBird Cloud?** Yes **NetBird version** `0.28.9` **NetBird status -dA output:** This is included in the output below from `netbird debug for 1m -AS` **Do you face any (non-mobile) client issues?** Please provide the file created by `netbird debug for 1m -AS`. [netbird.debug.3677564285.zip](https://github.com/user-attachments/files/16859666/netbird.debug.3677564285.zip)
saavagebueno added the waiting-feedbacktriage-needed labels 2025-11-20 05:26:03 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SVI/netbird#1210