Possible to enable local DNS caching?

  • Hello,

    I recently switched over from OSMC to LibreELEC. I'm really liking it but I'm having one problem. I'm a frequent user of the Twitch addon for Kodi and it uses HLS streaming. For every segment there is a DNS query. In OSMC it was possible to configure Connman to enable local DNS caching (DNS proxy?). Without it there's an obscene amount of DNS queries from the addon quickly filling the log space on a Pi-hole device that I'm running as DNS server in the network.

    I don't know why DNS caching is disabled by default, or if it's a good idea to enable it or not, but is it possible in LibreELEC?

  • connmand is started with the option -r disabling the DNS proxy.

    Copy the /usr/lib/systemd/system/connman.service file to /storage/.config/system.d/, change the ExecStart=... line and reboot.

  • connmand is started with the option -r disabling the DNS proxy.

    Copy the /usr/lib/systemd/system/connman.service file to /storage/.config/system.d/, change the ExecStart=... line and reboot.

    Sorry, I'm a bit of a linux noob. What does this accomplish exactly? What should I change in the line? Just remove the r in -nr?

    ExecStart=/bin/sh -c ". /usr/lib/connman/connman-setup; exec /usr/sbin/connmand -nr $CONNMAN_MAIN $CONNMAN_DEBUG"

    Also, what about this "ExecStartPre=" line?

    ExecStartPre=-/bin/sh -c "echo -e 'nameserver 8.8.8.8\nnameserver 8.8.4.4' > /etc/resolv.conf"

    Does this mean it sets Google DNS as default? Because I don't want that.

    • Official Post

    DNS caching is disabled by default because it results in the Kodi GUI showing 127.0.0.1 as the DNS server and 9/10 n00b users trying to solve any networking problem wrongly point the finger and report "DNS is broken" as the bug. If we disable it, Kodi reports whatever the DHCP server sets as your DNS servers and all the bug reports stop. The secondary reason is that we found it to be occasionally problematic, and the genuine bug reports also stopped once it was disabled.

  • DNS caching is disabled by default because it results in the Kodi GUI showing 127.0.0.1 as the DNS server and 9/10 n00b users trying to solve any networking problem wrongly point the finger and report "DNS is broken" as the bug. If we disable it, Kodi reports whatever the DHCP server sets as your DNS servers and all the bug reports stop. The secondary reason is that we found it to be occasionally problematic, and the genuine bug reports also stopped once it was disabled.

    I see, thank you for the info. Well, I never experienced any problems with having it enabled with OSMC so I'd like to try enabling it. It's a must if using the Twitch addon, otherwise I'll see over 50k external DNS queries each day. Is what mglae suggested the correct way of going about this?

  • Usually you'll have a caching DNS server running on your router so there's no need to run another DNS cache on each system in your LAN.

    so long,

    Hias

  • Sorry, I'm a bit of a linux noob. What does this accomplish exactly? What should I change in the line? Just remove the r in -nr?

    Yes, only remove the 'r'. Be careful, you loose networking if there is anything wrong with this file.

    Does this mean it sets Google DNS as default? Because I don't want that.

    Google DNS is the default until any other name server is defined manually or via DHCP.

  • Usually you'll have a caching DNS server running on your router so there's no need to run another DNS cache on each system in your LAN.

    so long,

    Hias

    I understand my situation may be unique. It's not possible to run a Pi-hole DNS server with logging enabled and the Twitch Kodi addon unfortunately. Pi-hole uses RAM disk for log files and it fills up very quickly with the obscene amount of DNS queries HLS streaming generates. Also I'm not sure if my router caches DNS or not and I don't feel comfortable making that amount of DNS queries to an external DNS server even if I chose to bypass my Pi-hole server. The solution to run connman proxy worked fine using OSMC so I hope it will in LibreELEC too.

    Edited 2 times, last by osen (July 28, 2018 at 4:26 AM).

  • Yes, only remove the 'r'. Be careful, you loose networking if there is anything wrong with this file.

    Google DNS is the default until any other name server is defined manually or via DHCP.


    Thank you very much. I did as you instructed and it seems like Connman is running, but I'm note 100% sure. According to systemctl the service is running (active). Kodi now reports DNS server as 127.0.0.1 just as chewitt pointed out. Amount of DNS queries in my Pi-hole log while watching Twitch seems to have gone down, but I'll have to let it run for a while to make sure.

    • Official Post

    Your solution is a bit "wagging the dogs tail to make the head move" and it's years since I encountered a non-caching DNS server in a router so IMHO the correct solution is to disable logging in pi-hole so it doesn't fill the ramdisk, or change the location to somewhere with more space.

  • Your solution is a bit "wagging the dogs tail to make the head move" and it's years since I encountered a non-caching DNS server in a router so IMHO the correct solution is to disable logging in pi-hole so it doesn't fill the ramdisk, or change the location to somewhere with more space.

    What are the disadvantages of this solution? I use the logging feature of Pi-hole to monitor traffic and blocked requests so I really don't want to disable it. Unfortunately it seems like it's not possible to omit a single device from the logging, otherwise that would be a solution. RAM disk is used to reduce wear on the SD card and adding another kind of storage seems like a huge waste, it would just be filled by useless data anyway.

  • You log each and every DNS query in order to compare your blocklists to the actual requests ["monitor traffic"]? It would make marginal sense in a test environment, but either you have way too much time in your hands, or there is something fundamentally wrong with the browsing habits. Just drop the logging, it's borderline insanity :)

  • You log each and every DNS query in order to compare your blocklists to the actual requests ["monitor traffic"]? It would make marginal sense in a test environment, but either you have way too much time in your hands, or there is something fundamentally wrong with the browsing habits. Just drop the logging, it's borderline insanity :)

    It's not like it's something I'm doing manually. Maybe I didn't express myself clearly, english is not my native language. Pi-hole generates statistics from the logs, such as top blocked domains, number of DNS requests from different devices etc. Among other things I use it to block telemetry and phoning home activities originating from Windows and Android devices. I like to keep an eye on the stats a couple of times a month to make sure it's working (a couple of times there's been problems with the blocking) and check if anything abnormal is going on. I don't see why this is insanity, it's one of the main features of Pi-hole.

    The only thing causing a problem with this setup is the Twitch Kodi addon. Enabling the Connman DNS proxy has eliminated the problem and I don't experience any side effects from what I can tell. I watch Twitch using HLS on a couple of Windows devices as well and they seem to be using local DNS cache as they don't generate anywhere near the amount of queries. So I'm still wondering what the downsides are to this solution.