# DNS over HTTPS

**URL:** <https://forum.mikrotik.com/t/dns-over-https/138774>\
**Category:** General\
**Created:** [April 22, 2020, 6:10am UTC](https://forum.mikrotik.com/t/dns-over-https/138774 "2020-04-22T06:10:48Z")\
**Posts on this page:** 20\
**Page:** 7

<div class="post-metadata">

**Author:** ![capy2008](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/capy2008/32/2606_2.png) [@capy2008](https://forum.mikrotik.com/u/capy2008)\
**Post date:** [June 21, 2020, 5:16pm UTC](https://forum.mikrotik.com/t/dns-over-https/138774/121 "2020-06-21T17:16:54Z")

</div>

I get this error. Anybody have any idea how I fix it?

```plaintext
/tool fetch url="https://curl.haxx.se/ca/cacert.pem"
failure: unable to resolve hostname

```

I fix it but i unable to make doh work. I still see isp dns in torch.

---

<div class="post-metadata">

**Author:** ![MEJAKUmputer](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/mejakumputer/32/2615_2.png) [@MEJAKUmputer](https://forum.mikrotik.com/u/MEJAKUmputer)\
**Post date:** [July 15, 2020, 11:33am UTC](https://forum.mikrotik.com/t/dns-over-https/138774/122 "2020-07-15T11:33:55Z")

</div>

My DoH setting

```plaintext
/tool fetch url=https://cacerts.digicert.com/DigiCertGlobalRootCA.crt.pem
/certificate import file-name=cacert.pem passphrase=””
/ip dns set servers=""
/ip dns set use-doh-server=https://family.cloudflare-dns.com/dns-query verify-doh-cert=yes

/ip firewall filter
add action=accept chain=input src-port=443 protocol=tcp src-address-list=Cloudflare-DNS
add action=accept chain=input dst-port=53 in-interface=!ether1-wan protocol=udp
add action=drop chain=input

/ip firewall nat
add action=dst-nat chain=dstnat dst-port=53 in-interface=ether2-lan protocol=tcp to-addresses=192.168.68.1 to-ports=53

```

I added 2 static DNS entries for [family.cloudflare-dns.com](http://family.cloudflare-dns.com) to address: 104.18.209.237 and 104.18.210.237.  
Also added 104.18.209.237 and 104.18.210.237 to address list named Cloudflare-DNS  
And 192.168.68.1 is gateway for Ether 2

Everything works well, but did i miss something in my settings? I need your opinion.

---

<div class="post-metadata">

**Author:** ![DarkNate](https://forum.mikrotik.com/letter_avatar/darknate/32/6_449c533f586939b6e5f246632a46421f.png) [@DarkNate](https://forum.mikrotik.com/u/DarkNate)\
**Post date:** [July 16, 2020, 1:26pm UTC](https://forum.mikrotik.com/t/dns-over-https/138774/123 "2020-07-16T13:26:48Z")

</div>

What ports does RouterOS use for DoH?

Stricly TCP 443 only?

Seems in some cases port 53, 853 is used: [https://en.wikipedia.org/wiki/DNS\_over\_HTTPS#Deployment\_scenarios](https://en.wikipedia.org/wiki/DNS_over_HTTPS#Deployment_scenarios)

---

<div class="post-metadata">

**Author:** ![proximus](https://forum.mikrotik.com/letter_avatar/proximus/32/6_449c533f586939b6e5f246632a46421f.png) [@proximus](https://forum.mikrotik.com/u/proximus)\
**Post date:** [July 16, 2020, 9:26pm UTC](https://forum.mikrotik.com/t/dns-over-https/138774/124 "2020-07-16T21:26:01Z")

</div>

> [@](#):
>
> I added 2 static DNS entries for [family.cloudflare-dns.com](http://family.cloudflare-dns.com) to address: 104.18.209.237 and 104.18.210.237.

You would probably be better off using the Anycast addresses 1.1.1.3 and 1.0.0.3. That way, if CF ever changes those specific servers, you won’t be out of service.

I use the 1.1.1.2 / 1.0.0.2 [security.cloudflare-dns.com](http://security.cloudflare-dns.com) static DNS entries and it is fine.

---

<div class="post-metadata">

**Author:** ![MEJAKUmputer](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/mejakumputer/32/2615_2.png) [@MEJAKUmputer](https://forum.mikrotik.com/u/MEJAKUmputer)\
**Post date:** [July 21, 2020, 10:59am UTC](https://forum.mikrotik.com/t/dns-over-https/138774/125 "2020-07-21T10:59:02Z")

</div>

> [@](#):
>
> > [@](#):
> >
> > I added 2 static DNS entries for [family.cloudflare-dns.com](http://family.cloudflare-dns.com) to address: 104.18.209.237 and 104.18.210.237.
> 
> You would probably be better off using the Anycast addresses 1.1.1.3 and 1.0.0.3. That way, if CF ever changes those specific servers, you won’t be out of service.
> 
> I use the 1.1.1.2 / 1.0.0.2 [security.cloudflare-dns.com](http://security.cloudflare-dns.com) static DNS entries and it is fine.

What if i just add 1.1.1.3 and 1.0.0.3 as [family.cloudflare-dns.com](http://family.cloudflare-dns.com) static DNS entries, so i have four static DNS entries for [family.cloudflare-dns.com](http://family.cloudflare-dns.com) (104.18.209.237, 104.18.210.237, 1.1.1.3, 1.0.0.3)? It’s fine?

---

<div class="post-metadata">

**Author:** ![Guscht](https://forum.mikrotik.com/letter_avatar/guscht/32/6_449c533f586939b6e5f246632a46421f.png) [@Guscht](https://forum.mikrotik.com/u/Guscht)\
**Post date:** [July 21, 2020, 8:57pm UTC](https://forum.mikrotik.com/t/dns-over-https/138774/126 "2020-07-21T20:57:38Z")

</div>

> [@](#):
>
> What ports does RouterOS use for DoH?
> 
> Stricly TCP 443 only?
> 
> Seems in some cases port 53, 853 is used: [https://en.wikipedia.org/wiki/DNS\_over\_HTTPS#Deployment\_scenarios](https://en.wikipedia.org/wiki/DNS_over_HTTPS#Deployment_scenarios)

I think you missunderstand the concept. In your LAN, the clients query your edge router as DNS-resolver unencrypted via port 53.  
The outgoing DNS query from your router to the public DoH-DNS server is encrypted and sent via port 443.  
The public DoH-DNS resolves the query itself unencrypted via port 53 (or via TLS over port 853).

This means DoH is no real end-to-end encryption. But it is a security benefit over all.  
So yes, the DoH part uses strictly port 443.

---

<div class="post-metadata">

**Author:** ![arrazib](https://forum.mikrotik.com/letter_avatar/arrazib/32/6_449c533f586939b6e5f246632a46421f.png) [@arrazib](https://forum.mikrotik.com/u/arrazib)\
**Post date:** [July 30, 2020, 6:23pm UTC](https://forum.mikrotik.com/t/dns-over-https/138774/127 "2020-07-30T18:23:56Z")

</div>

Dear Concern,  
I have successfully configured the system. It is showing me Verify that DoH is enabled and working. When I am torching WAN interface it is not showing me 1.1.1.1:443(http) rather showing me 1.1.1.1:53(dns). I dont know why it is happening. Is it any config error? Please let me know what to do if I want to solve the issue.

---

<div class="post-metadata">

**Author:** ![arrazib](https://forum.mikrotik.com/letter_avatar/arrazib/32/6_449c533f586939b6e5f246632a46421f.png) [@arrazib](https://forum.mikrotik.com/u/arrazib)\
**Post date:** [July 31, 2020, 9:02am UTC](https://forum.mikrotik.com/t/dns-over-https/138774/128 "2020-07-31T09:02:50Z")

</div>

I have successfully configured the system. It is showing me Verify that DoH is enabled and working. When I am torching WAN interface it is not showing me 1.1.1.1:443(http) rather showing me 1.1.1.1:53(dns). I dont know why it is happening. Is it any config error? Please let me know what to do if I want to solve the issue.

---

<div class="post-metadata">

**Author:** ![vishvas](https://forum.mikrotik.com/letter_avatar/vishvas/32/6_449c533f586939b6e5f246632a46421f.png) [@vishvas](https://forum.mikrotik.com/u/vishvas)\
**Post date:** [August 11, 2020, 4:54pm UTC](https://forum.mikrotik.com/t/dns-over-https/138774/129 "2020-08-11T16:54:16Z")

</div>

Dear All  
has anybody tested IPV6 DNS over HTTPS?

---

<div class="post-metadata">

**Author:** ![DarkNate](https://forum.mikrotik.com/letter_avatar/darknate/32/6_449c533f586939b6e5f246632a46421f.png) [@DarkNate](https://forum.mikrotik.com/u/DarkNate)\
**Post date:** [August 16, 2020, 12:04pm UTC](https://forum.mikrotik.com/t/dns-over-https/138774/130 "2020-08-16T12:04:06Z")

</div>

@normis

ROS keeps trying to use WAN1 for DoH even though WAN1 is down/disabled and WAN2 is active and reachable. Normal DNS works fine, only DoH keeps trying WAN1 even if the interface itself is manually disabled.

Steps to reproduce the bug

1. ISP 1 with Route distance 1
2. ISP 2 with Route distance 2
3. Disable ISP 1 or turn off the uplink device to simulate an unreachable state
4. Check the log and you’ll see DoH refuses to use ISP 2 no matter what

![](https://i.ibb.co/0hpqgKG/image.png)

---

<div class="post-metadata">

**Author:** ![DarkNate](https://forum.mikrotik.com/letter_avatar/darknate/32/6_449c533f586939b6e5f246632a46421f.png) [@DarkNate](https://forum.mikrotik.com/u/DarkNate)\
**Post date:** [August 16, 2020, 12:05pm UTC](https://forum.mikrotik.com/t/dns-over-https/138774/131 "2020-08-16T12:05:31Z")

</div>

> [@](#):
>
> Dear All  
> has anybody tested IPV6 DNS over HTTPS?

It seems to be working already as per the connection tracking in the firewall on IPv6, I can see DoH traffic to Cloudflare initiated by the client devices using advertised DNS from RouterOS.

---

<div class="post-metadata">

**Author:** ![fsgrbv](https://forum.mikrotik.com/letter_avatar/fsgrbv/32/6_449c533f586939b6e5f246632a46421f.png) [@fsgrbv](https://forum.mikrotik.com/u/fsgrbv)\
**Post date:** [August 16, 2020, 6:56pm UTC](https://forum.mikrotik.com/t/dns-over-https/138774/132 "2020-08-16T18:56:35Z")

</div>

> [@](#):
>
> Dear All  
> has anybody tested IPV6 DNS over HTTPS?

Yes. I’ve tested with:

```plaintext
/ip dns set use-doh-server=https://dns64.cloudflare-dns.com/dns-query verify-doh-cert=yes

```

Unfortunately, It does not work.  
  
  
Even though ipv6 works OK.

```plaintext
[admin@MikroTik] > put [resolve dns64.cloudflare-dns.com]
2606:4700:4700::64
[admin@MikroTik] > ping 2606:4700:4700::64      
  SEQ HOST SIZE TTL TIME STATUS                                         
    0 2606:4700:4700::64 56 61 24ms echo reply                                     
    1 2606:4700:4700::64 56 61 24ms echo reply                                     
    2 2606:4700:4700::64 56 61 23ms echo reply                                     
    sent=3 received=3 packet-loss=0% min-rtt=23ms avg-rtt=23ms max-rtt=24ms

```

IPv4 DoH (

```plaintext
/ip dns set use-doh-server=https://cloudflare-dns.com/dns-query verify-doh-cert=yes

```

) works OK too.

---

<div class="post-metadata">

**Author:** ![DarkNate](https://forum.mikrotik.com/letter_avatar/darknate/32/6_449c533f586939b6e5f246632a46421f.png) [@DarkNate](https://forum.mikrotik.com/u/DarkNate)\
**Post date:** [August 17, 2020, 7:56pm UTC](https://forum.mikrotik.com/t/dns-over-https/138774/133 "2020-08-17T19:56:47Z")

</div>

> [@](#):
>
> > [@](#):
> >
> > Dear All  
> > has anybody tested IPV6 DNS over HTTPS?
> 
> Yes. I’ve tested with:
> 
> ```plaintext
> /ip dns set use-doh-server=https://dns64.cloudflare-dns.com/dns-query verify-doh-cert=yes
> 
> ```
> 
> Unfortunately, It does not work.  
>   
>   
> Even though ipv6 works OK.
> 
> ```plaintext
> [admin@MikroTik] > put [resolve dns64.cloudflare-dns.com]
> 2606:4700:4700::64
> [admin@MikroTik] > ping 2606:4700:4700::64      
> SEQ HOST SIZE TTL TIME STATUS                                         
> 0 2606:4700:4700::64 56 61 24ms echo reply                                     
> 1 2606:4700:4700::64 56 61 24ms echo reply                                     
> 2 2606:4700:4700::64 56 61 23ms echo reply                                     
> sent=3 received=3 packet-loss=0% min-rtt=23ms avg-rtt=23ms max-rtt=24ms
> 
> ```
> 
> IPv4 DoH (
> 
> ```plaintext
> /ip dns set use-doh-server=https://cloudflare-dns.com/dns-query verify-doh-cert=yes
> 
> ```
> 
> ) works OK too.

_[dns64.cloudflare-dns.com](http://dns64.cloudflare-dns.com)_ is for NAT64 networks. In most cases ISPs give native IPv6 with CGNATted IPv4 or public IPv4.

\_[https://cloudflare-dns.com/dns-query\_](https://cloudflare-dns.com/dns-query_) would be the correct one to use, it works for both IPv4 and native IPv6.

---

<div class="post-metadata">

**Author:** ![Tubeorange667](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/tubeorange667/32/2612_2.png) [@Tubeorange667](https://forum.mikrotik.com/u/Tubeorange667)\
**Post date:** [August 18, 2020, 7:13am UTC](https://forum.mikrotik.com/t/dns-over-https/138774/134 "2020-08-18T07:13:26Z")

</div>

I got everything working with nextdns. Here is what i did.  
make sure you change for your config id): for Example if your id is “99b212” you can give … /ip dns set use-doh-server=[https://dns.nextdns.io/99b212](https://dns.nextdns.io/99b212) verify-doh-cert=yes  
if you want to display the device name just add it in the last after putting “/” like this … /ip dns set use-doh-server=[https://dns.nextdns.io/99b212/mikrotik](https://dns.nextdns.io/99b212/mikrotik)

```plaintext
tool fetch url=https://curl.haxx.se/ca/cacert.pem
/certificate import file-name=cacert.pem passphrase=""
/ip dns set servers=
/ip dns static add name=dns.nextdns.io address=45.90.28.0 type=A
/ip dns static add name=dns.nextdns.io address=45.90.30.0 type=A
/ip dns static add name=dns.nextdns.io address=2a07:a8c0:: type=AAAA
/ip dns static add name=dns.nextdns.io address=2a07:a8c1:: type=AAAA
/ip dns set use-doh-server=“https://dns.nextdns.io/<id>” verify-doh-cert=yes

```

![Untitled-1.jpg](https://data-discourse.cdn.mikrotik.com/original/3X/9/3/93d292d0e86bcfc51f6010d2f4a8764ddb564b10.jpeg)

---

<div class="post-metadata">

**Author:** ![Pea](https://forum.mikrotik.com/letter_avatar/pea/32/6_449c533f586939b6e5f246632a46421f.png) [@Pea](https://forum.mikrotik.com/u/Pea)\
**Post date:** [August 18, 2020, 7:38am UTC](https://forum.mikrotik.com/t/dns-over-https/138774/135 "2020-08-18T07:38:54Z")

</div>

Why do you import all 138 CA certificates? Isn’t it better do import only the one needed?

---

<div class="post-metadata">

**Author:** ![Tubeorange667](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/tubeorange667/32/2612_2.png) [@Tubeorange667](https://forum.mikrotik.com/u/Tubeorange667)\
**Post date:** [August 18, 2020, 8:00am UTC](https://forum.mikrotik.com/t/dns-over-https/138774/136 "2020-08-18T08:00:17Z")

</div>

> Why do you import all 138 CA certificates? Isn’t it better do import only the one needed?

I did not find anything specific in the certificate list which points to “nextdns”. so i imported all. How can i find the one which is used by nextdns?

---

<div class="post-metadata">

**Author:** ![Pea](https://forum.mikrotik.com/letter_avatar/pea/32/6_449c533f586939b6e5f246632a46421f.png) [@Pea](https://forum.mikrotik.com/u/Pea)\
**Post date:** [August 18, 2020, 8:04am UTC](https://forum.mikrotik.com/t/dns-over-https/138774/137 "2020-08-18T08:04:11Z")

</div>

Just try with this one:  
 ![cert.png](https://data-discourse.cdn.mikrotik.com/original/3X/f/e/fe27641ff23f834c9665c6db0107edbc737e15db.png)

---

<div class="post-metadata">

**Author:** ![Tubeorange667](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/tubeorange667/32/2612_2.png) [@Tubeorange667](https://forum.mikrotik.com/u/Tubeorange667)\
**Post date:** [August 18, 2020, 9:07am UTC](https://forum.mikrotik.com/t/dns-over-https/138774/138 "2020-08-18T09:07:41Z")

</div>

I am not finding anything like that in the certificates list. I tried to remove everything except the name 'digicert". But thats not working. it does not starts with this name. its something else.

---

<div class="post-metadata">

**Author:** ![nrgch](https://forum.mikrotik.com/letter_avatar/nrgch/32/6_449c533f586939b6e5f246632a46421f.png) [@nrgch](https://forum.mikrotik.com/u/nrgch)\
**Post date:** [September 21, 2020, 6:53pm UTC](https://forum.mikrotik.com/t/dns-over-https/138774/139 "2020-09-21T18:53:10Z")

</div>

Is it possible, that i’m getting “DoH server connection error: Idle timeout - waiting data” because i’m using two different ISPs at the same time on one PC with two ethernet adapters and two different routers and they don’t know anything about each other?  
2nd router is not Mikrotik and it’s not logging any problems about DoH.  
Other than that log message i’m not having any problems with internet connectivity, whether it is any router separately or both at the same time. Both are configured properly for using DoH.  
I’m just curious about that log message, nothing more. Everything’s working just fine.  
Thanks.

---

<div class="post-metadata">

**Author:** ![IYARINDRA](https://forum.mikrotik.com/letter_avatar/iyarindra/32/6_449c533f586939b6e5f246632a46421f.png) [@IYARINDRA](https://forum.mikrotik.com/u/IYARINDRA)\
**Post date:** [October 12, 2020, 8:20am UTC](https://forum.mikrotik.com/t/dns-over-https/138774/140 "2020-10-12T08:20:42Z")

</div>

> [@](#):
>
> Any guide for Google DoH settings ?

> ```plaintext
> 
> ```

### Google DoH

/ip dns set servers=8.8.8.8,8.8.4.4  
/system ntp client set enabled=yes [primary-ntp=time.google.com](http://primary-ntp=time.google.com)  
/tool fetch url=[https://pki.goog/roots.pem](https://pki.goog/roots.pem)  
/certificate import file-name=roots.pem passphrase=""  
/ip dns set use-doh-server=[https://dns.google/dns-query](https://dns.google/dns-query) verify-doh-cert=yes  
/ip dns set allow-remote-requests=yes cache-max-ttl=1d use-doh-server=[https://dns.google/dns-query](https://dns.google/dns-query) verify-doh-cert=yes  
/ip dns static  
add address=8.8.8.8 name=dns.google  
add address=8.8.4.4 name=dns.google  
/ip dns set servers=""

### Script for certfificates update

/system script add dont-require-permissions=no name=Certificate\_Google policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="/tool fetch url=[https://pki.goog/roots.pem\r\n/certificate](https://pki.goog/roots.pem%5Cr%5Cn/certificate) import file-name=roots.pem passphrase="""

### Script for DNS cache flush

/system script add dont-require-permissions=no name=DNS\_Flush\_Cache policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="/ip dns cache flush"

### Schedule to update google certificate once a week

/system scheduler add comment="Google Certificate Update" interval=1w name=Certificate\_Google\_Update on-event=Certificate\_Google policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon start-date=dec/06/2019 start-time=05:20:00

### Schedule to flush dns cache everyday

/system scheduler add comment="DoH Cache Flush" interval=1d name="DNS Cache Flush" on-event=DNS\_Flush\_Cache policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon start-date=dec/06/2019 start-time=05:30:00

```auto
>
```

[Previous page](https://forum.mikrotik.com/t/dns-over-https/138774.md?page=6)

[Next page](https://forum.mikrotik.com/t/dns-over-https/138774.md?page=8)
