I have a VLAN for IoT devices that doesn't allow internet access.
It seems that the time on some IoT devices has drifted and therefore lights come on and off at the wrong time.
Presumably this is because they cannot reach a time server.
If I configure OpenWrt to serve time and DHCP Option 42, will the clients get time from OpenWrt? Does it depend whether the IoT devices have hard-coded NTP servers? Is NTP discoverable?
This is a long shot, but I experience it on some home-made ESP8266 thermometers I built about 10 years ago; if your IoT devices are similarly old, it might apply. The symptom on my devices is similar, they simply lose time lock and drift off into space.
From my notes:
I remedy this by making sure that the time server A record that the device is seeking is always in the router's dnsmasq cache by running a dig in a cron job on the router:
59 * * * * /usr/bin/dig -p 53 A time.nist.gov
Note also that the above 1-hour job interval requires ttl on the cache be set to a an hour:
Believe it or not, I did a rudimentary search before asking my question.
I was unaware of that option family 'any' directive. Will read up on that.
With config redirect, must there be a stanza for each subnet/VLAN?
I read elsewhere that it's not possible to use a src wildcard which is a shame.
Is the word redirect in option redirect user-defined? i.e. could I have option lan-redirect, option IoT-redirect etc.?
Does this proposed solution trap all NTP requests and redirect them, even if the destination NTP server is hard-coded in the IoT device?
I shall read up on DNS hijacking as it seems it is quite a popular topic and there are therefore more examples whcih can be applied to NTP as well.
I'm a little confused. It appears your solution is to cache the IP addresss for time.nist.gov in dnsmasq so it can be given to your ESP devices? This is so they can then get time from time.nist.gov via its IP address, rather than needing DNS?
I want to make my devices get time from a different place, i.e. OpenWrt.
Perhaps I could redirect requsts to time.nist.gov to the IP address of OpenWrt which is running an NTP daemon.
@lleachii
Sorry, I try to make things clear when I'm replying as sometimes threads get confusing
(maybe nested replies would be clearer, however I do really like this forum)
src 'any' would be good, I can't remember where I saw that you couldn't use a wildcard I mentioned that because brada4 had demonstrated it in the post you linked to above. brada4 showed that you could use option family 'any' instead of option dest and option dest_ip (in that example).
In the DNS Hijacking guide, it says to configure the firewall Source zone:lan. I tried following the guide in Luci and it is not possilbe to group select all internal interfaces to achieve src*. Would I be able to manually change that in /etc/config/firewall after using Luci to build the rule as per the guide? Or can I use a comma seperated list of interfaces?
Also in that guide, it explains how to redirect the hijacked DNS queries to another server, explaining that those DNS servers would have to be in a different subnet to avoid masquerading. I don't fully understand that
It's not a problem to have them in a different subnet, I would just like to understand the implication if they weren't.
Let's say I have OpenWrt on 192.168.1.1 and 2 pi-holes on 192.168.1.2 and 192.168.1.3.
I intercept all DNS requests on OpenWrt and redirect them to the pi-holes, where is the masquerading problem?
Continuing with the example devices above, I have a VPN gateway on OpenWrt which has a DNS server at the other end of the tunnel. I have configured OpenWrt to forward all DNS requests through the tunnel.
I have configured both pi-holes to use OpenWrt as their upstream DNS so that all DNS requests go through the pi-holes before the tunnel to remove ads etc.
If I now try and hijack the DNS requests on OpenWrt and send them to the pi-holes, I will end up with a loop won't I?
Would there be any way to exclude the pi-holes from the DNS hijacking?
Yes, the device uses the IP address, but it rotates constantly and you need to do a DNS query every time you check the site.
So, the device will still do DNS queries, but it gets resolved from the cache and only the A record is returned. It's basically using the router to do pre-processing of the full query by stripping all of the DNSSEC baggage, so the query response fits into one packet and doesn't need to restart the query using TCP (in order to handle the multi-packet response, which a lot of cheap/small/old IoT devices don't support in their DNS stack).