Skip to content

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

Description

@gene1wood

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions