Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Different A record for nodes with the same name #2121

Closed
2 of 4 tasks
nblock opened this issue Sep 10, 2024 · 2 comments · Fixed by #2127
Closed
2 of 4 tasks

[Bug] Different A record for nodes with the same name #2121

nblock opened this issue Sep 10, 2024 · 2 comments · Fixed by #2127
Assignees
Labels
bug Something isn't working
Milestone

Comments

@nblock
Copy link
Collaborator

nblock commented Sep 10, 2024

Is this a support request?

  • This is not a support request

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

While testing #1369 (comment), I noticed the following behavior:

Setup

  • Node with name laptop assigned to user alice : 100.64.0.2, fd7a:115c:a1e0::2
  • Node with name laptop assigned to user bob: 100.64.0.3, fd7a:115c:a1e0::3
  • Config:
    dns:
      use_username_in_magic_dns: false
      base_domain: tn.example.com
  • Content of /etc/resolv.conf on both nodes:
    nameserver 100.100.100.100
    search tn.example.com
    

On alice's node

alice:~$ tailscale ip
100.64.0.2
fd7a:115c:a1e0::2

alice:~$ dig +short laptop.tn.example.com
100.64.0.3

On bob's node

bob:~$ tailscale ip
100.64.0.3
fd7a:115c:a1e0::3

bob:~$ dig +short laptop.tn.example.com
100.64.0.2

You get a different IP depending on depending on where you ask. Interestingly, Tailscale resolves to the IP of the other node.

Expected Behavior

Not sure which IP address, but I'd expect to always get the same one.

Steps To Reproduce

  • Create two users
  • Register a node for each user (using unique names, e.g. laptop for user alice and server for user bob)
  • Run: headscale nodes rename -i ID_OF_SERVER_BOB laptop
  • Node list:
$ headscale nodes list
ID | Hostname  | Name      | MachineKey | NodeKey | User  | IP addresses                  | Ephemeral | Last seen           | Expiration          | Connected | Expired
4  | laptop    | laptop    | [fLttA]    | [J2GVN] | alice | 100.64.0.2, fd7a:115c:a1e0::2 | false     | 2024-09-10 07:53:41 | 0001-01-01 00:00:00 | online    | no
5  | server    | laptop    | [BxUYW]    | [e4Bjc] | bob   | 100.64.0.3, fd7a:115c:a1e0::3 | false     | 2024-09-10 07:55:01 | 0001-01-01 00:00:00 | online    | no

Environment

- OS: Debian 12
- Headscale version: 0.23.0-beta.4
- Tailscale version: 1.72.1

Runtime environment

  • Headscale is behind a (reverse) proxy
  • Headscale runs in a container

Anything else?

No response

@nblock nblock added the bug Something isn't working label Sep 10, 2024
@kradalby kradalby self-assigned this Sep 11, 2024
@kradalby
Copy link
Collaborator

Ah, I can see there is no check to validate the uniqueness of the name in the rename.

one of the nodes gets a unique name if it is not renamed right?

@nblock
Copy link
Collaborator Author

nblock commented Sep 11, 2024

one of the nodes gets a unique name if it is not renamed right?

Yes, it looks like this when both join with the same hostname:

ID | Hostname  | Name            | MachineKey | NodeKey | User  | IP addresses                  | Ephemeral | Last seen           | Expiration          | Connected | Expired
6  | laptop    | laptop          | [SYCPl]    | [JKsUY] | alice | 100.64.0.4, fd7a:115c:a1e0::4 | false     | 2024-09-11 10:55:08 | 0001-01-01 00:00:00 | online    | no
7  | laptop    | laptop-klnwimod | [IcRoJ]    | [MjqjD] | bob   | 100.64.0.5, fd7a:115c:a1e0::5 | false     | 2024-09-11 10:55:10 | 0001-01-01 00:00:00 | online    | no

Probably a unique constraint will be required for the name column?

kradalby added a commit to kradalby/headscale that referenced this issue Sep 11, 2024
this commits moves the generation of "given names" of nodes
into the registration function, and adds validation of renames
to RenameNode using the same logic.

Fixes juanfont#2121

Signed-off-by: Kristoffer Dalby <[email protected]>
@kradalby kradalby added this to the v0.23.0 milestone Sep 11, 2024
kradalby added a commit to kradalby/headscale that referenced this issue Sep 30, 2024
* move logic for validating node names

this commits moves the generation of "given names" of nodes
into the registration function, and adds validation of renames
to RenameNode using the same logic.

Fixes juanfont#2121

Signed-off-by: Kristoffer Dalby <[email protected]>

* fix double arg

Signed-off-by: Kristoffer Dalby <[email protected]>

---------

Signed-off-by: Kristoffer Dalby <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants