How to add multiple hostnames to blacklist.txt?

Hello,

just set up my Pi-hole yesterday on a Pi 3 Model B with Raspbian; and I must say that I'm impressed, both regarding the painless setup process and the smooth usage.

Now, I want to transfer a number of hostnames (around 10,000) from my customized local hosts file to the blacklist.txt. However, I couldn't find a good way to easily add this number of hostnames. Here's what I tried:

  • Entering each through the dashboard is obviously not an option due to the sheer number of hostnames.
  • I tried to copy&paste the hostname list into a terminal line as pihole -b hostname_1 hostname_2 [...] hostname_n - but just the parsing on the screen took ages, and I felt that I might overburden my Pi by shoehorning 10,000+ arguments in one line, so I canceled that approach
  • Directly editing the blacklist.txt failed, too (it was write-protected when trying via SSH).

Is there a good approach for my task? As a workaround, I could of course add a link to my hosts file to /etc/pihole/adlists.default, but this seems clunky. Also, I was wondering if it is recommended to weed out duplicates from other lists (for performance or other reasons)? If so, is there an easy way to do so?

Thanks much and kudos again for the Pi Hole project!

We source hostlists from various locations around the Internet. So the best way would be to mimic our current approach. Set up a private GitHub repository, or even set up something like Apache2 on the Pi 3 itself, to serve your hosts list as a file. Then just add the URL to the adlist that you can customize per the instructions in the header, and your list will fall right in with all the other domains. Deduplication and unification is already handled by the scripts.

Thanks for the quick reply!

So the blacklists.txt approach seems to be for the occasional manual hostname addition only? That would explain why I couldn't find a way to resolve my issue... :slight_smile:

I'll try your suggestion and will make an addition to adlist. Can I find additional information somewhere about the results of my efforts? I know there's the total hostname count in the dashboard; if I can evaluate additional stats (e.g. number of duplicates found) that would be great. Thanks!

We currently don't measure any metrics like that, but that does sound like a great feature to have, what values would you be interested in seeing. And would the current way we echo the values out via the gravity.sh output work, or would you be looking for something more along the lines of an api call that listed the values?

No idea; I haven't yet actively used gravity.sh. :slight_smile: I'll fiddle around with it and see what it produces. Thanks!

An example gravity ouput:

adam@adam-debian:/etc/.pihole$ pihole -g
[sudo] password for adam:
:::
::: Neutrino emissions detected...
:::
::: Custom adList file detected. Reading... done!
:::
::: Getting raw.githubusercontent.com list... List updated, transport successful!
::: Getting mirror1.malwaredomains.com list... No changes detected, transport skipped!
::: Getting sysctl.org list... No changes detected, transport skipped!
::: Getting zeustracker.abuse.ch list... No changes detected, transport skipped!
::: Getting s3.amazonaws.com list... No changes detected, transport skipped!
::: Getting s3.amazonaws.com list... No changes detected, transport skipped!
::: Getting hosts-file.net list... No changes detected, transport skipped!
::: Getting raw.githubusercontent.com list... List updated, transport successful!
::: Getting ransomwaretracker.abuse.ch list... List updated, transport successful!
:::
::: Aggregating list of domains... done!
::: Formatting list of domains to remove comments.... done!
::: 127599 domains being pulled in by gravity...
::: Removing duplicate domains.... done!
::: 103435 unique domains trapped in the event horizon.
:::
::: Adding adlist sources to the whitelist... done!
::: Whitelisting 10 domains... done!
::: BlackListing 1 domain... done!
::: Formatting domains into a HOSTS file...
:::
::: Cleaning up un-needed files... done!
:::
::: Refresh lists in dnsmasq...
::: Pi-hole blocking is Enabled

Thanks! This looks informative enough for my purposes at the moment. I might come back with more specific ideas as I learn my way around Pi-hole...

Hey! I'm also really new to Pi Hole and also impressed of its power and easy way install. But I have some problems understanding the usage of 'adlist'.

I tried to add

"pihole-ytadblock/adverisment.txt at master · HenningVanRaumle/pihole-ytadblock · GitHub"

to the domain list using "http://pi.hole/admin/queryads.php" But that seams to be a wrong way to add stuff because I get the failure message "Invalid domain!"

What's the correct way to use the "adlist" function? (I know this is probably a really simple question but I can't figure it out reading the topics :no_mouth:)

Use winscp & putty

copy adlists.default to adlists.list - How do I add additional block lists to Pi-hole? - FAQs - Pi-hole Userspace

You are trying to add a URL where a domain is required. The domain is just github.com which I don't think you want to do. And queryads.php is the page to find if a domain is currently on any sourced lists.

@spacemonkey has the link that you should follow if you'd like to add that entire list to your blocking.