Ajout d’un nom de domaine
L’ajout d’un nouveau nom de domaine dans son réseau peut impliquer la modification de plusieurs fichiers de configuration, la création de nouvelles clés et le redémarrage de plusieurs services.
BIND⌗
La clé générée servira à Certbot pour renouveler les certificats en requêtant le serveur de noms grâce au protocole RFC2136.
# tsig-keygen -a sha512 triaxx.io
acl "localnet" {
127.0.0.1/32;
192.168.42.0/24;
::1/128;
2003:ab4:4213:101::/64;
};
key "triaxx.io" {
algorithm hmac-sha512;
secret "ThE_vErY_sEcReT_kEy==";
};
view "internal" {
match-clients {
"localnet";
};
zone "triaxx.io" {
type primary;
file "/etc/namedb/zones/internal/triaxx.io.db";
};
};
view "external" {
match-clients {
"any";
};
zone "triaxx.io" {
type primary;
file "/etc/namedb/zones/external/triaxx.io.db";
allow-transfer { ns1; };
update-policy {
grant "triaxx.io." name "_acme-challenge.triaxx.io." "txt";
grant "triaxx.io." name "_acme-challenge.mx.triaxx.io." "txt";
grant "triaxx.io." name "_acme-challenge.ns0.triaxx.io." "txt";
grant "triaxx.io." name "_acme-challenge.ns1.triaxx.io." "txt";
grant "triaxx.io." name "_acme-challenge.www.triaxx.io." "txt";
};
dnssec-policy default;
inline-signing yes;
};
};
La zone externe peut être configurée de la manière suivante :
$ORIGIN .
$TTL 86400 ; 1 day
triaxx.io IN SOA ns0.triaxx.io. hostnaster.triaxx.io. (
2025052000 ; serial
7200 ; refresh (2 hours)
900 ; retry (15 minutes)
1209600 ; expire (2 weeks)
7200 ; minimum (2 hours)
)
NS ns0.triaxx.io.
NS ns1.triaxx.io.
A 42.59.73.132
MX 10 mx.triaxx.io.
TXT "v=spf1 a mx ip4:42.59.73.132 ip6:2003:ab4:4213:101:216:3eff:fe26:1303 ~all"
AAAA 2003:ab4:1200:d:ec4:7aff:fe0d:b158
$ORIGIN triaxx.io.
mx._domainkey TXT "v=DKIM1; k=rsa; " "p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC4NNt/kXl4oHodSXCckQosoaj+aStD3CEtyaHgisBbBexc1k/EALmaSlDufB0tXoFS52Qaz8OQ+B1j7VW3SF3NIN0wvJTbYEFJ6V9C2ujJwnD+dIkKG9oLQhgw0bRa5uZ8AL5YsoOxHAK+2LXMPjE60frESxN/MJK3rYKBxymc7wIDAQAB"
mx A 42.59.73.132
AAAA 2003:ab4:4213:101:216:3eff:fe26:1303
ns0 A 42.59.73.132
AAAA 2003:ab4:4213:101:216:3eff:fe26:1302
ns1 A 108.9.148.123
AAAA 2003:ab4:4213:101:ba27:ebff:fef8:16c6
www A 108.9.148.123
AAAA 2003:ab4:4213:101:ba27:ebff:fef8:16c6
OpenDKIM⌗
Pour que le serveur SMTP puisse authentifier les courriers avec DKIM, il faut modifier la configuration d’OpenDKIM.
Les lignes suivantes sont nécessaires dans le fichier opendkim.conf.
KeyTable refile:/var/db/opendkim/keys.tbl
SigningTable refile:/var/db/opendkim/signings.tbl
Le fichier signings.tbl doit inclure une ligne associant l’entrée DNS au motif d’adresse mail devant être signées.
*@*triaxx.io mx._domainkey.triaxx.io
Le fichier keys.tbl doit inclure une ligne associant la clé privée à cette entrée DNS.
mx._domainkey.triaxx.io triaxx.io:mx:/var/db/opendkim/triaxx.io/mx.private
Certbot⌗
dns_rfc2136_server = 192.168.1.2
dns_rfc2136_port = 53
dns_rfc2136_name = triaxx.io.
dns_rfc2136_secret = ThE_vErY_sEcReT_kEy==
dns_rfc2136_algorithm = HMAC-SHA512
Les certificats peuvent être générés avec le script suivant.
#!/bin/sh
#
# Don't forget to add an update-policy to named.conf
certbot=/usr/pkg/bin/certbot
email=triaxx@triaxx.io
inipath=/usr/pkg/etc/letsencrypt
domains="triaxx_io"
triaxx_io_subdomains="mx ns0 ns1 www"
for _domain in ${domains} ; do
eval subdomains=\$${_domain}_subdomains
domain=`echo ${_domain} | sed -e 's,_,\.,g'`
domain_args="--domain ${domain}"
for _subdomain in ${subdomains} ; do
domain_args="${domain_args} --domain ${_subdomain}.${domain}"
done
${certbot} certonly \
--cert-name ${domain} \
--agree-tos \
--email ${email} \
--dns-rfc2136 \
--dns-rfc2136-credentials ${inipath}/${domain}-rfc2136.ini \
${domain_args} \
--expand
done