summary refs log tree commit diff
path: root/nixos/modules/system
diff options
context:
space:
mode:
authorAlexander Ried <ried@mytum.de>2016-06-26 22:58:04 +0200
committerFranz Pletz <fpletz@fnordicwalking.de>2016-06-26 22:58:04 +0200
commita31e07fc112c1c9b00b748a85f76a4c4c203a03d (patch)
tree0e9099965acfa9f7464dd7eee8920a1e36048b58 /nixos/modules/system
parent07cfc1553fca3f686be7fdd3ddaa07a0fc8e1503 (diff)
downloadnixlib-a31e07fc112c1c9b00b748a85f76a4c4c203a03d.tar
nixlib-a31e07fc112c1c9b00b748a85f76a4c4c203a03d.tar.gz
nixlib-a31e07fc112c1c9b00b748a85f76a4c4c203a03d.tar.bz2
nixlib-a31e07fc112c1c9b00b748a85f76a4c4c203a03d.tar.lz
nixlib-a31e07fc112c1c9b00b748a85f76a4c4c203a03d.tar.xz
nixlib-a31e07fc112c1c9b00b748a85f76a4c4c203a03d.tar.zst
nixlib-a31e07fc112c1c9b00b748a85f76a4c4c203a03d.zip
modules.resolved: Enhance by upstream options (#15897)
Diffstat (limited to 'nixos/modules/system')
-rw-r--r--nixos/modules/system/boot/resolved.nix67
1 files changed, 64 insertions, 3 deletions
diff --git a/nixos/modules/system/boot/resolved.nix b/nixos/modules/system/boot/resolved.nix
index 5a98b9b6d480..4b7c545dcc0d 100644
--- a/nixos/modules/system/boot/resolved.nix
+++ b/nixos/modules/system/boot/resolved.nix
@@ -1,7 +1,9 @@
 { config, lib, pkgs, ... }:
 
 with lib;
-
+let
+  cfg = config.services.resolved;
+in
 {
 
   options = {
@@ -14,9 +16,60 @@ with lib;
       '';
     };
 
+    services.resolved.fallbackDns = mkOption {
+      default = [ ];
+      example = [ "8.8.8.8" "2001:4860:4860::8844" ];
+      type = types.listOf types.str;
+      description = ''
+        A list of IPv4 and IPv6 addresses to use as the fallback DNS servers.
+        If this option is empty, a compiled-in list of DNS servers is used instead.
+      '';
+    };
+
+    services.resolved.domains = mkOption {
+      default = config.networking.search;
+      example = [ "example.com" ];
+      type = types.listOf types.str;
+      description = ''
+        A list of domains. These domains are used as search suffixes when resolving single-label host names (domain names which contain no dot), in order to qualify them into fully-qualified domain names (FQDNs).
+        For compatibility reasons, if this setting is not specified, the search domains listed in /etc/resolv.conf are used instead, if that file exists and any domains are configured in it.
+      '';
+    };
+
+    services.resolved.llmnr = mkOption {
+      default = "true";
+      example = "false";
+      type = types.enum [ "true" "resolve" "false" ];
+      description = ''
+        Controls Link-Local Multicast Name Resolution support (RFC 4794) on the local host.
+        If true, enables full LLMNR responder and resolver support.
+        If false, disables both.
+        If set to "resolve", only resolution support is enabled, but responding is disabled.
+      '';
+    };
+
+    services.resolved.dnssec = mkOption {
+      default = "allow-downgrade";
+      example = "true";
+      type = types.enum [ "true" "allow-downgrade" "false" ];
+      description = ''
+        If true all DNS lookups are DNSSEC-validated locally (excluding LLMNR and Multicast DNS). Note that this mode requires a DNS server that supports DNSSEC. If the DNS server does not properly support DNSSEC all validations will fail.
+        If set to "allow-downgrade" DNSSEC validation is attempted, but if the server does not support DNSSEC properly, DNSSEC mode is automatically disabled. Note that this mode makes DNSSEC validation vulnerable to "downgrade" attacks, where an attacker might be able to trigger a downgrade to non-DNSSEC mode by synthesizing a DNS response that suggests DNSSEC was not supported.
+        If set to false, DNS lookups are not DNSSEC validated.
+      '';
+    };
+
+    services.resolved.extraConfig = mkOption {
+      default = "";
+      type = types.lines;
+      description = ''
+        Extra config to append to resolved.conf.
+      '';
+    };
+
   };
 
-  config = mkIf config.services.resolved.enable {
+  config = mkIf cfg.enable {
 
     systemd.additionalUpstreamSystemUnits = [ "systemd-resolved.service" ];
 
@@ -27,7 +80,15 @@ with lib;
 
     environment.etc."systemd/resolved.conf".text = ''
       [Resolve]
-      DNS=${concatStringsSep " " config.networking.nameservers}
+      ${optionalString (config.networking.nameservers != [])
+        "DNS=${concatStringsSep " " config.networking.nameservers}"}
+      ${optionalString (cfg.fallbackDns != [])
+        "FallbackDNS=${concatStringsSep " " cfg.fallbackDns}"}
+      ${optionalString (cfg.domains != [])
+        "Domains=${concatStringsSep " " cfg.domains}"}
+      LLMNR=${cfg.llmnr}
+      DNSSEC=${cfg.dnssec}
+      ${config.services.resolved.extraConfig}
     '';
 
   };