system/hosts/tatos/services/dns.nix

29 lines
710 B
Nix
Raw Normal View History

{ lib, ... }:
let dnsport = 53; in
{
2024-04-18 12:54:40 +03:00
services.dnscrypt-proxy2.settings.listen_addresses = [ "127.0.0.1:51" "[::1]:51" ];
# Forward loopback traffic on port 53 to dnscrypt-proxy2.
networking.firewall.extraCommands = ''
ip6tables --table nat --flush OUTPUT
${lib.flip (lib.concatMapStringsSep "\n") [ "udp" "tcp" ] (proto: ''
ip6tables --table nat --append OUTPUT \
--protocol ${proto} --destination ::1 --destination-port 53 \
--jump REDIRECT --to-ports 51
'')}
'';
networking.firewall = {
allowedTCPPorts = [ dnsport ];
allowedUDPPorts = [ dnsport ];
};
services.dnsmasq = {
enable = true;
settings = {
interface = "wg0";
};
};
2024-04-18 12:54:40 +03:00
}