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

Closed
opened 2025-12-29 02:24:01 +01:00 by adam · 2 comments
Owner

Originally created by @nblock on GitHub (Sep 10, 2024).

Originally assigned to: @kradalby on GitHub.

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 https://github.com/juanfont/headscale/issues/1369#issuecomment-2339901185, 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

Originally created by @nblock on GitHub (Sep 10, 2024). Originally assigned to: @kradalby on GitHub. ### Is this a support request? - [X] This is not a support request ### Is there an existing issue for this? - [X] I have searched the existing issues ### Current Behavior While testing https://github.com/juanfont/headscale/issues/1369#issuecomment-2339901185, 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: ```yaml 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 ```bash 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 ```bash 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 ```markdown - 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_
adam added the bug label 2025-12-29 02:24:01 +01:00
adam closed this issue 2025-12-29 02:24:01 +01:00
Author
Owner

@kradalby commented on GitHub (Sep 11, 2024):

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?

@kradalby commented on GitHub (Sep 11, 2024): 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?
Author
Owner

@nblock commented on GitHub (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?

@nblock commented on GitHub (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?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#788