Filter Negative Site by Power DNS And Unbound Ubuntu

Powerdns With Mysql
Powerdns With Mysql

Update Repository
apt-get update

Install Mysql
apt-get install mysql-server mysql-client

pastekan baris code dibawah ini :
CREATE DATABASE powerdns;
GRANT ALL ON powerdns.* TO 'power_admin'@'localhost' IDENTIFIED BY '!tuS@ja';
GRANT ALL ON powerdns.* TO 'power_admin'@'localhost.localdomain' IDENTIFIED BY '!tuS@ja';
FLUSH PRIVILEGES;
USE powerdns;
CREATE TABLE domains (
id INT auto_increment,
name VARCHAR(255) NOT NULL,
master VARCHAR(128) DEFAULT NULL,
last_check INT DEFAULT NULL,
type VARCHAR(6) NOT NULL,
notified_serial INT DEFAULT NULL,
account VARCHAR(40) DEFAULT NULL,
primary key (id)
);
CREATE UNIQUE INDEX name_index ON domains(name);
CREATE TABLE records (
id INT auto_increment,
domain_id INT DEFAULT NULL,
name VARCHAR(255) DEFAULT NULL,
type VARCHAR(6) DEFAULT NULL,
content VARCHAR(255) DEFAULT NULL,
ttl INT DEFAULT NULL,
prio INT DEFAULT NULL,
change_date INT DEFAULT NULL,
primary key(id)
);
CREATE INDEX rec_name_index ON records(name);
CREATE INDEX nametype_index ON records(name,type);
CREATE INDEX domain_id ON records(domain_id);
CREATE TABLE supermasters (
ip VARCHAR(25) NOT NULL,
nameserver VARCHAR(255) NOT NULL,
account VARCHAR(40) DEFAULT NULL
);
quit;

Install Unbound sebagai recursornya
apt-get install unbound
cd /etc/unbound/
wget ftp://ftp.internic.net/domain/named.cache
killall unbound
nano /etc/unbound/unbound.conf

edit config unbound dan sesuaikan agar sesuai dengan kebutuhan. jangan lupa portnya selain 53 dan ipnya ke localhost
#### START UNBOUND CONFIG
server:
verbosity: 1
statistics-interval: 120
num-threads: 4
statistics-cumulative: yes
interface: 127.0.0.1@12345
port: 12345

outgoing-range: 512
num-queries-per-thread: 1024

msg-cache-size: 128m
rrset-cache-size: 256m
so-rcvbuf: 8m

msg-cache-slabs: 8
rrset-cache-slabs: 8
infra-cache-slabs: 8
key-cache-slabs: 8

cache-min-ttl: 600
cache-max-ttl: 86400
infra-host-ttl: 60
infra-lame-ttl: 120

infra-cache-numhosts: 10000
infra-cache-lame-size: 10k

do-ip4: yes
do-ip6: no
do-udp: yes
do-tcp: yes
do-daemonize: yes

access-control: 0.0.0.0/0 allow

chroot: "/etc/unbound"
username: "unbound"
directory: "/etc/unbound"
logfile: ""
use-syslog: no
pidfile: "/etc/unbound/unbound.pid"
root-hints: "/etc/unbound/named.cache"

identity: "DNS"
version: "1.4"
hide-identity: yes
hide-version: yes
harden-glue: yes
use-caps-for-id: yes
harden-dnssec-stripped: yes
do-not-query-address: 127.0.0.1/8
do-not-query-localhost: yes
module-config: "iterator"

#zone localhost
local-zone: "localhost." static
local-data: "localhost. 10800 IN NS localhost."
local-data: "localhost. 10800 IN SOA localhost. nobody.invalid. 1 3600 1200 604800 10800"
local-data: "localhost. 10800 IN A 127.0.0.1"

local-zone: "127.in-addr.arpa." static
local-data: "127.in-addr.arpa. 10800 IN NS localhost."
local-data: "127.in-addr.arpa. 10800 IN SOA localhost. nobody.invalid. 2 3600 1200 604800 10800"
local-data: "1.0.0.127.in-addr.arpa. 10800 IN PTR localhost."

forward-zone:
name: "."
forward-addr: 8.8.8.8
forward-addr: 8.8.4.4

remote-control:
control-enable: yes
control-interface: 127.0.0.1
control-port: 953
server-key-file: "/etc/unbound/unbound_server.key"
server-cert-file: "/etc/unbound/unbound_server.pem"
control-key-file: "/etc/unbound/unbound_control.key"
control-cert-file: "/etc/unbound/unbound_control.pem"
##### END CONFIG

restart powerdns
/etc/init.d/pdns restart

check service powerdns apakah sudah berjalan
ps ax | grep pdns

Test apakah resolve
dig @192.168.0.10 detik.com

Install apache dan php module
apt-get install apache2 libapache2-mod-php5 php5 php5-common php5-curl php5-dev php5-gd php-pear php5-imap php5-mcrypt php5-ming php5-mysql php5-xmlrpc gettext php-db php-mdb2 php-mdb2-driver-mysql
a2enmod rewrite
service apache2 restart

Install phpmyadmin
apt-get install phpmyadmin

download poweradmin untuk menambah atau membuang record dns yang akan di block
wget https://github.com/downloads/poweradmin/poweradmin/poweradmin-2.1.6.tgz
tar xzvf poweradmin-2.1.6.tgz
mv poweradmin-2.1.6 /var/www/poweradmin
touch /var/www/poweradmin/inc/config.inc.php
chown -R www-data:www-data /var/www

Lanjutkan setting poweradmin dengan merujuk ke http://192.168.0.10/poweradmin/install/index.php

isi databasenya dengan merujuk file dari https://docs.google.com/file/d/0BxUNcvINx070eHNMUkROQUFEX1U/edit?pli=1 download lalu masukkan ke mesin linux selanjutnya jalankan perintah dibawah ini
awk '{print "NULL" "\t" $1 "\t" NULL "\t" "NULL" "\t" "NATIVE" "\t" "NULL" "\t" "NULL" }' domain.txt > domains
mysql -u power_admin -p'!tuS@ja' -Dpowerdns -e "LOAD DATA INFILE 'domains' INTO TABLE domains"
mysql -u power_admin -p'!tuS@ja' -Dpowerdns -e "select id,name from domains" > forrecord
awk '{print "NULL" "\t" $1 "\t" $2 "\t" "A" "\t" "1.1.1.1" "\t" "86400" "\t" "0" "\t" "1392620361" "\n" "NULL" "\t" $1 "\t" "*."$2 "\t" "A" "\t" "1.1.1.1" "\t" "86400" "\t" "0" "\t" "1392620361" }' forrecord > records
awk '{print "NULL" "\t" $1 "\t" "1" "\t" "0" "\t" "2" }' forrecord > zones
cp records /var/lib/mysql/powerdns/
cp zones /var/lib/mysql/powerdns/
chmod 666 /var/lib/mysql/powerdns/records
chmod 666 /var/lib/mysql/powerdns/zones
mysql -upower_admin -p'!tuS@ja' -Dpowerdns -e "LOAD DATA INFILE 'records' INTO TABLE records"
mysql -upower_admin -p'!tuS@ja' -Dpowerdns -e "LOAD DATA INFILE 'zones' INTO TABLE zones"

Selesai sudah, filtering domain untuk porno, malware, spyware dan judi telah selesai, semoga bermanfaat bagi rekan rekan sekalian.

Sumber : http://jaringanku.net/2014/03/16/filter-negative-site-by-dns/

Artikel Terkait


EmoticonEmoticon