aboutsummaryrefslogtreecommitdiff
path: root/modules/nixos/services/unbound/default.nix
blob: a926b55314b8979feb6fd2495c2040de7fab393b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{ options, config, lib, namespace, pkgs, ... }:

with lib; with lib.${namespace}; let
  cfg = config.${namespace}.services.unbound;
  impermanence = config.${namespace}.system.impermanence;
in {
  options.${namespace}.services.unbound = with types; {
    enable = mkEnableOption "unbound dns server";
  };

  config = mkIf cfg.enable {
    networking.firewall.allowedTCPPorts = [ 53 ];
    networking.firewall.allowedUDPPorts = [ 53 ];

    services.unbound = {
      enable = true;
      settings = {
        server = {
          logfile = "unbound.log";
          verbosity = 3;

          interface = [ 
            "0.0.0.0"
            "::0"
          ];
          access-control = [
            "10.0.0.0/8 allow"
            "192.168.0.0/16 allow"
            "2001:DB8::/64 allow"
          ];

          do-not-query-localhost = false;

          local-zone = ''"cxl.sh." redirect'';
          local-data = [
            ''"cxl.sh. 30 IN A 192.168.254.11"''
          ];
        };

        forward-zone = [{
          name = ".";
          # sobbing
          # forward-addr = [
          #   "1.1.1.1@853#cloudflare-dns.com"
          #   "1.0.0.1@853#cloudflare-dns.com"
          # ];
          forward-addr = [
            "1.1.1.1"
            "1.0.0.1"
          ];
        }];
      };
    };
  };
}