Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Adblocking with /etc/hosts

Share your HowTo, Documentation, Tips and Tricks. Not for support questions!.
Post Reply
Message
Author
User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Adblocking with /etc/hosts

#16 Post by Head_on_a_Stick »

kevinthefixer wrote:
Ran into dependency problems with this one (running Stretch)
You can use the supplied hosts file directly instead.
milomak wrote:how is this better than say using ublock origin?
It blocks the bad addresses for all software and it operates with zero overhead, unlike a plugin.
deadbang

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Adblocking with /etc/hosts

#17 Post by debiman »

bedtime wrote:
debiman wrote:i've been using https://github.com/gaenserich/hostsblock for years.
I installed this program, and it renamed my home directory to 'hostsblock'. Anyhow, long story short, I ended up losing a bunch of files whilst uninstalling and getting things back to normal—config files and scripts that took hours and hours to make. :(

Please be careful if you chose to install this app.
you are right, and i am very, very sorry.
i guess you were using the install.sh script? I had problems with it, too, but the developer said they fixed it.
may i ask which version / how you installed? maybe i should re-open that issue:
https://github.com/gaenserich/hostsblock/issues/87

fwiw, the AUR installation method has always been reliable, and so is the script once you have it installed properly.

edit:
seems i cannot re-open the issue, i created a new one:
https://github.com/gaenserich/hostsblock/issues/88

bedtime
Posts: 146
Joined: 2012-12-16 19:34
Has thanked: 1 time
Been thanked: 6 times

Re: Adblocking with /etc/hosts

#18 Post by bedtime »

debiman wrote:
bedtime wrote:
debiman wrote:i've been using https://github.com/gaenserich/hostsblock for years.
I installed this program, and it renamed my home directory to 'hostsblock'. Anyhow, long story short, I ended up losing a bunch of files whilst uninstalling and getting things back to normal—config files and scripts that took hours and hours to make. :(

Please be careful if you chose to install this app.
you are right, and i am very, very sorry.
It's not at all your fault; you cannot be responsible for a program that somebody else maintains. We all know that there is a small risk when playing around with Github stuff. I took the chance, and I take responsibility.
i guess you were using the install.sh script? I had problems with it, too, but the developer said they fixed it.
may i ask which version / how you installed? maybe i should re-open that issue:
https://github.com/gaenserich/hostsblock/issues/87

fwiw, the AUR installation method has always been reliable, and so is the script once you have it installed properly.

edit:
seems i cannot re-open the issue, i created a new one:
https://github.com/gaenserich/hostsblock/issues/88
Not sure of the version, but I know that I used the generic OS .zip file and installed it using the install.sh: https://github.com/gaenserich/hostsbloc ... master.zip

Thank you so much for re-opening the bug. That was awesome of you! *gives a star* :D

I wonder why they opted to have this program make its own user? Security? Seems unnecessary to me. :?


Here is my—very crude—hosts setup that I use for now if anybody is interested:

Code: Select all

#!/bin/sh

if ! [ $(id -u) = 0 ]; then
   echo "This script must be run as root. Exiting."
   exit 1
fi

hostfile="/etc/hosts"
cd /home/user/scripts
echo "Updating hosts..."

echo "127.0.0.1       localhost\n127.0.1.1       debian.mydomain debian\n" > $hostfile

# Pick one filter below: Unified hosts = (adware + malware), Unified hosts + fakenews + gambling + social, Unified hosts + fakenews + gambling + porn + social
hostblockurl="https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts"
#hostblockurl="https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-social/hosts"
#hostblockurl="https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts"

# Append to hosts
wget -O - $hostblockurl >> $hostfile

file="hosts.txt"
# Check if primary (longterm) hosts file exists.
if [ -f "$file" ]; then
        echo "$file found. Skipping download."
else
        echo "$file not found. Retrieving file..."
        wget https://hosts-file.net/download/hosts.zip; unzip hosts.zip
fi

# Append to hosts
cat hosts.txt >> $hostfile

# Fetch and append secondary updated hosts (goes along with the above primary host file)
hostblockurl="https://hosts-file.net/hphosts-partial.txt"
wget -O - $hostblockurl >> $hostfile

blocked=$(wc -l /etc/hosts | awk '{print $1;}')
echo "Hosts blocked: "$blocked
As can be seen, it combines the Steve's Github hosts with the huge hosts-file.net hosts. Yes, it's redundant and inefficient (750,000+ hosts blocked, but who knows if half of them even still exist or how many overlap). It will suffice until I have the time to make it more proper.

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Adblocking with /etc/hosts

#19 Post by debiman »

just to clarify:
gaenserich's hostsblock itself works well; it's the install.sh script that doesn't.

but i agree that it's slightly overkill for the situation; otoh it's good to have multiple sources combined.
bedtime wrote:I wonder why they opted to have this program make its own user? Security? Seems unnecessary to me. :?
it didn't at first, then at some point they changed it.
makes sense to me; it's never good to download stuff from the internet as root (btw, apt is doing the same nowadays).
if you want to know exactly why i guess you'd need to go trawling the archlinux forums thread.

i'm keeping the new issue alive.
i know it might take a while til the developer answers, but they will evtl.

bedtime, which debian version?
anything particular we need to know about?

Post Reply