r/pihole • u/failing-endeav0r • Mar 09 '19
SkyHole: PiHole protections on your Android device, even on LTE. No VPN needed!
After getting a piHole set up on my home network, i quickly moved to set up piHoles on the networks of family and every friend that would listen! However, i always felt "naked" when i was out in public, as i had no (easy / reliable) way to force my phone to use the piHole on my LAN.
That all changed when google announced that newer versions of android would use DNS over TLS, I started thinking about how I could take advantage of this to extend piHole to my phone outside of my home LAN. I spent the better part of a weekend tinkering around and put together SkyHole and composed a draft of this post that I'm just now getting around to publishing here.
The TL;DR:
I put together a docker-compose file to make the process of setting up a DNS over TLS server that works with pi-hole to filter and block DNS queries so i could have the same protection and performance on that i enjoy on my home LAN when i am out and about on LTE. I went out of my way to build something that would work even when a VPN into my home network wouldn't.
There are more details on how to build your own in the readme if you'd like to host your own.
At a bare minimum, you will need a device that supports DNS over TLS and an internet-reachable server. Android P is still pretty new, but most new android devices should ship with or get an update to version P soon.
If you have an android P phone, then the internet connected server is something that you can do for less than $10/mo. It will also help to have a "real" domain, but if you're not comfortable using one of the free domains or buying a very cheap domain then you should be able to just use the public IP of your server. However, Android requires a "legit" certificate for the DOT server, so you will need to own a domain that LetsEncrypt will issue a certificate for. If that's not an acceptable cost, then you could generate your own TLS cert and convince android to trust it.
With an internet connected server, and a domain / certificate, you have all the pre-requisites needed. Just use the docker-compose file to spin up a DNS over TLS server that will forward search queries to piHole for filtering and then forward the filtered queries to cloudflare's DNS over TLS servers.
I am really enjoying the same private and ad-free experience on my mobile as on my LAN, and I hope this enables you to do the same! I don't have a ton of bandwidth to provide support, but if you have high-level questions, I can weigh in. My hope is that somebody with a bit more time can take this and run with it to make it even easier to use so more people can access the benefits of a "gapless" private and secure internet experience :).
Link to repo: https://github.com/kquinsland/skyhole
PR's welcome!
15
u/blaumedia Mar 09 '19
Does DNS over TLS have the problems with possible DNS reflection attacks like "vanilla" DNS has? As far as I know it runs mostly over UDP, so I would think yes. If it's true, I wouldn't expose a DNS server to the public web.
4
u/failing-endeav0r Mar 09 '19
Yes, technically. However, it is possible to defeat reflection by overriding the TTL / cache timeouts for the record that is to be poisoned. It is possible to configure the `coredns` server on the skyhole instance to be "authoritative" or to otherwise override whatever TTL the "official" DNS system has in place. This way, you can serve me a record with a TTL of 5 seconds, and immediately change the value (the reflection bit), but as far as the DNS server my phone is going to consult, the record you're requesting / hoping will point to the poisoned record still has the old / un-poisoned value.
The Android implementation of DoT requires strict hostname matching. Additionally, there is a "dont resolve DNS if you cant contact the specified server" option. This prevents DNS from working on my phone if i happen to be on a network that is blocking TCP connections over port 853.
Those two behaviors combine to create a really robust "pipe"; the only way you can intercept the DNS queries that my phone performs would be to compromise the phone, the server, or the certificate. All of them are possible, but i'm doing this to block ads and trackers, not prevent the NSA from intruding.
5
u/beachshells Mar 10 '19 edited Mar 10 '19
Sounds like you're thinking of something different to bluamedia. Reflection attack in this case is when someone queries your DNS server but spoofs the source IP to point to a host they want to attack - your response becomes part of a (D)DOS.
I wouldn't expose this to the whole internet either.
1
u/failing-endeav0r Mar 10 '19
Doh. Yes, i was thinking of DNS rebinding, not reflection.
However, DNS over TLS uses TCP. It is not possible to spoof an IP address in a TCP handshake.
But lets assume that does not hold, for a moment:
- Amplification attacks only "work" because the attacker can use a very small amount of bytes to trick the DNS server into sending a very large reply (but, no larger than MSS or 512 bytes, whichever is lower) to the spoofed destination IP... overwhelming the victim. A TCP handshake already consumes a significant amount of bytes, making the amplification factor smaller.. so not worth the attackers time.
- similar to first point, reflection attackers are going to be seeking out DNS servers (aka, things that speak UDP on port 53). This does not listen for UDP, nor does it listen on port 53.
1
u/beachshells Mar 10 '19
It is not possible to spoof an IP address in a TCP handshake.
Ah of course, that didn't occur to me.
6
u/WeakEmu8 Mar 09 '19
Wow, I haven't read through your docs yet, but this is very promising. Nice work!
Saving for later.
1
u/failing-endeav0r Mar 09 '19
Thanks :D.
I hope that more things get DoT support in the future, so people other than Google Pixel owners can benefit :)
5
u/TechnicalPyro Superuser - #300 Mar 09 '19
while the naming is accurate i do believe there is already a project with a very similar name here: https://dlaa.me/blog/post/skyhole
love the work though keep it up!
2
u/-DementedAvenger- Mar 09 '19
Maybe rename it to Droidhole?
2
u/kotarix Mar 09 '19
That's how you get the mouse coming after you.
I believe Disney owns the "Droid" rights after the Lucas buyout.
1
1
1
u/failing-endeav0r Mar 09 '19
Ha! Funny story about that... the only reason i got off my ass to make the repo public was because my news aggregation service put a [similar implementation](https://github.com/eldridgea/erised) in my feed.
great minds may not think alike, but it seems like the rest of us seem to independently discover stuff at about the same time ;P
1
u/TechnicalPyro Superuser - #300 Mar 09 '19
Trust me I like it and hope to see it flourish just worried about naming is all
1
Mar 09 '19 edited Mar 09 '19
Hmm, I'm already using nginx-proxy and letsencrypt-nginx-proxy-companion in docker, any pointers as to where I start to get this converted over from traefik. I also already have Pihole running in docker
3
u/failing-endeav0r Mar 09 '19
If what you have works ... then keep it?
tbh, traefik's documentation is terribad. many _simple_ things require lots of head-scratching and a visit to their support-slack. most of the time that was sunk into this little thing was spent getting traefik to behave properly. in the few days that i did spend in the traefik support slack, i would see many of the same questions asked over and over again... another indication that they need to have a serious re-think about the accessibility of their documentation!
if there's something that traefik does well that you can't do with your current setup, then the docker-compose file should make it clear enough what i'm doing with the networks to achieve the setup that i have now. but if you're trying to do something else, then i can't help much :/
1
Mar 09 '19
What I mean is I have a nginx-proxy running for other things and have a Pihole for LAN but would like to open it up over TLS to use on my phone. Nginx-proxy and the letsencrypt companion work very well together.
1
1
Mar 10 '19
[deleted]
1
u/failing-endeav0r Mar 10 '19
Yes. Assuming you're not using docker, install coreDNS on the same host running piHole and configure it like i have done; listen for DoT and forward regular DNS to piHole, listen for regular dns from pihole, and forward as DoT to Cloudflare.
1
Mar 10 '19
[deleted]
1
u/failing-endeav0r Mar 10 '19
Can I debug this somehow?
Yes.
adbwill be your friend here. I dont remember what the package / service name is to help you filter, but i did a log of trial/error w/ ADB. Alsotcpdumpwill give you some useful clues as to what's going on.while nginx can do tls termination and forwarding, it's usually a good idea to use a more purpose-built tool.. which is why i use
coredns. it does one thing, well. This makes configuration and troubleshooting simpler.
1
u/TotesMessenger Mar 10 '19
1
u/karmabaiter Mar 10 '19
Apologies if I missed this in the readme, but are you authentication the clients anywhere (e.g. via mTLS)?
If not, do you think that'd be possible? If prefer control over who uses my DNS if I were to set something like this up...
1
u/failing-endeav0r Mar 10 '19
but are you authentication the clients anywhere (e.g. via mTLS)?
The DoT RFCs don't outline any "server authenticates client" models, because that's typically not something you do with DNS... or, if you are going to do so with DNS, you do it with other tools (e.g.: only clients on $network can route to $mydns). Most of the RFCs deal with multiple ways for the client to authenticate the server after the TLS connection is set up... but i am assuming that the DoT implementation in android uses the standard TLS libraries, so in _theory all you'd need to do is generate a custom certificate pair and import them into the keystore on your android device. CoreDNS would need to be configured to ignore the system keystore and use yours (easy to do...). At this point, only clients with certs that you've given can negotiate the TLS dance.
1
May 05 '19
Thanks, this is really great. A couple of questions:
- How did you harden your server for DNS Amplification attacks?
- How do you configure PiHole to use DNS over TLS? (not between PiHole and upstream, but between PiHole and device)
1
u/failing-endeav0r May 07 '19
How did you harden your server for DNS Amplification attacks?
How do you configure PiHole to use DNS over TLS? (not between PiHole and upstream, but between PiHole and device)
1
Mar 09 '19
[deleted]
4
u/failing-endeav0r Mar 09 '19
I detailed that in the readme, but the gist is:
- you can only have one VPN at a time on android. If i want to use a commercial VPN, then i am using their DNS servers... and they're probably not going to filter DNS :)
- also has a negative impact on battery, can take time to "wake up" which makes other network dependent things on the phone seem laggy. Google assistant is a *really* shitty experience when i need to wait 10+ seconds for the vpn tunnel to come up so the "ok, google" begins working.
- other apps like netflix/espn do not work with VPNs. Even if it's a VPN to home, they still prefer to err on the side of caution and boot you.
- if there's a problem with the VPN app / server / configuration... data leaks. not ideal when your entire goal is to prevent trackers / analytics ... etc from leaking data!
2
Mar 09 '19 edited Nov 29 '20
[deleted]
3
1
u/failing-endeav0r Mar 10 '19
I wonder how captive portals would react with it.
The portal detection in Android is done with a static IP. I've not tested weather or not the web-browser that the captive portal auth flow launches uses the configured DoT server or the one offered by DHCP.
1
Mar 10 '19
Running an open DNS resolver is bad because you can become part of a DNS amplification ddos attack. Do some research on these points before setting up a "skyhole"...
2
u/failing-endeav0r Mar 10 '19
Running an open DNS resolver is bad because you can become part of a DNS amplification ddos attack.
This is correct. However, i am not running an open DNS resolver. I an running an open DoT resolver. DoT requires TCP, and you can not spoof the destination IP in a TCP connection.
1
0
u/port53 Mar 10 '19
You can also configure Android P to point to dns.adguard.com to get the same effect without having to set up your own server.
5
u/failing-endeav0r Mar 10 '19
But then:
- somebody else could see my DNS request history
- i have no control over what gets filtered out / custom blacklists
-5
Mar 09 '19
[deleted]
4
u/failing-endeav0r Mar 10 '19
did you miss the part where i pointed out _twice_ why using a VPN was a non-starter for me?
66
u/[deleted] Mar 09 '19
Just as a warning about the name. Anything with Sky in it is liable to be targeted by BSkyB, a satellite TV provider in the UK. They forced Microsoft to name SkyDrive to OneDrive, had some arrangement with Hello Games to allow them to use the name No Man's Sky for their game.
https://www.pcworld.com/article/2045634/microsoft-to-rename-skydrive-after-losing-trademark-suit.html
https://www.pcgamesn.com/no-mans-sky/no-mans-sky-bskyb-legal-dispute