<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Arquivos ietf-doh - Remontti</title>
	<atom:link href="https://blog.remontti.com.br/tag/ietf-doh/feed" rel="self" type="application/rss+xml" />
	<link>https://blog.remontti.com.br/tag/ietf-doh</link>
	<description>rudimar@remontti</description>
	<lastBuildDate>Mon, 21 Dec 2020 23:40:29 +0000</lastBuildDate>
	<language>pt-BR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://blog.remontti.com.br/wp-content/uploads/2024/09/icone-rr-80x80.png</url>
	<title>Arquivos ietf-doh - Remontti</title>
	<link>https://blog.remontti.com.br/tag/ietf-doh</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Criando um servido de DNS-over-HTTPS (DoH)</title>
		<link>https://blog.remontti.com.br/3637</link>
					<comments>https://blog.remontti.com.br/3637#respond</comments>
		
		<dc:creator><![CDATA[Rudimar Remontti]]></dc:creator>
		<pubDate>Fri, 04 Oct 2019 20:16:43 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutoriais]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[DNS-over-HTTPS]]></category>
		<category><![CDATA[doh]]></category>
		<category><![CDATA[google-dns]]></category>
		<category><![CDATA[ietf-doh]]></category>
		<category><![CDATA[rfc-8484]]></category>
		<guid isPermaLink="false">https://blog.remontti.com.br/?p=3637</guid>

					<description><![CDATA[<p>Neste tutorial vamos aprender como criar um servidor para consultar o DNS através de HTTPS, usando o Google DNS-over-protocolo HTTPS e IETF DNS-over-HTTPS (RFC 8484). O Google Chrome já a partir da versão 78&#46;&#46;&#46;</p>
<p>O post <a href="https://blog.remontti.com.br/3637">Criando um servido de DNS-over-HTTPS (DoH)</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Neste tutorial vamos aprender como criar um servidor para consultar o DNS através de HTTPS, usando o <a href="https://developers.google.com/speed/public-dns/docs/dns-over-https" rel="noopener noreferrer" target="_blank">Google DNS-over-protocolo HTTPS</a> e <a href="https://www.rfc-editor.org/rfc/rfc8484.txt" rel="noopener noreferrer" target="_blank">IETF DNS-over-HTTPS (RFC 8484)</a>.</p>
<p>O <a href="https://www.chromium.org/developers/dns-over-https" rel="noopener noreferrer" target="_blank">Google Chrome</a> já  a partir da versão 78 irá implantar o DNS-over-HTTPS (DoH), criptografando as solicitações de DNS. </p>
<p>Pressupõe que você tenha um servidor DNS em funcionamento (<a href="https://blog.remontti.com.br/3086" rel="noopener noreferrer" target="_blank"><strong>eu uso o bind9</strong></a>).</p>
<p>Estou utilizando Debian 10 (<em><strong><a href="https://blog.remontti.com.br/2966" rel="noopener noreferrer" target="_blank">Instalação limpa</a></strong></em>) para fazer esta instalação</p>
<p>Também será necessário configurar o seu ambiente <a href="https://golang.org/" rel="noopener noreferrer" target="_blank">Golang</a>, veja <a href="https://blog.remontti.com.br/3623" rel="noopener noreferrer" target="_blank"><strong>aqui como proceder</strong></a></p>
<p>Com o Golang já preparado vamos instalar alguns pacotes necessários para compilação:</p>
<pre class="remontti-code"># apt install curl software-properties-common build-essential wget unzip</pre>
<p>Vamos usar o projeto <a href="https://github.com/m13253/dns-over-https" rel="noopener noreferrer" target="_blank">m13253/DNS-over-HTTPS</a>.</p>
<pre class="remontti-code"># cd /tmp
# wget https://github.com/m13253/dns-over-https/archive/master.zip
# unzip master.zip
# cd dns-over-https-master/
# make
# make install</pre>
<p>Agora vamos configurar o servidor DoH, seu arquivo de configuração fica em /etc/dns-over-https/doh-server.conf<br />
Supondo que você esteja instalando no mesmo servidor de DNS, vamos apenas alterar o upstream para usar as consultar para localhost (127.0.0.1:53).</p>
<pre class="remontti-code"># mv /etc/dns-over-https/doh-server.conf /etc/dns-over-https/doh-server.conf.old
# vim /etc/dns-over-https/doh-server.conf</pre>
<pre class="remontti-code"># HTTP listen port
listen = [
    &quot;127.0.0.1:8053&quot;,
    &quot;[::1]:8053&quot;,

    ## To listen on both 0.0.0.0:8053 and [::]:8053, use the following line
    # &quot;:8053&quot;,
]

# Local address and port for upstream DNS
# If left empty, a local address is automatically chosen.
local_addr = &quot;&quot;

# TLS certification file
# If left empty, plain-text HTTP will be used.
# You are recommended to leave empty and to use a server load balancer (e.g.
# Caddy, Nginx) and set up TLS there, because this program does not do OCSP
# Stapling, which is necessary for client bootstrapping in a network
# environment with completely no traditional DNS service.
cert = &quot;&quot;

# TLS private key file
key = &quot;&quot;

# HTTP path for resolve application
path = &quot;/dns-query&quot;

# Upstream DNS resolver
# If multiple servers are specified, a random one will be chosen each time.
# You can use &quot;udp&quot;, &quot;tcp&quot; or &quot;tcp-tls&quot; for the type prefix.
# For &quot;udp&quot;, UDP will first be used, and switch to TCP when the server asks to
# or the response is too large.
# For &quot;tcp&quot;, only TCP will be used.
# For &quot;tcp-tls&quot;, DNS-over-TLS (RFC 7858) will be used to secure the upstream connection.
upstream = [
    &quot;udp:127.0.0.1:53&quot;,
]

# Upstream timeout
timeout = 10

# Number of tries if upstream DNS fails
tries = 3

# Enable logging
verbose = false

# Enable log IP from HTTPS-reverse proxy header: X-Forwarded-For or X-Real-IP
# Note: http uri/useragent log cannot be controlled by this config
log_guessed_client_ip = false</pre>
<p>Vamos ativa-lo na inicialização do sistema e restartar o serviço.</p>
<pre class="remontti-code"># systemctl enable doh-server 
# systemctl restart doh-server</pre>
<p>Verifique se o serviço esta rodando</p>
<pre class="remontti-code">#  systemctl status doh-server</pre>
<p><img fetchpriority="high" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2019/10/DNS-over-HTTPS-Server.png" alt="" width="928" height="275" class="alignnone size-full wp-image-3646" srcset="https://blog.remontti.com.br/wp-content/uploads/2019/10/DNS-over-HTTPS-Server.png 928w, https://blog.remontti.com.br/wp-content/uploads/2019/10/DNS-over-HTTPS-Server-300x89.png 300w, https://blog.remontti.com.br/wp-content/uploads/2019/10/DNS-over-HTTPS-Server-768x228.png 768w" sizes="(max-width: 928px) 100vw, 928px" /></p>
<p>Perfeito nosso doh-server já está rodando! </p>
<p>Instalação de configuração do <a href="https://blog.remontti.com.br/3464" rel="noopener noreferrer" target="_blank"><strong>Apache2 com um domínio virtual</strong></a>  utilizando o <a href="https://blog.remontti.com.br/3548" rel="noopener noreferrer" target="_blank"><strong>Let’s Encrypt</strong></a> para criptografar nossa conexão HTTPs.</p>
<pre class="remontti-code"># apt install apache2 apache2-utils letsencrypt python-certbot-apache
# a2enmod http2 proxy proxy_http proxy_connect
# systemctl restart apache2</pre>
<p>Vou editar a configuração padrão do servidor web, informado meu real <strong>ServerName</strong>, no exemplo &#8220;<em>doh.remontti.com.br</em>&#8220;, e <strong>ErrorDocument</strong> quando um IP não autorizado acessar ser redirecionado.</p>
<pre class="remontti-code"># vim /etc/apache2/sites-available/000-default.conf</pre>
<p>Faça as devidas alterações, não esqueça de alterar em <strong>Require ip</strong> para os IPs que você vai autorizar as conexões.</p>
<pre class="remontti-code">&lt;virtualhost *:80&gt;
        Protocols h2 http/1.1
        ServerName doh.remontti.com.br
        ServerAdmin noc@remontti.com.br
        ErrorDocument 403 http://www.remontti.com.br/
 
        DocumentRoot /var/www/html
 
        &lt;Directory /var/www/html/&gt;
                Options FollowSymLinks
                AllowOverride All
                Require ip 127.0.0.1 ::1 192.168.0.0/16 172.16.0.0/12 100.64.0.0/10 10.0.0.0/8 250.0.0.0/22 2000:000::/32
        &lt;/Directory&gt;
 
        LogLevel warn 
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
&lt;/virtualhost&gt;</pre>
<p>Por segurança recomendo remover a assinatura do servidor, para isso edite:</p>
<pre class="remontti-code"># sed -i &#039;s/ServerTokens OS/ServerTokens Prod/&#039; /etc/apache2/conf-available/security.conf
# sed -i &#039;s/ServerSignature On/ServerSignature Off/&#039; /etc/apache2/conf-available/security.conf</pre>
<p>Para que quando alguém (autorizado) acessar seu endereço DoH não veja aquela tela Default do Apache2, vamos remover o /var/www/html/index.html e criar uma index mais legal <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f61b.png" alt="😛" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<pre class="remontti-code"># rm /var/www/html/index.html
# wget https://blog.remontti.com.br/wp-content/uploads/2019/10/doh.jpg -O /var/www/html/doh.jpg
# vim /var/www/html/index.html</pre>
<pre class="remontti-code">&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;meta charset=&quot;utf-8&quot;/&gt;
    &lt;title&gt;Dns Over Https - DoH&lt;/title&gt;
    &lt;!-- Altere para o endereço que você deseja que ele seja direcionado apos 5seg--&gt;
    &lt;meta http-equiv=&quot;refresh&quot; content=&quot;5; URL=&#039;http://www.remontti.com.br/&#039;&quot;/&gt;
    &lt;style type=&quot;text/css&quot;&gt;
      body, html {
        background-color: #fff112;
      }
      img {
        width: 95%;
        height: auto;
      }
    &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
  &lt;img src=&quot;doh.jpg&quot;&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>Geramos o certificado</p>
<pre class="remontti-code"># systemctl stop apache2
# letsencrypt</pre>
<p>Agora já é possível acessar <em>&#8220;doh.remontti.com.br&#8221;</em> com HTTPS, faça um teste se seu domínio esta respondendo corretamente. Teste também seu HTTP2 em <a href="https://tools.keycdn.com/http2-test" rel="noopener noreferrer" target="_blank">https://tools.keycdn.com/http2-test</a> </p>
<p>Para evitar que o certificado expire faça um script e colocando ele no cron para que o mesmo renove automaticamente.</p>
<pre class="remontti-code"># vim  /etc/renovassl.sh</pre>
<p>Adicione</p>
<pre class="remontti-code">#!/bin/bash
/usr/bin/systemctl stop apache2
/usr/bin/certbot -q renew
/usr/bin/systemctl start apache2</pre>
<p>De permissão de execução: </p>
<pre class="remontti-code"># chmod +x /etc//renovassl.sh</pre>
<p>Adicione ao cron e restarte o cron</p>
<pre class="remontti-code"># echo &#039;00 00   * * *   root    /etc/renovassl.sh&#039; &gt;&gt; /etc/crontab
# systemctl restart cron</pre>
<p>Altere algumas configuração no 000-default-le-ssl.conf  criado pelo Let&#8217;s Encrypt para trabalhar como um proxy do nosso DoH</p>
<pre class="remontti-code"># vim /etc/apache2/sites-enabled/000-default-le-ssl.conf</pre>
<p>Adicione as entradas destacadas: </p>
<pre class="remontti-code">&lt;IfModule mod_ssl.c&gt;

SSLProtocol TLSv1.2
SSLHonorCipherOrder On
SSLCipherSuite ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+3DES:!aNULL:!MD5:!DSS:!eNULL:!EXP:!LOW:!MD5
SSLUseStapling on
SSLStaplingCache shmcb:/var/lib/apache2/stapling_cache(512000)

&lt;VirtualHost *:443&gt;

        Protocols h2 http/1.1
        ServerName doh.remontti.com.br
        ServerAdmin noc@remontti.com.br
        ErrorDocument 403 http://www.remontti.com.br/

        ProxyPreserveHost On
        ProxyPass /dns-query http://[::1]:8053/dns-query
        ProxyPassReverse /dns-query http://[::1]:8053/dns-query

        &lt;Proxy &quot;*&quot;&gt;
            Require ip 127.0.0.1 ::1 192.168.0.0/16 172.16.0.0/12 100.64.0.0/10 10.0.0.0/8 250.0.0.0/22 2000:000::/32
        &lt;/Proxy&gt;

        DocumentRoot /var/www/html

        &lt;Directory /var/www/html/&gt;
                Options FollowSymLinks
                AllowOverride All
                Require ip 127.0.0.1 ::1 192.168.0.0/16 172.16.0.0/12 100.64.0.0/10 10.0.0.0/8 250.0.0.0/22 2000:000::/32
        &lt;/Directory&gt;

  
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

SSLCertificateFile /etc/letsencrypt/live/su-151.speedrs.com.br/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/su-151.speedrs.com.br/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
&lt;/VirtualHost&gt;
&lt;/IfModule&gt;</pre>
<p>Restar o apache</p>
<pre class="remontti-code"># systemctl restart apache2</pre>
<p>Configuramos o apache para encaminhar solicitações para nosso servidor DoH. Agora vamos fazer alguns testes.<br />
O servidor DoH retorna em formato JSON, e para testar apenas abra no seu navegador:<br />
<em>https://doh.remontti.com.br/dns-query?name=remontti.com.br&#038;type=A</em><br />
Ou já que você está com o terminal aberto digite:</p>
<pre class="remontti-code"># curl -s &quot;https://doh.remontti.com.br/dns-query?name=google.com.br&amp;type=A&quot; | python -m json.tool</pre>
<p>Vai retornar:</p>
<pre class="remontti-code">{
    &quot;AD&quot;: false,
    &quot;Answer&quot;: [
        {
            &quot;Expires&quot;: &quot;Fri, 04 Oct 2019 16:48:23 UTC&quot;,
            &quot;TTL&quot;: 300,
            &quot;data&quot;: &quot;172.217.29.227&quot;,
            &quot;name&quot;: &quot;google.com.br.&quot;,
            &quot;type&quot;: 1
        }
    ],
    &quot;CD&quot;: false,
    &quot;Question&quot;: [
        {
            &quot;name&quot;: &quot;google.com.br.&quot;,
            &quot;type&quot;: 1
        }
    ],
    &quot;RA&quot;: true,
    &quot;RD&quot;: true,
    &quot;Status&quot;: 0,
    &quot;TC&quot;: false,
    &quot;edns_client_subnet&quot;: &quot;186.250.168.0/0&quot;
}
</pre>
<p>Legal, nosso DoH esta funcionando! </p>
<p><strong>Configure seu navegador</strong><br />
Bem, no Firefox, isso é bem fácil, entre no menu <strong>Preferências</strong>, role até o final e clique em <strong>Configurar Conexão&#8230;</strong> em seguida marque a caixa <strong>Ativar DNS sobre HTTPS</strong> selecione <strong>Personalizado</strong> e informe o endereço do seu servidor DoH <strong>https://doh.exemplo.com.br/dns-query</strong></p>
<p><a href="https://blog.remontti.com.br/wp-content/uploads/2019/10/doh-firefox.png" data-rel="lightbox-gallery-lalMkuKb" data-rl_title="" data-rl_caption="" title=""><img decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2019/10/doh-firefox-1024x597.png" alt="" width="1024" height="597" class="alignnone size-large wp-image-3653" srcset="https://blog.remontti.com.br/wp-content/uploads/2019/10/doh-firefox-1024x597.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2019/10/doh-firefox-300x175.png 300w, https://blog.remontti.com.br/wp-content/uploads/2019/10/doh-firefox-768x448.png 768w, https://blog.remontti.com.br/wp-content/uploads/2019/10/doh-firefox.png 1680w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></p>
<p>No linux a versão que utilizei foi uma beta, pois na estável ainda não aparecia a opção.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2019/10/doh-firefox-versao.png" data-rel="lightbox-gallery-lalMkuKb" data-rl_title="" data-rl_caption="" title=""><img decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2019/10/doh-firefox-versao-300x142.png" alt="" width="300" height="142" class="alignnone size-medium wp-image-3654" srcset="https://blog.remontti.com.br/wp-content/uploads/2019/10/doh-firefox-versao-300x142.png 300w, https://blog.remontti.com.br/wp-content/uploads/2019/10/doh-firefox-versao-520x245.png 520w, https://blog.remontti.com.br/wp-content/uploads/2019/10/doh-firefox-versao-720x340.png 720w, https://blog.remontti.com.br/wp-content/uploads/2019/10/doh-firefox-versao.png 728w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>Já no Chrome Versão Dev 79.0.3921.0 no linux não consegui testar, pois a opção aparece como: Not available on your platform.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2019/10/doh-chrome-Versão-79.0.3921.0-dev.png" data-rel="lightbox-gallery-lalMkuKb" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2019/10/doh-chrome-Versão-79.0.3921.0-dev-300x175.png" alt="" width="300" height="175" class="alignnone size-medium wp-image-3655" srcset="https://blog.remontti.com.br/wp-content/uploads/2019/10/doh-chrome-Versão-79.0.3921.0-dev-300x175.png 300w, https://blog.remontti.com.br/wp-content/uploads/2019/10/doh-chrome-Versão-79.0.3921.0-dev-768x448.png 768w, https://blog.remontti.com.br/wp-content/uploads/2019/10/doh-chrome-Versão-79.0.3921.0-dev-1024x597.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2019/10/doh-chrome-Versão-79.0.3921.0-dev.png 1680w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Agora basta navegar! E para ter certeza que ele realmente ta fazendo as consulta em seu DoH Server, verifique os logs do seu apache:</p>
<pre class="remontti-code"># tail -f /var/log/apache2/access.log</pre>
<p><a href="https://blog.remontti.com.br/wp-content/uploads/2019/10/doh-log-apache2.png" data-rel="lightbox-gallery-lalMkuKb" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2019/10/doh-log-apache2-1024x151.png" alt="" width="1024" height="151" class="alignnone size-large wp-image-3657" srcset="https://blog.remontti.com.br/wp-content/uploads/2019/10/doh-log-apache2-1024x151.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2019/10/doh-log-apache2-300x44.png 300w, https://blog.remontti.com.br/wp-content/uploads/2019/10/doh-log-apache2-768x113.png 768w, https://blog.remontti.com.br/wp-content/uploads/2019/10/doh-log-apache2.png 1431w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a><br />
Parabéns você concluiu! </p>
<p><strong>O que você vai acontecer quando o DoH estiver ativado?</strong><br />
Quando o DoH está ativado, você não notará nada. O Firefox e o Chrome implementaram extensos mecanismos de fallback para situações em que o DoH pode cair, como um provedor de DNS que não oferece suporte a DoH.</p>
<p><strong>Quais navegadores suportam o DoH?</strong><br />
Por enquanto, os únicos principais navegadores programados para oferecer suporte ao DoH são o Mozilla Firefox e Chrome 78 ou superior (embora, especialmente, o Chrome para iOS e o Chrome para Linux não suportem esse recurso ainda). Resta saber se o Safari da Apple seguirá o exemplo.</p>
<p>Ambos os navegadores se o DoH não funcionar como planejado simplesmente retornará ao método padrão de pesquisa de DNS.</p>
<p><strong>Se quiser fazer uma doação para o café ficarei muito feliz pelo seu reconhecimento!</strong><br />
<a href="https://blog.remontti.com.br/doar"><img decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2019/07/quero-doar-remontti.png" /></a></p>
<p>Se não puder doar pode deixar seu agradecimento nos comentário também ficarei feliz em saber que ajudei. Se tiver qualquer pergunta deixe-a também. Se preferir entrar em Contato <a href="https://blog.remontti.com.br/meucontato" rel="noopener noreferrer" target="_blank">clique aqui.</a></p>
<p>Abraço!</p>
<p>O post <a href="https://blog.remontti.com.br/3637">Criando um servido de DNS-over-HTTPS (DoH)</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.remontti.com.br/3637/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
