Using /etc/hosts to block domains

Expected Behavior:

When I put the line "127.0.0.1 self.events.data.microsoft.com" or
"0.0.0.0 self.events.data.microsoft.com" in the raspberry pi running pihole /etc/hosts file, then
it used to be blocked "before" pihole (ie, it did not appear in the pihole blocked gravity list -
was "pre-filtered" also reducing the percentage blocked).

Actual Behaviour:

self.events.data.microsoft.com is blocked by gravity in pihole blocked list.

This used to work, reducing the "excess clutter" in my blocked list, and the % blocked.

I understand the "The order of locally defined DNS records." Is there a way to "block"
self.events.data.microsoft.com so it does not appear in the blocked pihole gravity list?

Thanks, Peter Henderson

The hosts file is not part of DNS resolution.

It may be consulted by RPi OS's glibc before formulating a DNS request, and only for name resolution requests issued by some software on the same machine.

But why would your Raspberry query that self.events.data.microsoft.com?

That's likely issued by a Windows OS, so a Windows client has sent an explicit DNS request to Pi-hole.

You could consider to edit the hosts file on that Windows client (e.g. How to edit the hosts file on Windows, Mac, or Linux - SiteGround KB) in order to prevent it from sending a DNS request to Pi-hole.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.