You are not logged in.
Pages: 1
Topic closed
Is it possible to append a blocklist (er... redirectlist) to /etc/hosts somehow?
For example, mvps has been supplying a very nice list of known parasite websites for years. Basically, it just uses 127.0.0.1 to redirect known bad websites so they don't load. It's a nice system-wide method to block them. I have been pasting their list into my /etc/hosts but am wondering if I can someone call it as I do in bash scripts.
For example, this doesn't work, but you get idea:
$ cat /etc/hosts
127.0.0.1 localhost.localdomain localhost novelty
192.168.1.1 router
192.168.1.2 inky
192.168.1.3 blinky
. /etc/hostsmvps # try to load the mvps redirect list
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
cat file.txt >> /etc/hosts
as root (sudo will not work)
edit: this is not the requested solution. sorry.
Last edited by eldragon (2010-10-10 13:24:01)
Offline
Copy your local machine and network hosts to "/etc/hosts.local," then:
#!/bin/dash
### MVPS Hosts Updater #########
# Version 0.3 by Scott Garrett #
# Wintervenom [(at)] gmail.com #
################################
# Download the MVPS hosts file.
wget -c -O /tmp/hosts.txt http://www.mvps.org/winhelp2002/hosts.txt
# Be paranoid and replace every IP address with 0.0.0.0. We also get
# only want the actual blacklist, 'cause we want to prepend the user's
# own hosts. 0.0.0.0 is nicer than constantly knocking on localhosts' door.
sed -r -e 's:^([0-9]{1,3}\.){3}[0-9]{1,3}:0.0.0.0:' /tmp/hosts.txt > /tmp/hosts.new.txt
tail -n+`grep -nF 'start of lines' /tmp/hosts.new.txt | cut -d':' -f1` /tmp/hosts.new.txt > /tmp/hosts.txt
# Write this new list over the system hosts list. MVPS' line feeds
# are \n\r; we will be getting rid of those dirty carriage returns.
# We'll first write the user's hosts head, then the black list.
cat /etc/hosts.local > /etc/hosts
cat /tmp/hosts.txt | tr -d "\r" >> /etc/hosts
rm /tmp/hosts*.txt
# This is the end!
Last edited by Wintervenom (2010-10-10 15:57:35)
Offline
Copy your local machine and network hosts to "/etc/hosts.local," then:
#!/bin/dash ### MVPS Hosts Updater ######### # Version 0.3 by Scott Garrett # # Wintervenom [(at)] gmail.com # ################################ # Download the MVPS hosts file. wget -c -O /tmp/hosts.txt http://www.mvps.org/winhelp2002/hosts.txt # Be paranoid and replace every IP address with 0.0.0.0. We also get # only want the actual blacklist, 'cause we want to prepend the user's # own hosts. 0.0.0.0 is nicer than constantly knocking on localhosts' door. sed -r -e 's:^([0-9]{1,3}\.){3}[0-9]{1,3}:0.0.0.0:' /tmp/hosts.txt > /tmp/hosts.new.txt tail -n+`grep -nF 'start of lines' /tmp/hosts.new.txt | cut -d':' -f1` /tmp/hosts.new.txt > /tmp/hosts.txt # Write this new list over the system hosts list. MVPS' line feeds # are \n\r; we will be getting rid of those dirty carriage returns. # We'll first write the user's hosts head, then the black list. cat /etc/hosts.local > /etc/hosts cat /tmp/hosts.txt | tr -d "\r" >> /etc/hosts rm /tmp/hosts*.txt # This is the end!
Thanks for the script, I actually wrote one very similar to yours but then thought I'd ask about sourcing it like a bash script does...
Last edited by graysky (2010-10-10 16:04:16)
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
It's better to put these things into the user.action of privoxy! You can do it like this
{ +block }
LIST
Offline
Added to the AUR.
http://aur.archlinux.org/packages.php?ID=44930
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
I modified wintervenom's script to include another blocklist, and delete duplicates:
flack 2.0.6: menu-driven BASH script to easily tag FLAC files (AUR)
knock-once 1.2: BASH script to easily create/send one-time sequences for knockd (forum/AUR)
Offline
Edit: Sorry, I think I shouldn't have posted this here. I already reported this post.
I get the following error messages. I guess, it started after switching to systemd:
# hosts_update
/usr/bin/hosts_update: line 6: /etc/rc.d/functions: No such file or directory
/usr/bin/hosts_update: line 13: stat_busy: command not found
/usr/bin/hosts_update: line 15: stat_done: command not found
/usr/bin/hosts_update: line 17: stat_busy: command not found
/usr/bin/hosts_update: line 28: stat_done: command not found
Any possibility to make this package compatible with pure systemd systems?
Last edited by Markus00000 (2012-10-18 07:25:29)
Offline
Well, let's keep this one read only.
Closing.
To know or not to know ...
... the questions remain forever.
Offline
Pages: 1
Topic closed