maxwell/nameserver.nix

83 lines
2.2 KiB
Nix
Raw Normal View History

2023-08-15 16:21:59 +02:00
{ config, lib, ... }:
2020-10-20 01:11:28 +02:00
# Setup:
2024-07-04 11:21:51 +02:00
# pdns-recursor on localhost:55
# dnsdist on port 53 (DNS) and localhost:54 (DNSCrypt)
# sslh handling both HTTP and DNS on port 443
# ncdns for Namecoin bit. zone resolution
2020-10-20 01:11:28 +02:00
{
# Recursive DNS resolver
2023-08-15 16:21:59 +02:00
services.pdns-recursor =
{ enable = true;
# Configures the bit. zone
resolveNamecoin = true;
2024-07-04 11:21:51 +02:00
dns.port = 55;
2023-08-15 16:21:59 +02:00
};
2020-10-20 01:11:28 +02:00
2024-07-04 11:21:51 +02:00
# Public DNS resolver
services.dnsdist =
{ enable = true;
extraConfig = ''
-- Listen on IPv6 and IPv4
setLocal("[::]:53"); addLocal("0.0.0.0:53")
-- Allow everything
setACL({"0.0.0.0/0", "::/0"})
-- Set upstream resolver
newServer({address="[::1]:55", name="pdns"})
'';
};
# DNSCrypt endpoint
services.dnsdist.dnscrypt =
{ enable = true;
listenAddress = "[::1]";
listenPort = 54;
providerKey = config.secrets.dnscrypt.sec;
2023-08-15 16:21:59 +02:00
};
# Demultiplex HTTP and DNS from port 443
services.sslh =
{ enable = true;
method = "ev";
settings.transparent = true;
settings.listen = with config.var; lib.mkForce
[ { host = hostname; port = "443"; is_udp = false; }
{ host = hostname; port = "443"; is_udp = true; }
];
settings.protocols =
[ # Send TLS to nginx (TCP)
2024-02-25 18:58:01 +01:00
{ name = "tls"; host = "localhost"; port= "443"; }
2023-08-15 16:21:59 +02:00
# Send DNSCrypt to dnscrypt-wrapper (TCP or UDP)
2024-07-04 11:21:51 +02:00
{ name = "anyprot"; host = "localhost"; port = "54"; }
{ name = "anyprot"; host = "localhost"; port = "54";
2024-05-05 18:31:57 +02:00
is_udp = true; udp_timeout = 100; }
2023-08-15 16:21:59 +02:00
];
};
# This is needed for the rotation of DNSCrypt keys
security.polkit.enable = true;
2020-10-20 01:11:28 +02:00
# Namecoin resolver
2023-08-15 16:21:59 +02:00
services.ncdns =
{ enable = true;
# This is currently broken, see ncdns issue:
# https://github.com/namecoin/ncdns/issues/127
dnssec.enable = false;
};
2020-10-20 01:11:28 +02:00
# Namecoin daemon with RPC server
2023-08-15 16:21:59 +02:00
services.namecoind =
{ enable = true;
# This are used by the resolver (ncdns)
# to query the blockchain.
rpc.user = config.secrets.namecoin.user;
rpc.password = config.secrets.namecoin.password;
};
2020-10-20 01:11:28 +02:00
2021-12-21 00:31:25 +01:00
users.users.namecoin.group = "namecoin";
2020-10-20 01:11:28 +02:00
}