This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| computing:dnshijacks [2026/09/06 13:57] – oemb1905 | computing:dnshijacks [2026/09/08 04:37] (current) – oemb1905 | ||
|---|---|---|---|
| Line 11: | Line 11: | ||
| ------------------------------------------- | ------------------------------------------- | ||
| - | This tutorial is for owner' | + | This tutorial is for owner' |
| - | + | ||
| - | LuCI → Network | + | |
| {{ : | {{ : | ||
| - | **2. Port 53/853 intercept | + | After your statics are set, the next task is to stop the cameras or IoT devices from directly querying external DNS servers. Most devices that do this directly contact the upstream DNS IP on either port 53 or port 853. It is true that 853 can be used for DoT - but that's not what we are stopping right now. Here, we are stopping alternate port direct udp DNS queries which can also use 853. To stop outgoing packets |
| - | LuCI → Network → Firewall → Port Forwards | + | * Name: Camera1 |
| + | * Restrict to address family: ipv4 #use what your devices use | ||
| + | * Protocol: TCP + UDP | ||
| + | * Source zone: res #pick your zone/subnet/ | ||
| + | * External port: 53 | ||
| + | * Destination zone: Any | ||
| + | * Internal IP address: 172.66.66.150 (ns5.haacksnetworking.org) #redirects traffic to my DNS server, a pihole + unbound | ||
| + | * Internal port: 53 | ||
| + | * Advanced Settings | ||
| + | * Source MAC address: 80: | ||
| - | < | + | Once this is done, duplicate the rule and change the external port to 853. If your devices listen on ipv6, make a separate ipv6 rule with a separate ipv6 DNS target. In my case, the v4 Wyze cameras I used only accepted ipv4 addresses. I checked on the router to be sure with '' |
| - | - Name: Camera1 | + | |
| - | - Restrict | + | |
| - | - Protocol: TCP + UDP | + | |
| - | - Source zone: res | + | |
| - | - External port: 53 | + | |
| - | - Destination zone: res | + | |
| - | - Internal IP address: 172.66.66.150 (ns5.haacksnetworking.org) | + | |
| - | - Internal | + | |
| - | + | ||
| - | Advanced Settings | + | |
| - | - Source MAC address: | + | |
| - | 80: | + | |
| - | 80: | + | |
| - | 80: | + | |
| - | 80: | + | |
| - | </ | + | |
| {{ : | {{ : | ||
| - | I decided | + | In the openWRT tutorial linked at the top, you will see that I use two nameservers for each vlan/ |
| - | **3. DoH / DoT drop** | + | |
| + | | ||
| + | * From: zone `res` | ||
| + | * Specify the MACs: 80: | ||
| + | * To: zone `wan` | ||
| + | * IPs to block: 1.1.1.1 1.0.0.1 8.8.8.8 8.8.4.4 9.9.9.9 149.112.112.112 94.140.14.14 94.140.15.15 208.67.222.222 208.67.220.220 185.228.168.9 185.228.169.9 76.76.2.0 76.76.10.0 45.90.28.0 45.90.30.0 2001: | ||
| + | | ||
| + | | ||
| - | LuCI → Network → Firewall → Traffic Rules. | + | The rule above includes both port 443 and 853. The inclusion of 853 is not for DoH, rather, it is included as an extra pre-caution for DoT. It's harmless to include and just in case a port forward for 853 DoT fails to work, this drop rule ensures that cams / IoT devices can't contact any of these IPs for DoT. The DoH is covered by 443 and the IPs specified are just the most common (Google, Cloudflare, etc.). One can and should monitor this list and include others; consult online sources for a comprehensive list and/or dedicated repository. Once that's done, you should have a rule that looks something like this: |
| - | < | + | {{ :computing:doh-revised.png? |
| - | - Name: `Camera DoH` | + | |
| - | - Family: IPv4 and IPv6 | + | |
| - | - From: zone `res` | + | |
| - | - Specify the MACs: | + | |
| - | 80: | + | |
| - | 80: | + | |
| - | 80: | + | |
| - | 80: | + | |
| - | - To: zone `wan` | + | Now that everything is setup, you need to ensure that there are no leaks. This is easily done with tcpdump on the router. There' |
| - | # Specify | + | |
| - | 1.1.1.1 | + | tcpdump -ni br-lan.179 host 172.66.66.105 or host 172.66.66.106 or host 172.66.66.107 or host 172.66.66.108 | egrep '(\.53 |\.853 )' |
| - | 1.0.0.1 | + | |
| - | 8.8.8.8 | + | This command above will pull out all 53 or 853 outgoing packets and you can see what upstream DNS the cams/IoT device is using. When I began this tutorial, I ran this command first and you could clearly confirm that online reports were correct and the Wyze v4 cams were sending outgoing udp/53 requests to 8.8.8.8 and 8.8.4.4, which are Google' |
| - | 8.8.4.4 | + | |
| - | 9.9.9.9 | + | |
| - | 149.112.112.112 | + | |
| - | 94.140.14.14 | + | |
| - | 94.140.15.15 | + | |
| - | 208.67.222.222 | + | |
| - | 208.67.220.220 | + | |
| - | 185.228.168.9 | + | |
| - | 185.228.169.9 | + | |
| - | 76.76.2.0 | + | |
| - | 76.76.10.0 | + | |
| - | 45.90.28.0 | + | |
| - | 45.90.30.0 | + | |
| - | - Ports: `443`, `853` | + | tcpdump |
| - | - Action: Drop | + | |
| - | </ | + | |
| - | {{ : | + | To be clear, the above command is checking both 53 and 853 for plain text udp requests. Although rare, you can do this on port 853 but do not confuse that with DNS over TLS, which I tested next. To my surprise, I initially saw requests sneaking out. As it turns out, this was because I had wrongly set the destination zone on the hijack to the same zone as the origin. This, however, is wrong because obviously these external IPs are not within the source zone. So, I removed the destination zone and left it as " |
| - | Then, once these are setup, confirm using tcpdump | + | |
| + | | ||
| - | tcpdump -ni eth1 udp port 53 and '( host 8.8.8.8 or host 8.8.4.4 or host 1.1.1.1 or host 1.0.0.1 or host 9.9.9.9 )' | + | I only ran these commands for port 853 because it is impossible to do DoT on port 53. After rebooting the devices a few times and waiting five minutes, I confirmed that there were no DoT requests sneaking out. I had not seen any during initial testing, nor did online sources state that v4 cams were known to do this, but it's harmless to set the logic and better safe than sorry. Now that those leaks were stopped and/or confirmed not happening, it was time to test DoH. Similarly, there were no reports online that Wyze cams using DoH, but there's no reason to let a firmware update add that feature down the road and then have no prohibition. Better to set the rule now instead of being sorry later. To confirm no DoH requests were getting out, I ran the following: |
| - | tcpdump -ni eth1 '(tcp port 443 or tcp port 853 or udp port 853)' and '(host 8.8.8.8 or host 8.8.4.4 or host 1.1.1.1 or host 1.0.0.1 or host 9.9.9.9 )' | + | |
| - | tcpdump -ni eth1 ip6 and udp port 53 and '( host 2001:4860: | + | |
| - | tcpdump -ni eth1 ip6 and '(tcp port 443 or tcp port 853 or udp port 853)' and '( host 2001: | + | |
| - | Or, run all at once: | + | |
| - | < | + | |
| - | tcpdump -ni eth1 ' | + | |
| - | ( | + | If the cams/IoT devices are sending out DoH requests, these commands will spot those leaks. Since I had not seen the Wyze v4 cams ping anything besides Google in testing, I restricted the commands to Google's DNS servers. If needed, however, you can adjust the IPs above to include all of the blocked IPs in the traffic rule above. Here are the more inclusive commands: |
| - | udp port 53 or | + | |
| - | | + | |
| - | tcp port 853 or | + | |
| - | udp port 853 | + | |
| - | ) and ( | + | |
| - | | + | |
| - | host 1.1.1.1 or host 1.0.0.1 or | + | |
| - | host 9.9.9.9 or | + | |
| - | | + | |
| - | host 2606: | + | |
| - | host 2620:fe::fe | + | |
| - | | + | |
| - | ' | + | |
| - | </ | + | |
| - | Or, to just check the cameras | + | tcpdump -ni eth1 tcp port 443 and '(host 8.8.8.8 or host 8.8.4.4 or host 1.1.1.1 or host 1.0.0.1 or host 9.9.9.9 or host 149.112.112.112 or host 94.140.14.14 or host 94.140.15.15 or host 208.67.222.222 or host 208.67.220.220 or host 185.228.168.9 or host 185.228.169.9)' |
| + | tcpdump -ni eth1 ip6 and tcp port 443 and '(host 2001:4860: | ||
| + | Once everything is set up and you've confirmed you have no leaks, you can return to your pihole dashboard and start evaluating urls that the cameras/IoT devices are contacting. Prior to this, the dashboard was empty, but now that direct udp on 53/853, DoT on 853, and DoH on 443 are all either hijacked or dropped, you should see it fill up nicely. Here's a shot from each pihole, ns5 and ns6, after a few minutes. | ||
| - | tcpdump -i br-lan.179 host 172.66.66.105 or host 172.66.66.106 or host 172.66.66.107 or host 172.66.66.108 -n | + | {{ : |
| + | {{ : | ||
| - | Or, just check outbound 53 / 853, direct udp: | + | For whatever reason, the cams are using FOUR timeservers! Also, despite turning off all cloud-based features, the Wyze cameras continually ping home to '' |
| - | tcpdump -i br-lan.179 host 172.66.66.105 or host 172.66.66.106 or host 172.66.66.107 or host 172.66.66.108 -n | egrep '(\.53 |\.853 )' | + | {{ : |
| - | + | ||
| - | Or, check 443 and 853 while stripping the okay stun/turn they need for the app: | + | |
| - | tcpdump -i br-lan.179 host 172.66.66.105 or host 172.66.66.106 or host 172.66.66.107 | + | So far, the piholes have not caught the v4s phoning home to any of these domains, but better safe than sorry. I also left four different tabs open in Terminator all night to confirm that nothing was sneaking out the wan interface that shouldn' |
| - | + | ||
| - | After catching some leaks due to destination zone being set on 53/853 direct udp, revised | + | |
| - | < | + | ------------------------------------------- |
| - | tcpdump | + | |
| - | (host 172.66.66.105 or host 172.66.66.106 or host 172.66.66.107 or host 172.66.66.108) | + | |
| - | and not ( | + | |
| - | udp port 123 or | + | |
| - | (udp portrange 10000-65535 and not udp port 53 and not udp port 853) | + | |
| - | ) | + | |
| - | ' | + | |
| - | </ | + | |
| - | You have to run tcpdump and bird's eye look at the pihole dashboard initially. You will suddenly see that the direct DNS udp/53 it runs to 8.8.8.8 and 8.8.4.4 that are widely reported are now being intercepted. You confirm on tcpdump by checking the wan outgoing ... to see if anything gets by. You can tell on the piholes because initially you won't see any domains, but as soon as you set up the forwards correctly, you will get a slew of domains popping off: | + | === Updates === |
| - | {{ : | + | * Installed conntrack on openWRT in order to confirm forwards and drops via kernel DRAFT |
| - | {{ : | + | * forthcoming |
| - | For whatever reason, | + | The simplest command is to see what is happening on the '' |
| - | {{ : | + | conntrack -L -f ipv4 | grep 172.66.66 |
| - | Alright, this is an improved version of my prior setup, dedicated to Bender. | + | To confirm direct udp 53/853 hijacks: |
| - | Notes: | + | conntrack -L -f ipv4 -p udp --orig-port-dst 53 |
| - | | + | |
| - | | + | |
| - | | + | |
| + | |||
| + | To confirm hijacks of DoT: | ||
| + | conntrack -L -f ipv4 -p tcp --orig-port-dst 853 | ||
| + | conntrack -L -f ipv6 -p tcp --orig-port-dst 853 | ||
| + | | ||
| + | To confirm drops of DoH requests: | ||
| + | |||
| + | conntrack -L -f ipv4 -p tcp --orig-port-dst 443 | grep -E ' | ||
| + | conntrack -L -f ipv6 -p tcp --orig-port-dst 443 | grep -Ei ' | ||
| + | | ||
| + | Or, query the kernel directly: | ||
| + | |||
| + | grep -E ' | ||
| + | | ||
| + | Also, one can layer 7 domain block these common DoH domains. This won't stop cams / IoT devices from using IPs, but it stops them from using domains: | ||
| + | |||
| + | < | ||
| + | `doh.dns.apple.com mask.icloud.com mask-h2.icloud.com dns.google dns.google.com google.dns dns64.dns.google cloudflare-dns.com mozilla.cloudflare-dns.com security.cloudflare-dns.com family.cloudflare-dns.com one.one.one.one 1dot1dot1dot1.cloudflare-dns.com dns.quad9.net dns10.quad9.net dns11.quad9.net dns.adguard.com dns-family.adguard.com dns.adguard-dns.com unfiltered.adguard-dns.com family.adguard-dns.com doh.opendns.com doh.familyshield.opendns.com doh.sandbox.opendns.com dns.nextdns.io firefox.dns.nextdns.io anycast.dns.nextdns.io dns.mullvad.net adblock.dns.mullvad.net base.dns.mullvad.net family.dns.mullvad.net unfiltered.dns.mullvad.net freedns.controld.com p0.freedns.controld.com p1.freedns.controld.com p2.freedns.controld.com p3.freedns.controld.com dns.sb doh.dns.sb doh.cleanbrowsing.org security-filter-dns.cleanbrowsing.org family-filter-dns.cleanbrowsing.org adult-filter-dns.cleanbrowsing.org dns.switch.ch doh.pi-dns.com doh.appliedprivacy.net odoh.cloudflare-dns.com` | ||
| + | </ | ||
| - | --- // | + | --- // |