2022-01-02 22:21:20 +01:00
Manage DNS and DoH servers from netwatch
========================================
2024-03-06 14:30:18 +01:00
[](https://github.com/eworm-de/routeros-scripts/stargazers)
[](https://github.com/eworm-de/routeros-scripts/network)
[](https://github.com/eworm-de/routeros-scripts/watchers)
2024-08-28 08:53:20 +02:00
[](https://mikrotik.com/download/changelogs/)
2024-03-06 14:30:18 +01:00
[](https://t.me/routeros_scripts)
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick& hosted_button_id=A4ZXBD6YS2W8J)
2023-01-10 14:45:27 +01:00
[⬅️ Go back to main README ](../README.md )
2022-01-02 22:21:20 +01:00
2022-02-12 13:05:56 +01:00
> ℹ ️ **Info**: This script can not be used on its own but requires the base
2022-02-11 23:34:39 +01:00
> installation. See [main README](../README.md) for details.
2022-01-02 22:21:20 +01:00
Description
-----------
This script reads server state from netwatch and manages used DNS and
DoH (DNS over HTTPS) servers.
Requirements and installation
-----------------------------
Just install the script:
$ScriptInstallUpdate netwatch-dns;
Then add a scheduler to run it periodically:
2022-05-11 10:19:11 +02:00
/system/scheduler/add interval=1m name=netwatch-dns on-event="/system/script/run netwatch-dns;" start-time=startup;
2022-01-02 22:21:20 +01:00
Configuration
-------------
The DNS and DoH servers to be checked have to be added to netwatch with
specific comment:
2022-07-05 13:16:47 +02:00
/tool/netwatch/add comment="doh" host=1.1.1.1;
/tool/netwatch/add comment="dns" host=8.8.8.8;
2022-07-05 13:29:00 +02:00
/tool/netwatch/add comment="doh, dns" host=9.9.9.9;
2022-01-02 22:21:20 +01:00
This will configure *cloudflare-dns* for DoH (`https://1.1.1.1/dnsquery` ), and
2022-07-05 13:29:00 +02:00
*google-dns* and *quad-nine* for regular DNS (`8.8.8.8,9.9.9.9` ) if up.
2022-01-02 22:21:20 +01:00
If *cloudflare-dns* is down the script will fall back to *quad-nine* for DoH.
Giving a specific query url for DoH is possible:
2022-09-13 11:05:16 +02:00
/tool/netwatch/add comment="doh, doh-url=https://dns.nextdns.io/dns-query" host=199.247.16.158;
2022-01-02 22:21:20 +01:00
Note that using a name in DoH url may introduce a chicken-and-egg issue!
2023-11-27 13:17:17 +01:00
Adding a static DNS record has the same result for the url, but always
resolves to the same address.
2025-02-05 09:51:42 +01:00
/ip/dns/static/add name="cloudflare-dns.com" address=1.1.1.1;
/tool/netwatch/add comment="doh" host=1.1.1.1;
2023-11-27 13:17:17 +01:00
Be aware that you have to keep the ip address in sync with real world
manually!
2024-10-31 15:17:31 +01:00
Importing a certificate automatically is possible. You may want to find the
[certificate name from browser ](../CERTIFICATES.md ).
2022-09-13 09:01:40 +02:00
2024-06-20 10:55:13 +02:00
/tool/netwatch/add comment="doh, doh-cert=DigiCert Global Root G2" host=1.1.1.1;
2024-08-27 10:59:51 +02:00
/tool/netwatch/add comment="doh, doh-cert=DigiCert Global Root G3" host=9.9.9.9;
2024-06-20 10:38:35 +02:00
/tool/netwatch/add comment="doh, doh-cert=GTS Root R1" host=8.8.8.8;
2022-09-13 09:01:40 +02:00
2025-02-05 09:55:41 +01:00
> ⚠️ **Warning**: Combining these techniques can cause some confusion and
> troubles! Chances are that a service uses different certificates based
> on indicated server name.
2022-01-02 22:21:20 +01:00
Sometimes using just one specific (possibly internal) DNS server may be
desired, with fallback in case it fails. This is possible as well:
2022-07-05 13:16:47 +02:00
/tool/netwatch/add comment="dns" host=10.0.0.10;
/tool/netwatch/add comment="dns-fallback" host=1.1.1.1;
2022-01-02 22:21:20 +01:00
Tips & Tricks
-------------
### Use in combination with notifications
Netwatch entries can be created to work with both - this script and
[netwatch-notify ](netwatch-notify.md ). Just give options for both:
2022-07-05 13:23:34 +02:00
/tool/netwatch/add comment="doh, notify, name=cloudflare-dns" host=1.1.1.1;
2022-01-02 22:21:20 +01:00
Also this allows to update host address, see option `resolve` .
See also
--------
2024-10-31 15:17:31 +01:00
* [Certificate name from browser ](../CERTIFICATES.md )
2022-01-02 22:21:20 +01:00
* [Notify on host up and down ](netwatch-notify.md )
---
2023-01-10 14:45:27 +01:00
[⬅️ Go back to main README ](../README.md )
[⬆️ Go back to top ](#top )