Skip to content

Gravity and Blocklists

Scope: where the refused names come from — public blocklists compiled by "gravity", the exact and regex lists you keep yourself, the allowlist that wins arguments, blocking modes, and how the engine explains a refusal. Gravity's download-and-compile run is the one piece the lab could not execute; everything the compiled result does was proven live.

Gravity, in one paragraph

A blocklist (Pi-hole calls them adlists) is a published text file of domain names someone maintains — tens of thousands of names whose business is ads, tracking, or worse. Pi-hole ships with one well-kept starter list and room for as many more as you care to add. Periodically — weekly by default on a full install, and whenever you ask — a script named gravity downloads every enabled list, reads the names out of whatever format they arrived in, and compiles them into a database table the engine can consult at question speed. The engine never parses lists at answer time; it asks the compiled database. In the lab's final statistics that database reported itself plainly:

"gravity": {
  "domains_being_blocked": 3,
  ...
}

Three, because the lab's specimen list had three names on it. A household install will show a number in the hundreds of thousands, which is a fact about list sizes, not a score to maximise — a bloated list mostly buys false refusals (chapter 9 and the recipes chapter both return to this).

The lab's list, and what gravity would have done

The lab's adlist was a file of invented names under the reserved .test TLD (examples/specimen-blocklist.txt):

ads.specimen.test
telemetry.specimen.test
tracker.specimen.test

Registered in the database as an adlist pointing at that file, its names compiled into the gravity table, and the database's own count updated to match — precisely the rows gravity writes, planted by hand because the engine alone has no gravity script to run (asked through the API, it says so: Gravity failed, transcript t06). The engine's side of the bargain is fully real, and this is it answering:

$ dig @127.0.0.1 -p 8053 ads.specimen.test A +tcp
; EDE: 15 (Blocked): (gravity)
ads.specimen.test.  2   IN  A   0.0.0.0

The (gravity) annotation is the engine citing its source — an Extended DNS Error that supporting tools display, and the same word the query log uses as the query's status (chapter 6). It is a small thing and a good habit: a refusal that names its reason can be argued with.

Your own lists: exact and regex

Public lists are other people's judgement. The lists you will actually touch live one level up, and all four were live in the lab:

List Matches Lab example
Deny, exact one name, exactly popups.specimen.test
Deny, regex any name the pattern fits ^ads[0-9]+\.specimen\.test$
Allow, exact one name, exempted (wins over every deny)
Allow, regex names the pattern exempts (wins over every deny)

The exact deny, added through the same API the web interface calls, answered like this, and the log called it DENYLIST where gravity's was GRAVITY:

$ dig @127.0.0.1 -p 8053 popups.specimen.test A +tcp +short
0.0.0.0

The regex earns its row. One pattern, ^ads[0-9]+\.specimen\.test$, refuses a whole family of names that no list could enumerate — here is it catching a name that exists on no list anywhere:

$ dig @127.0.0.1 -p 8053 ads42.specimen.test A +tcp
; EDE: 15 (Blocked): (regex)
ads42.specimen.test.    2   IN  A   0.0.0.0

Regular expressions are power tools: the same syntax that catches ads42 can, in a careless moment, refuse half the internet for the whole house. The engine ships a tester (pihole-FTL regex-test <name>) for checking a string against your patterns before a device discovers the mistake. Allowlists are the counterweight — an allowed name is exempt from gravity and deny lists alike — and they are how a broken login page gets fixed without switching the whole filter off (recipes, chapter 10).

Blocking modes: the shape of a refusal

"Refused" is configurable. The lab ran the default, NULL mode: the answer is 0.0.0.0 (and :: for IPv6 questions) — a real answer pointing nowhere, which most software accepts quickly and quietly. The alternatives a full install offers include answering NXDOMAIN (the name formally does not exist — some apps retry less, some misbehave more), answering with the Pi-hole's own address (the v4-era behaviour that let a block page appear, mostly of historical interest now that the web is encrypted), and two forms for specialised setups. The mode is one setting (dns.blocking.mode), it applies to gravity and deny lists alike, and NULL is the default because it breaks the fewest things while still being a brick wall: a device cannot fetch from an address that isn't one.

One timing fact the lab learned the observable way: a blocked answer is cached like any other, with a two-second lifetime here. Change a rule and immediately re-ask, and you may be reading the old answer out of the cache — the group transcript (t04) contains one such ghost, left in deliberately. When a test seems to ignore your change, wait a breath and ask again before doubting the rule.

Check: a name you have never heard of is blocked for your whole house — the three possible citable reasons in the log are GRAVITY (a list), DENYLIST (your exact rule), and REGEX (your pattern). Chapter 4 turns from names you refuse to names you invent: your own machines.