X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=modules%2Fprivate%2Fdns.nix;h=b4772fcde9f20d5a5d00669abf80e0c11bef4bc2;hb=8415083eb6acc343dfa404dbbc12fa0171a48a20;hp=af536958e59767e6cf0d079d10f1833876ec3923;hpb=02d6e977e309355ae728422e26063090e8a2f193;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/modules/private/dns.nix b/modules/private/dns.nix index af53695..b4772fc 100644 --- a/modules/private/dns.nix +++ b/modules/private/dns.nix @@ -1,5 +1,6 @@ { lib, pkgs, config, myconfig, ... }: { + options.myServices.dns.enable = lib.mkEnableOption "enable DNS resolver"; config = let cfg = config.services.bind; configFile = pkgs.writeText "named.conf" '' @@ -49,8 +50,7 @@ '') cfg.zones } ''; - in - { + in lib.mkIf config.myServices.dns.enable { networking.firewall.allowedUDPPorts = [ 53 ]; networking.firewall.allowedTCPPorts = [ 53 ]; services.bind = { @@ -94,10 +94,10 @@ ${conf.entries} ${if lib.attrsets.hasAttr "withEmail" conf && lib.lists.length conf.withEmail > 0 then '' - mail IN A ${myconfig.env.servers.immaeEu.ips.main.ip4} mx-1 IN A ${myconfig.env.servers.eldiron.ips.main.ip4} - ${builtins.concatStringsSep "\n" (map (i: "mail IN AAAA ${i}") myconfig.env.servers.immaeEu.ips.main.ip6)} + mx-2 IN A ${myconfig.env.servers.immaeEu.ips.main.ip4} ${builtins.concatStringsSep "\n" (map (i: "mx-1 IN AAAA ${i}") myconfig.env.servers.eldiron.ips.main.ip6)} + ${builtins.concatStringsSep "\n" (map (i: "mx-2 IN AAAA ${i}") myconfig.env.servers.immaeEu.ips.main.ip6)} ${lib.concatStringsSep "\n\n" (map (e: let n = if e.domain == "" then "@" else "${e.domain} "; @@ -105,8 +105,25 @@ in '' ; ------------------ mail: ${n} --------------------------- - ${n} IN MX 10 mail.${conf.name}. - ;${n} IN MX 50 mx-1.${conf.name}. + ${n} IN MX 10 mx-1.${conf.name}. + ${n} IN MX 20 mx-2.${conf.name}. + + ; https://tools.ietf.org/html/rfc6186 + _submission._tcp${suffix} SRV 0 1 587 smtp.immae.eu. + _submissions._tcp${suffix} SRV 0 1 465 smtp.immae.eu. + _imap._tcp${suffix} SRV 0 1 143 imap.immae.eu. + _imaps._tcp${suffix} SRV 0 1 993 imap.immae.eu. + _pop3._tcp${suffix} SRV 10 1 110 pop3.immae.eu. + _pop3s._tcp${suffix} SRV 10 1 995 pop3.immae.eu. + _sieve._tcp${suffix} SRV 0 1 4190 imap.immae.eu. + + ; MTA-STS + ; https://blog.delouw.ch/2018/12/16/using-mta-sts-to-enhance-email-transport-security-and-privacy/ + ; https://support.google.com/a/answer/9261504 + _mta-sts${suffix} IN TXT "v=STSv1;id=20190630054629Z" + _smtp._tls${suffix} IN TXT "v=TLSRPTv1;rua=mailto:postmaster+mta-sts@immae.eu" + mta-sts${suffix} IN A ${myconfig.env.servers.eldiron.ips.main.ip4} + ${builtins.concatStringsSep "\n" (map (i: "mta-sts${suffix} IN AAAA ${i}") myconfig.env.servers.eldiron.ips.main.ip6)} ; Mail sender authentications ${n} IN TXT "v=spf1 mx ~all" @@ -115,6 +132,7 @@ immae_eu._domainkey${suffix} IN TXT ( "v=DKIM1; k=rsa; s=email; " "p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzl3vLd8W5YAuumC5+ZT9OV7/14Pmh5JYtwyqKI3cfe9NnAqInt3xO4bZ7oqIxRKWN4SD39vm7O/QOvFdBt00ENOOzdP90s5gKw6eIP/4+vPTh0IWltAsmu9B2agzdtWUE7t2xFKIzEn8l9niRE2QYbVaqZv4sub98vY55fIgFoHtjkmNC7325S8fjDJGp6OPbyhAs6Xl5/adjF" "0ko4Y2p6RaxLQfjlS0bxmK4Qg6C14pIXHtzVeqOuWrwApqt5+AULSn97iUtqV/IJlEEjC6DUR44t3C/G0G/k46iFclCqRRi0hdPrOHCtZDbtMubnTN9eaUiNpkXh1WnCflHwtjQwIDAQAB" ) + eldiron._domainkey${suffix} IN TXT ${myconfig.env.mail.dkim.eldiron.public} '' else ""} '') conf.withEmail)} '' + (if conf.name == "immae.eu" then ''