hectorm / hblock

Improve your security and privacy by blocking ads, tracking and malware domains.
https://hblock.molinero.dev
MIT License
1.63k stars 104 forks source link

Questions for the Hero Dev #127

Closed birds-swim closed 1 year ago

birds-swim commented 1 year ago

I just found your app and I LOVE IT. I just have a few questions for you.

I don't fully understand networking on Linux, so bear with me. For context, I am a Debian/Arch user.

I want to take full advantage of your hblock software. Here are my questions:

1.) How do I FORCE my Linux system to consult first/prefer/use /etc/hosts file created by hblock? How do I ensure that, not just my web browser (Firefox or Brave), but all the apps and services on my system consult my /etc/hosts file first before making a DNS query?

2.) I wish to use NextDNS for my Linux laptop. How do I FORCE my Linux laptop to always, always, always consult my /etc/hosts file first AND THEN ask NextDNS for the DNS query?

I am concerned that, if I set this up, my apps and services will ignore hblock and NextDNS because of some unknown program or service running in the background (like dnsmasq vs unbound or something, I dunno) is changing how my system is doing DNS or networking.

How do I Scooby-Doo this stuff?

hectorm commented 1 year ago

This depends on your system configuration. If you are a Debian/Arch user, I assume you are using systemd and probably systemd-resolved as your local resolver, in which case if the ReadEtcHosts property in /etc/systemd/resolved.conf or /etc/systemd/resolved.conf.d/*.conf is set to yes (the default), then the entries in /etc/hosts will take precedence over DNS.

However, although it is not common, a program is not obliged to respect the DNS server configured on your system and can resolve domains using other methods instead.

You can experiment with the dig DOMAIN or resolvectl query DOMAIN commands to check that the answers you get are as expected.

birds-swim commented 1 year ago

This depends on your system configuration. If you are a Debian/Arch user, I assume you are using systemd and probably systemd-resolved as your local resolver, in which case if the ReadEtcHosts property in /etc/systemd/resolved.conf or /etc/systemd/resolved.conf.d/*.conf is set to yes (the default), then the entries in /etc/hosts will take precedence over DNS.

However, although it is not common, a program is not obliged to respect the DNS server configured on your system and can resolve domains using other methods instead.

You can experiment with the dig DOMAIN or resolvectl query DOMAIN commands to check that the answers you get are as expected.

That's correct: I am a systemd user. I use both Debian and Arch systems at the moment. I'd like to focus on Debian.

Would there be any noise from BIND and dnsmasq? And by "noise", I mean interference to systemd-resolved that would prevent me or a program from using /etc/hosts? Is it a matter of changing the settings/configs of BIND/dnsmasq or should I just remove those programs altogether focusing only on systemd to resolve?

Is there a short book, guide, or wiki I should be reading to get a better understanding of networking so I can achieve what I want?

If I understand your answer correctly, are you saying I would need to hunt down which programs/services are not honoring my /etc/hosts wishes? I'm guessing I'd then have to figure out how to FORCE those individual programs/services to honor my /etc/hosts file.

I will try those tools and see what I get. I have more reading to do....

hectorm commented 1 year ago

Since there is no problem with hBlock, I will close this issue.

For more information, I recommend reading the official documentation for each project. The Arch Linux and Gentoo wikis are also excellent resources.