BSDTR

Unbound DNS kurulumu + Reklam engelleme - FreeBSD


 Unbound DNS, girdiğiniz bir web sitesinin ip adresini bulan ve önbelleğe alan kendi yerel DNS sunucunuzdur. Yani başka bir DNS'ye sormaz, bunu kendisi yapar, bu şekilde daha fazla gizlilik sağlar. 
 FreeBSD de varsayılan olarakta gelir, (paket deposunda unbound diyede paketi var fakat bizim için gerek yok) sadece isteğe bağlı olarak aktif etmek gerekir. Bu rehberde ekstra olarak local_unbound 'da, reklam engelleme de yapacağız. 

REHBER GÜNCELLENDİ: 9-4-2025

Önce unbound'u kontrol edelim, aktif mi?
# service local_unbound status
Aktif değilse devam, /etc/rc.conf 'ta eklemek için.
# service local_unbound enable
local_unbound enabled in /etc/rc.conf

$ grep "local_unbound" /etc/rc.conf
local_unbound_enable="YES"

# service local_unbound start
Starting local_unbound.

# service local_unbound status
local_unbound is running as pid 1275. # unbound çalışıyor..
/etc/resolv.conf böyle görünsün.
nameserver 127.0.0.1
options edns0
/var/unbound/unbound.conf 'ta böyle görünsün.
server:
    username: unbound
    directory: /var/unbound
    chroot: /var/unbound
    pidfile: /var/run/local_unbound.pid
    root-hints: "/var/unbound/root.hints"
    ratelimit: 1000
    val-log-level: 2
    val-permissive-mode: no
    auto-trust-anchor-file: /var/unbound/root.key

include: /var/unbound/forward.conf
include: /var/unbound/lan-zones.conf
include: /var/unbound/control.conf
include: /var/unbound/conf.d/*.conf
/var/unbound/conf.d/10-forward.conf # yoksa dosya oluştur.
# İsterseniz diğerlerinide açabilirsiniz, DNS yi buradan değiştirebilirsiniz...
servisi restart etmeyi unutmayın!
forward-zone:
name: "."
   forward-addr: 94.140.14.14@53#adguard.dns
   forward-addr: 94.140.15.15@53#adguard.dns
#   forward-addr: 1.0.0.1@53#one.one.one.one
#   forward-addr: 1.1.1.1@53#one.one.one.one
#   forward-addr: 8.8.4.4@53#dns.google
#   forward-addr: 8.8.8.8@53#dns.google

Şimdi gerekli olan cache/root.hints dosyasını indirelim.
Dosyanın güncelliğini korumak için bu dosyayı düzenli olarak güncelleyiniz
# fetch -o /var/unbound/root.hints https://www.internic.net/domain/named.cache

Şimdi servisi restart edip, ardından kontrollerimizi yapalım.
# service local_unbound restart
Stopping local_unbound.
Waiting for PIDS: 1275.
Starting local_unbound.
Waiting for nameserver to start... good

# service local_unbound setup
Performing initial setup.
destination: 
Extracting forwarders from /etc/resolv.conf.
No forwarders found in resolv.conf, using existing forward.conf.
/var/unbound/lan-zones.conf not modified
/var/unbound/control.conf not modified
/var/unbound/unbound.conf not modified
/etc/resolvconf.conf not modified
/etc/resolv.conf not modified

$ sockstat -4 | grep unbound
unbound  local-unbo  4668 5   udp4   127.0.0.1:53          *:*
unbound  local-unbo  4668 6   tcp4   127.0.0.1:53          *:*

# local-unbound-control status
version: 1.20.0
verbosity: 1
threads: 1
modules: 2 [ validator iterator ]
uptime: 1586 seconds
options: control(namedpipe)
unbound (pid 4538) is running...
Bazı durumlarda, DNS sunucunuz sorgunuzu yanıtlayamaz. Bu durumda, aşağıdaki komutu kullanarak DNS önbelleğini temizleyebilirsiniz:
# local-unbound-control flush freebsd.com
ok

ÖNBELLEK TESTİ 

Önce dig için bind-tools 'u kurunuz.

# pkg install bind-tools

Alta ki komutlar başarıyla çözülürse Unbound düzgün çalışıyor demektir.

Önbelleği kontrol etmek için aynı komutu iki kez çalıştırın ve ikinci denemede sorgu süresinin azaldığını not edin.
$ drill -D google.com
$ drill -S freebsd.org @127.0.0.1
$ dig @127.0.0.1 freebsd.com
$ dig freebsd.com | grep -e Query -e SERVER
$ delv www.nixcraft.com
DNSSEC Doğrulamasını Etkinleştirme
$ dig +dnssec freebsd.org @127.0.0.1
; <<>> DiG 9.20.7 <<>> +dnssec freebsd.org @127.0.0.1
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21357
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags: do; udp: 1232
;; QUESTION SECTION:
;freebsd.org.                   IN      A

;; ANSWER SECTION:
freebsd.org.            2077    IN      A       96.47.72.84
freebsd.org.            2077    IN      RRSIG   A 8 2 3600 20250422015155
20250407232001 52789 freebsd.org.
sKE7dx475KK/y/tuUbLAGbrHO/lWRWG+TpyPRryXgKjb4yTEhhfb1gnG ... 9HiXnw==

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1) (UDP)
;; WHEN: Tue Apr 08 08:34:00 +03 2025
;; MSG SIZE  rcvd: 355
📌 Bakmanız gereken yerler kırmızı ile işaretli yerlerdir, DNSSEC devrededir

DNS önbelleğini bir metin dosyasına yedeklemek istiyorsanız, aşağıdaki komutu çalıştırın.
# local-unbound-control dump_cache > cache.txt

 REKLAM ENGELLEME - KARA LİSTE 💡
 disk.yandex.com.tr 
Yandex'te ki 4 dosyayı /var/unbound/conf.d/ içine indirin.
      1. dns.log
      2. blacklist.conf
      3. unbound-blacklist.sh
      4. unbound-guncelleme.sh
Komutu döndürün...
# sh /var/unbound/conf.d/unbound-guncelleme.sh
Stopping local_unbound.
Waiting for PIDS: 1169.
Starting local_unbound.
Waiting for nameserver to start... good
Betiği crontab'a ekleyin, her gün otomatik güncellensin.
📌 Komutların tümünü root ile kopyala ve konsola yapıştır ve enter.
cat << BSD >> /var/cron/tabs/root
00 13,23 * * * /var/unbound/conf.d/unbound-guncelleme.sh
00 22 * * * /var/unbound/conf.d/unbound-root-hints.sh
BSD
Kontrol et.
# crontab -l
00 13,23 * * * /var/unbound/conf.d/unbound-guncelleme.sh
00 22 * * * /var/unbound/conf.d/unbound-root-hints.sh

$ wc -l /var/unbound/conf.d/blacklist.conf
  118260 /var/unbound/conf.d/blacklist.conf
118260 blacklist.conf 'ta ki satır sayısıdır, her satırda bir etki alanına denk gelir, bir kaç güncellemede bir bu sayı değişecektir
log.dns dosyasına da zaten kayıt olacaktır. 

 ENGELLENEN ETKİ ALANLARI TESTİ 
🚫
$ ping ad.track.us.org
ping: cannot resolve ad.track.us.org: Name does not resolve

$ host ad.track.us.org
Host ad.track.us.org not found: 3(NXDOMAIN)

CloudFlare Test: https://1.1.1.1/help/
Adguard Test: https://adguard.com/tr/test.html
Quad9 Test: https://on.quad9.net/
DNSSEC Test1: https://wander.science/projects/dns/dnssec-resolver-test/
DNSSEC Test2: http://www.dnssec-or-not.com/
DNS Leak Test: https://browserleaks.com/dns
Bağlantı Test: https://internet.nl/connection/
Yararlanılan
Kaynaklar:
vermaden.wordpress.com
siberoloji.com
cyberciti.biz
Reklam test1: https://canyoublockit.com/
Reklam Test2: https://d3ward.github.io/toolz/adblock

yorum yok:

Yorum Gönder

2010 - 2025 Beastie BSD Türkiye 🇹🇷