-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
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
nixos/nebula: add CAP_NET_BIND_SERVICE when lighthouse node serves DNS #353665
base: master
Are you sure you want to change the base?
Conversation
4fdd4f0
to
51d1018
Compare
51d1018
to
3198924
Compare
@numinit I would appreciate your review on this 🙏 |
3198924
to
84e3439
Compare
@@ -210,6 +210,11 @@ in | |||
'' | |||
settings | |||
); | |||
capabilities = concatStringsSep " " ([ | |||
"CAP_NET_ADMIN" | |||
] ++ (optionals (settings.lighthouse.serve_dns or false) [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition should probably be:
let
nebulaPort = settings.listen.port;
dnsPort = if (settings.lighthouse.serve_dns or false) then settings.lighthouse.dns.port or -1 else -1;
in nebulaPort > 0 && nebulaPort < 1024 || dnsPort > 0 && dnsPort < 1024;
Do you mind adding services.nebula.networks.<name>.dns.{enable,port,host}
as well? The port should likely default to 5353 so we don't need the extra capability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably should still have this condition. If any port is < 1024 and > 0 we need CAP_NET_ADMIN.
May be worth updating the NixOS test too. |
84e3439
to
9715721
Compare
2ceb113
to
f77e832
Compare
Hey, thanks for taking this btw! Let me know if you need any help getting it across the finish line. |
f77e832
to
46f1429
Compare
Thanks :) Got it done and working well on my own nebula network. A bit stumped about how to extend the tests to cover this however, any help there is appreciated. |
73d2f99
to
d09287b
Compare
@@ -231,6 +249,10 @@ in | |||
'' | |||
settings | |||
); | |||
capabilities = lib.concatStringsSep " " ( | |||
(lib.optional (!settings.tun.disabled) "CAP_NET_ADMIN") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can get rid of the parens around (lib.optional ..) - ++ is higher precedence than the function call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, TIL
|
||
lighthouse.dns.port = lib.mkOption { | ||
type = lib.types.nullOr lib.types.port; | ||
default = 53; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe default this to something like 5353
For the tests, maybe make a |
d09287b
to
9259f5d
Compare
74887ed
to
34707a9
Compare
6edb421
to
40fa11c
Compare
|
||
lighthouse.dns.host = lib.mkOption { | ||
type = lib.types.str; | ||
default = "0.0.0.0"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better default is possibly localhost. This uses dial
under the hood so it should work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree localhost
is better as a "secure defaults" choice, so the default doesn't listen on public interfaces. The description may want a callout, though, or have an example value of some nebula address like "10.0.0.5".
NixOS tests all pass, looks good except for the above unless @Jaculabilis has any more changes. Thanks for the contribution! |
nixos/tests/nebula.nix
Outdated
@@ -338,6 +349,8 @@ import ./make-test-python.nix ( | |||
# allowAny can ping the lighthouse, but not allowFromLighthouse because of its inbound firewall | |||
allowAny.succeed("ping -c3 10.0.100.1") | |||
allowAny.fail("ping -c3 10.0.100.3") | |||
# allowAny can also resolve DNS on lighthouse | |||
allowAny.succeed("dig @10.0.100.1 allowToLighthouse") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dig
returns 0 if there's a NXDOMAIN. Recommend dig @10.0.100.1 allowToLighthouse | grep -E 'allowToLighthouse\.\s+[0-9]+\s+IN\s+A\s+10\.0\.100\.4'
(at least, I think that's how it will respond)
40fa11c
to
4aaac02
Compare
Respun with requested changes. Unable to run nixos tests at the moment to verify DNS grep, apologies. |
Indeed it works :-)
|
This looks good and should be fine to merge. |
Add the options: - lighthouse.serve_dns - lighthouse.dns.host - lighthouse.dns.port Improve systemd capabilities handling: - do not give CAP_NET_ADMIN when tunnel interface is disabled - give CAP_NET_BIND_SERVICE when DNS is enabled Add self as maintainer: I'm using Nebula on NixOS in prod. Signed-off-by: Sirio Balmelli <sirio@b-ad.ch>
Signed-off-by: Sirio Balmelli <sirio@b-ad.ch>
4aaac02
to
7a24b07
Compare
Serving DNS fails in the absence of CAP_NET_BIND_SERVICE.
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.