tailscale: fix broken DNS on IPv6 only tailnets#1246
tailscale: fix broken DNS on IPv6 only tailnets#1246nolith wants to merge 1 commit intonix-darwin:masterfrom
Conversation
|
oops i screwed up that review a little. anyway that's a minor nit and this otherwise looks good. I grepped for |
|
ack it won't let me leave an inline comment on an unchanged part of the file, but the comment on line 36 should be updated as well: |
b712f1c to
cc95d5c
Compare
|
Thank you all, I made all the suggested edit. I'll test it tomorrow on my other machine that is using this option. |
modules/services/tailscale.nix
Outdated
| config = mkIf cfg.enable { | ||
| assertions = [{ | ||
| assertion = !cfg.overrideLocalDns || config.networking.dns == [ "100.100.100.100" ]; | ||
| assertion = cfg.overrideLocalDns -> (builtins.elem config.networking.dns "100.100.100.100" || builtins.elem config.networking.dns "fd7a:115c:a1e0::53"); |
There was a problem hiding this comment.
| assertion = cfg.overrideLocalDns -> (builtins.elem config.networking.dns "100.100.100.100" || builtins.elem config.networking.dns "fd7a:115c:a1e0::53"); | |
| assertion = cfg.overrideLocalDns -> (builtins.any (x: x != "100.100.100.100" && x != "fd7a:115c:a1e0::53") config.networking.dns); |
There was a problem hiding this comment.
Hello, I'm not an expert of nix but I don't think this suggestion has the same behaviour of the existing implementation.
The original implementation was !cfg.overrideLocalDns || config.networking.dns == [ "100.100.100.100" ] and we are swapping it with an arrow operator.
b1 -> b2 == !b1 || b2
nix-repl> networking_dns = [ "100.100.100.100" "fd7a:115c:a1e0::53" ]
nix-repl> networking_dns == [ "100.100.100.100" "fd7a:115c:a1e0::53" ]
true
nix-repl> builtins.elem "100.100.100.100" networking_dns || builtins.elem "fd7a:115c:a1e0::53" networking_dns
true
nix-repl> builtins.any (x: x != "100.100.100.100" && x != "fd7a:115c:a1e0::53") networking_dns
false
nix-repl> builtins.elem "100.100.100.100" networking_dns && builtins.elem "fd7a:115c:a1e0::53" networking_dns
true
nix-repl> builtins.any (x: x != "100.100.100.100" || x != "fd7a:115c:a1e0::53") networking_dns
trueThere was a problem hiding this comment.
x != 5 || x != 6 is always true
The original condition we’re looking to verify is that at least one element in the list is neither 100.100.100.100 nor fd7a:115c:a1e0::53 so we want to use &&
There was a problem hiding this comment.
x != 5 || x != 6is always true
🤦
The original condition we’re looking to verify is that at least one element in the list is neither
100.100.100.100norfd7a:115c:a1e0::53so we want to use&&
But this is not what the original condition was doing !cfg.overrideLocalDns || config.networking.dns == [ "100.100.100.100" ].
If we analyse cfg.overrideLocalDns -> (builtins.any (x: x != "100.100.100.100" && x != "fd7a:115c:a1e0::53") config.networking.dns):
- when
cfg.overrideLocalDns == falsethe assertion returnstrue- same as before - when
cfg.overrideLocalDns == truewe return the result of(builtins.any (x: x != "100.100.100.100" && x != "fd7a:115c:a1e0::53") config.networking.dns), but this is checking a different condition compared toconfig.networking.dns == [ "100.100.100.100" ]. When using magicDNS you want to set a global nameserver in the admin panel, not adding another nameserver to/etc/resolv.conf. I think the original intention of thatassertionwas to make sure you are not adding an extra nameserver that may result in unexpected results depending on which server is selected for the resolution.
There was a problem hiding this comment.
hello @Enzime, what do you think of my last comment?
There was a problem hiding this comment.
@Enzime did you had any chance to read my comment?
I'd like to close this PR and get rid of the override in my flake.
cc95d5c to
8c73b37
Compare
When a tailnet has the disableIPv4 settings it will not deploy IPv4, resolving any ts.net address is broken because 100.100.100.100 is not reachable. https://tailscale.com/kb/1337/acl-syntax#disableipv4 Co-authored-by: Michael Hoang <Enzime@users.noreply.github.com> Co-authored-by: Sam <30577766+Samasaur1@users.noreply.github.com>
8c73b37 to
801e0cb
Compare
|
I'm pretty sure the intersection of nix-darwing users and tailscale users with an ipv6 only tailnet is very small (likely only myself). But dear reader, if you are like me, this is how I circumvented this bug without loading a forked flake of nix-darwin. |
When a tailnet has the disableIPv4 settings it will not deploy IPv4, resolving any ts.net address is broken because 100.100.100.100 is not reachable.
fd7a:115c:a1e0::53is the magic dns address for IPv6 tailnets.https://tailscale.com/kb/1337/acl-syntax#disableipv4