netbirdio / netbird

Connect your devices into a secure WireGuard®-based overlay network with SSO, MFA and granular access controls.
https://netbird.io
BSD 3-Clause "New" or "Revised" License
10.78k stars 487 forks source link

DNS cannot be scoped to TLD #2021

Open ednxzu opened 4 months ago

ednxzu commented 4 months ago

Describe the problem

Netbird currently does not allow you to pass a top level domain to resolve.

Example: one cannot have a match domain scoped to consul., that would allow to resolve anything under *.consul

I believe this is only a GUI issue in the dashboard, and the feature should (???) work, it just cannot be set because of some UI input filter.

To Reproduce

Steps to reproduce the behavior:

  1. Go to DNS settings
  2. Try adding a domain match that is a TLD (com, fr, eu, etc..)

Expected behavior

match domain should support TLD scope

Are you using NetBird Cloud?

No

NetBird version

0.27.3

pascal-fischer commented 4 months ago

Hi @ednxzu, yes that seems to be a limitation of the front end right now. We are going to fix that. Till then if you need this earlier you can try setting the domain by calling the API directly.

taylorwilsdon commented 4 months ago

Hey @pascal-fischer, also very curious about this one but I tried via api (route /api/dns/nameservers/{nameserverid}) and when including any of the following:

consul .consul consul.

in the body payload under "domains", it will return a 422 (Unprocessable content) - if you change that to abc.consul with nothing else different it goes through. The message in the response is: {"message":"nameserver group got an invalid domain: consul \"domain should consists of only letters, numbers, and hyphens with no leading, trailing hyphens, or spaces\"","code":422}

So it does appear the same format checks present in the UI are also present in the backend. The regex used to dictate this is declared here: https://github.com/netbirdio/netbird/blob/main/management/server/nameserver.go#L17

You can confirm at regex101.com that for the current regular expression ^(?i)[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,}$ the test string "consul.com" validates but simply "consul" or "consul." does not.

pascal-fischer commented 4 months ago

Ah you are right, my bad. Then we need to update and test this on the backend as well.