Kali ini akan saya share script untuk blokir unbound berdasarkan list porn StevenBlack.
Syarat penggunaan script ini adalah jika unbound telah berhasil diinstall dan berjalan dengan baik tanpa error. Jangan lupa install dahulu dos2unix jika belum terinstall, caranya
apt install dos2unix -yBaiklah, silahkan buat file convert.sh, kemudian chmod 777 convert.sh
# list of ads domain nameskemudian eksekusi ./convert.sh
array=( https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn/hosts )
for i in "${array[@]}"
do
wget $i -O w
grep -v " #\|<td>\|<p>\|<meta>\|<link>\|<title>\|href\|title=\|=\|<" w > adsList.txt
rm w
dos2unix adsList.txt
# remove host syntax and clean file
sed -i 's/0.0.0.0//g' adsList.txt
sed -i 's/127.0.0.1//g' adsList.txt
sed -i 's/localhost//g' adsList.txt
sed -i 's/.localdomain//g' adsList.txt
# remove commentary after domain name
sed -i 's/#.*//' adsList.txt
# remove tabulation character and carriage return
sed -i "s/\t//g" adsList.txt
sed -i "s/\r//g" adsList.txt
# remove useless space
sed -i 's/ //g' adsList.txt
# remove empty lines
sed -i '/^\s*$/d' adsList.txt
# add prefix and suffix for unbound
sed -i "s/.*/local-zone: \"&\" static/" adsList.txt
cat adsList.txt >> adsListFinal.txt
done
# order list by name, it didn't cost a lot and could maybe increase unbound performance
sort adsListFinal.txt -o adsListFinal.txt
# remove duplicate ads domain in order to avoid warning with Unbound
uniq adsListFinal.txt > adslist.txt
# remove tempory files
rm adsListFinal.txt adsList.txt
dari hasil script di atas akan muncul file adsList.txt, kemudian pindahkan ke /etc/unbound/unbound.conf.d/
kemudian laukan pengecekan
root@DNS-20-10:/home/rahox # unbound-checkconf
unbound-checkconf: no errors in /etc/unbound/unbound.conf
jika dipastikan tidak error silahkan reload atau restart unbound dengan cara
unbound-control reload
atau
unbound-control restartJika sudah, lakukan pengecekan seperti berikut, pastikan /etc/resolv.conf sudah diarahkan ke 127.0.0.1
root@DNS-20-10:/home/rahox # nslookup xnxx.com
Server: 127.0.0.1
Address: 127.0.0.1#53
** server can't find xnxx.com: NXDOMAIN
0 comments:
Post a Comment