Wiki » Historique » Version 18
sacha, 26/02/2023 21:03
1 | 5 | sacha | {{>toc}} |
---|---|---|---|
2 | |||
3 | 9 | sacha | # DNS récursif Ouvert DoH DoT & haute disponibilité |
4 | 15 | sacha | **45.67.81.23 - dns.aquilenet.fr** |
5 | 14 | sacha | |
6 | 1 | sacha | |
7 | 16 | sacha | |
8 | 1 | sacha | Aquilenet propose deux serveurs DNS ouverts cf https://www.aquilenet.fr/services/dns/ |
9 | 18 | sacha | On a mis aussi un DNS ouvert sur l'IP 45.67.81.23 car facile à retenir, avec l'adresse de dns.aquilenet.fr (voir [http://dns.aquilenet.fr](http://dns.aquilenet.fr)) . Nous en avons profité pour ajouter [DoH](https://fr.wikipedia.org/wiki/DNS_over_HTTPS) et [DoT](https://fr.wikipedia.org/wiki/DNS_over_TLS) et d'avoir cette adresse en IP Virtuelle partagée entre pan1 et pan2. |
10 | Cette IP virtuelle est portée par Keepalived sur pan1 le primaire et pan2 le secondaire. Si le démon Keepalived est arrêté sur pan1, l'ip bascule sur pan2. Si on redémarre le démon sur pan1, ce dernier reprend l'IP: pratique pour les mises à jour, le service continue à fonctionner. |
||
11 | 1 | sacha | |
12 | 18 | sacha | Une configuration spécifique pour l'ip de ce vlan a été fait sur les switches et les hyperviseurs, ce qui permet au final à pan1 et pan2 d'avoir une seconde interface qui porte l'IP virtuelle, elle n'est pas abordée dans ce document. |
13 | 6 | sacha | |
14 | 18 | sacha | ## Configurations communes à pan1 et pan2 |
15 | 1 | sacha | |
16 | 18 | sacha | ### Nginx |
17 | 1 | sacha | |
18 | 18 | sacha | * /etc/nginx/site-avaible |
19 | 1 | sacha | |
20 | 6 | sacha | |
21 | ~~~ |
||
22 | 18 | sacha | server { |
23 | listen 443 ssl http2 default_server; |
||
24 | listen [::]:443 ssl http2 default_server; |
||
25 | server_name dns.aquilenet.fr; |
||
26 | root /var/www/dns.aquilenet.fr; |
||
27 | 1 | sacha | |
28 | 18 | sacha | include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot |
29 | ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot |
||
30 | 1 | sacha | |
31 | |||
32 | 18 | sacha | server_tokens off; |
33 | 1 | sacha | |
34 | 18 | sacha | ssl_session_cache shared:SSL:10m; |
35 | # resolver 127.0.0.1 valid=300s; # Replace with your local resolver |
||
36 | resolver_timeout 5s; |
||
37 | # HTTP Security Headers |
||
38 | add_header X-Frame-Options DENY; |
||
39 | add_header X-Content-Type-Options nosniff; |
||
40 | add_header X-XSS-Protection "1; mode=block"; |
||
41 | add_header Strict-Transport-Security "max-age=63072000"; |
||
42 | ssl_certificate /etc/letsencrypt/live/dns.aquilenet.fr/fullchain.pem; # managed by Certbot |
||
43 | ssl_certificate_key /etc/letsencrypt/live/dns.aquilenet.fr/privkey.pem; # managed by Certbot |
||
44 | location / { |
||
45 | try_files $uri /index.htm; |
||
46 | } |
||
47 | location /dns-query { |
||
48 | proxy_pass http://localhost:1443/dns-query; |
||
49 | proxy_set_header Host $host; |
||
50 | proxy_set_header X-Real-IP $remote_addr; |
||
51 | } |
||
52 | 1 | sacha | |
53 | 18 | sacha | } |
54 | 1 | sacha | |
55 | 18 | sacha | ~~~ |
56 | 1 | sacha | |
57 | 18 | sacha | ### Unbound |
58 | |||
59 | 1 | sacha | ~~~ |
60 | |||
61 | ~~~ |
||
62 | |||
63 | ### AppArmor |
||
64 | |||
65 | 18 | sacha | * /etc/apparmor.d/usr.sbin.unbound |
66 | décomenter: |
||
67 | include <local/usr.sbin.unbound> |
||
68 | 1 | sacha | |
69 | 18 | sacha | * /etc/apparmor.d/local/usr.sbin.unbound |
70 | 1 | sacha | ~~~ |
71 | 18 | sacha | /etc/letsencrypt/archive/** r, |
72 | /etc/letsencrypt/live/** r, |
||
73 | 1 | sacha | ~~~ |
74 | 18 | sacha | appliquer avec: `apparmor_parser -r /etc/apparmor.d/usr.sbin.unbound` |
75 | 7 | sacha | |
76 | ### Iptables |
||
77 | |||
78 | ~~~ |
||
79 | # Web |
||
80 | -A INPUT -p tcp --dport 80 -j ACCEPT |
||
81 | -A INPUT -i eth0 -p tcp --dport 443 -j ACCEPT |
||
82 | ~~~ |
||
83 | ~~~ |
||
84 | -A INPUT -d 45.67.81.23 -p tcp -m tcp --dport 53 -j dns_limit |
||
85 | -A INPUT -d 45.67.81.23 -p udp -m udp --dport 53 -j dns_limit |
||
86 | -A INPUT -d 45.67.81.23 -p tcp -m tcp --dport 443 -j dns_limit |
||
87 | -A INPUT -d 45.67.81.23 -p tcp -m tcp --dport 853 -j dns_limit |
||
88 | ~~~ |
||
89 | 3 | sacha | |
90 | ## Configurations spécifiques |
||
91 | |||
92 | ### Génération du certificat SSL sur Hades |
||
93 | |||
94 | ~~~ |
||
95 | certbot --apache --agree-tos --email sysop@aquilenet.fr -d dns.aquilenet.fr |
||
96 | chgrp bind /etc/letsencrypt/live/dns.aquilenet.fr/privkey.pem |
||
97 | chmod 0640 /etc/letsencrypt/live/dns.aquilenet.fr/privkey.pem |
||
98 | openssl dhparam -out /etc/bind/dhparam.pem 4096 |
||
99 | ~~~ |
||
100 | |||
101 | Copie du certificat sur gaia |
||
102 | |||
103 | * /etc/letsencrypt/renewal-hooks/post/sync-cert.sh |
||
104 | ~~~ |
||
105 | #!/bin/bash |
||
106 | rsync -aPHSA /etc/letsencrypt/archive/dns.aquilenet.fr gaia:/etc/letsencrypt/archive/ |
||
107 | ~~~ |
||
108 | |||
109 | 16 | sacha | ### Clée sdns (auth par épinglage de la clé / key pining) |
110 | |||
111 | * A partir de la clé |
||
112 | ~~~ |
||
113 | hades|19:21:08|:~# openssl rsa -in /etc/letsencrypt/live/dns.aquilenet.fr/privkey.pem -outform der -pubout | openssl dgst -sha256 -binary | openssl enc -base64 |
||
114 | writing RSA key |
||
115 | lBk09CRIPJ+J4O9rmbvJkEiGYoH5r9rxOIQdxkYxyII= |
||
116 | ~~~ |
||
117 | * ou à partir du certificat |
||
118 | ~~~ |
||
119 | hades|19:22:21|:~# openssl x509 -in /etc/letsencrypt/live/dns.aquilenet.fr/cert.pem -pubkey -noout | openssl rsa -pubin -outform der | openssl dgst -sha256 -binary | openssl enc -base64 |
||
120 | writing RSA key |
||
121 | lBk09CRIPJ+J4O9rmbvJkEiGYoH5r9rxOIQdxkYxyII= |
||
122 | ~~~ |
||
123 | |||
124 | 3 | sacha | ### Keepalived |
125 | |||
126 | #### Hades Master |
||
127 | |||
128 | * /etc/keepalived/keepalived.conf |
||
129 | |||
130 | ~~~ |
||
131 | global_defs { |
||
132 | notification_email { |
||
133 | sysop@aquilenet.fr |
||
134 | } |
||
135 | notification_email_from vrrp-dns@aquilenet.fr.fr |
||
136 | smtp_server localhost |
||
137 | smtp_connect_timeout 30 |
||
138 | } |
||
139 | |||
140 | vrrp_instance DNS { |
||
141 | state MASTER |
||
142 | interface eth0 |
||
143 | virtual_router_id 101 |
||
144 | priority 100 |
||
145 | advert_int 2 |
||
146 | smtp_alert |
||
147 | unicast_src_ip 185.233.100.16 |
||
148 | unicast_peer { |
||
149 | 185.233.100.2 |
||
150 | } |
||
151 | virtual_ipaddress { |
||
152 | 45.67.81.23/32 dev eth1 scope global # VIP |
||
153 | } |
||
154 | } |
||
155 | ~~~ |
||
156 | |||
157 | #### Gaia Slave |
||
158 | |||
159 | * /etc/keepalived/keepalived.conf |
||
160 | |||
161 | ~~~ |
||
162 | global_defs { |
||
163 | notification_email { |
||
164 | sysop@aquilenet.fr |
||
165 | } |
||
166 | notification_email_from vrrp-dns@aquilenet.fr.fr |
||
167 | smtp_server localhost |
||
168 | smtp_connect_timeout 30 |
||
169 | } |
||
170 | |||
171 | vrrp_instance DNS { |
||
172 | state BACKUP |
||
173 | interface eth0 |
||
174 | virtual_router_id 101 |
||
175 | priority 50 |
||
176 | advert_int 2 |
||
177 | smtp_alert |
||
178 | unicast_src_ip 185.233.100.2 |
||
179 | unicast_peer { |
||
180 | 185.233.100.16 |
||
181 | } |
||
182 | virtual_ipaddress { |
||
183 | 45.67.81.23/32 dev eth1 scope global # VIP |
||
184 | } |
||
185 | } |
||
186 | |||
187 | 1 | sacha | ~~~ |
188 | 4 | sacha | |
189 | ## Validation |
||
190 | |||
191 | * test du service |
||
192 | ~~~ |
||
193 | 1 | sacha | dig +short dns.aquilenet.fr @45.67.81.23 |
194 | 13 | sacha | 45.67.81.23 |
195 | dig +https +short dns.aquilenet.fr @45.67.81.23 |
||
196 | 45.67.81.23 |
||
197 | dig +tls +short dns.aquilenet.fr @45.67.81.23 |
||
198 | 8 | sacha | 45.67.81.23 |
199 | 4 | sacha | ~~~ |
200 | |||
201 | * bascule keepalived |
||
202 | 8 | sacha | |
203 | sur hades: `systemctl stop keepalived` |
||
204 | 1 | sacha | sur gaia: `ip a |grep /32`doit donner "inet 45.67.81.23/32 scope global eth1" |
205 | 12 | sacha | http://dns.aquilenet.fr/host permet de savoir quel est le serveur qui porte l'IP virtuelle |
206 | 9 | sacha | |
207 | ## Indexes de serveurs DNS ouverts: |
||
208 | |||
209 | https://github.com/curl/curl/wiki/DNS-over-HTTPS#publicly-available-servers <= fait |
||
210 | 10 | sacha | https://diyisp.org/dokuwiki/doku.php?id=technical:dnsresolver <= fait |
211 | https://diyisp.org/dokuwiki/doku.php?id=technical:dnsresolver <= fait |
||
212 | 9 | sacha | https://dnsprivacy.org/public_resolvers/ |
213 | 16 | sacha | |
214 | 17 | sacha | ## Ressources |
215 | 16 | sacha | |
216 | https://www.bortzmeyer.org/doh-bortzmeyer-fr-policy.html |
||
217 | https://www.bortzmeyer.org/7858.html |
||
218 | https://kb.isc.org/docs/aa-01386 |