Project Bezpieczne i wolne od reklam przeglądanie stron Web (Internet - Filtrowanie treści) [piszę...]

Silas Mariusz

Silas Mariusz

rm -rf /
Help us, GOD!
Apr 5, 2008
9,803
25
2,194
153
38
www.devspark.pl
QNAP
TS-x77
Ethernet
1 GbE
Bezpieczne i wolne od reklam przeglądanie stron Internetowych - Filtrowanie treści
Autor: Silas Mariusz


Spis treści

1. Filtrowanie internetu

1a. Instalacja maszyny wirtualnej z Pi-Hole - filtrowanie Internetu
... lub ;
1b. Instalacja z repo qnapclub.eu -> AdGuard Home

2. Konfiguracja list.

2a. Konfiguracja list w Pi-Hole

2b. Konfiguracja AdGuard Home

(Dla posiadaczy Mikrotik)
3. Automatyczny skrypt przywracający DNS'y dostawcy internetu w przypadku braku połączenia z serwerem filtrującym internet

BONUS
4. Proxy Server na dysku SSD (rekomendowany min. SSD SATA lub dla lepszej wydajności NVMe)

________________________________________________________________________________________________________

1. Filtrowanie internetu

1a.
  • Utworzyć maszyne wirtualną dla Pi-Hole z ustawieniami:
    • 1 vCPU,
    • 1GB RAM,
    • dysk twardy VirtIO,
    • karta sieciowa VirtIO,
    • włączyć virtio-serial
  • W Ubuntu przełączyć użytkownika na root poleceniem: su

  • Zainstalować qemu-guest-agent i podstawowe narzędzia...
    Bash:
    apt-get update
    apt-get install qemu-guest-agent htop mc iotop iperf aptitude

  • Zmień w ustawieniach interfejsu sieciowego adres IP z przydzielania dynamicznego przez DHCP na adres IP statyczny. Edytuj plik: /etc/network/interfaces
    Bash:
    mcedit /etc/network/interfaces

    Zmień ustawienie:
    Code:
    ....
    auto ens3
    iface ens3 inet dhcp
    ....

    Na:
    Code:
    .....
    auto ens3
    iface ens3 inet static
       address 192.168.1.15
       netmask 255.255.255.0
       gateway 192.168.1.1
       dns-nameservers 8.8.8.8 8.8.4.4
    .....

  • Aby zastosować ustawienia, zrestartuj serwer:
    Bash:
    reboot

  • TIP:

    Upload 2019 3 1 11 37 0


    Dla zwiększenia wydajności zapytań DNS użyj Cloudflare DNS zamiast tych, które dotychczasowo używasz.
    IPv4: 1.1.1.1, 1.0.0.1
    IPv6: 2606:4700:4700::1111, 2606:4700:4700::1001

    Pamiętaj, że jeśli Twój operator oferuje Ci swój własny serwer DNS, to nie musimy on być szybszy niż inne DNS'y. Większość nie pomyśli i porównanie prędkości DNS zrobi w ten sposób:
    PHP:
    ping 1.1.1.1
    ping <isp_dns_ip>
    ... Nie! Błąd! :nonono:

    To, że odpowiedź ping w milisekundach będzie szybsza serwera DNS od Twojego ISP nie oznacza, to, że pozyskuje on już tak szybko adresy IP dla zapytań o domeny internetowe.

    Tu jest poprawny przykład:
    (Przed wykonaniem pomiaru wyłącz DNS cache w routerze.)
    Bash:
    dig domena.pl @8.8.8.8  | grep "Query time"

    Poniżej skrypt automatycznie testujący wiele serwerów DNS:
    File: dns_query_lookup_compare.sh
    Bash:
    #!/bin/sh
    
    # Compare DNS lookup query time (c) QNAP Club, Silas Mariusz 2019
    
    domain_target="forum.qnap.net.pl"
    [ ! -z "$1" ] && domain_target="$1"
    
    # Sample List of DNS providers:
    # - Cloudflare DNS,
    # - TPSA DNS,
    # - OpenDNS,
    # - Norton ConnectSafe,
    # - Zaklad Efektywnych Technik Obliczeniowych - ZETO z Tarnowa
    # - Comodo Secure DNS
    # - Quad9
    # - Level3
    # - Verisign
    # - SafeDNS
    dns_serv="1.1.1.1 1.0.0.1 8.8.8.8 8.8.4.4 194.204.159.1 194.204.152.34 208.67.222.222 208.67.220.220 199.85.126.10 199.85.127.10 80.85.224.2 80.85.224.50 8.26.56.26 8.20.247.20 9.9.9.9 149.112.112.112 209.244.0.3 209.244.0.4 64.6.64.6 64.6.65.6 195.46.39.39 195.46.39.40"
    
    
    # Cache executables before...
    sync
    usleep 100000 2>/dev/null 1>/dev/null || sleep 1
    dig --help 2>/dev/null 1>/dev/null
    grep --help 2>/dev/null 1>/dev/null
    
    
    # Measure query time
    for i in $dns_serv
    do
    	echo "Sending [${domain_target}.] dns lookup query to [$i] dns host. `dig ${domain_target} @$i | grep 'Query time'`"
    done
    Gotowy skrypt można pobrać i uruchomić na QNAP z:
    Bash:
    cd /share/Public
    wget http://pool.qnapclub.pl/projects/tools/dns_query_lookup_compare/dns_query_lookup_compare.sh
    chmod +x dns_query_lookup_compare.sh
    
    # test
    sh dns_query_lookup_compare.sh
    sh dns_query_lookup_compare.sh google.com
    sh dns_query_lookup_compare.sh qnap.com

    Przykładowe wyniki:
    Sending [google.com.] dns lookup query to [1.1.1.1] dns host. ;; Query time: 35 msec
    Sending [google.com.] dns lookup query to [1.0.0.1] dns host. ;; Query time: 34 msec
    Sending [google.com.] dns lookup query to [8.8.8.8] dns host. ;; Query time: 31 msec
    Sending [google.com.] dns lookup query to [8.8.4.4] dns host. ;; Query time: 31 msec
    Sending [google.com.] dns lookup query to [194.204.159.1] dns host. ;; Query time: 14 msec
    Sending [google.com.] dns lookup query to [194.204.152.34] dns host. ;; Query time: 15 msec
    Sending [google.com.] dns lookup query to [208.67.222.222] dns host. ;; Query time: 29 msec
    Sending [google.com.] dns lookup query to [208.67.220.220] dns host. ;; Query time: 29 msec
    Sending [google.com.] dns lookup query to [199.85.126.10] dns host. ;; Query time: 41 msec
    Sending [google.com.] dns lookup query to [199.85.127.10] dns host. ;; Query time: 34 msec
    Sending [google.com.] dns lookup query to [80.85.224.2] dns host. ;; Query time: 16 msec
    Sending [google.com.] dns lookup query to [80.85.224.50] dns host. ;; Query time: 7 msec
    Sending [google.com.] dns lookup query to [8.26.56.26] dns host. ;; Query time: 62 msec
    Sending [google.com.] dns lookup query to [8.20.247.20] dns host. ;; Query time: 62 msec
    Sending [google.com.] dns lookup query to [9.9.9.9] dns host. ;; Query time: 13 msec
    Sending [google.com.] dns lookup query to [149.112.112.112] dns host. ;; Query time: 13 msec
    Sending [google.com.] dns lookup query to [209.244.0.3] dns host. ;; Query time: 27 msec
    Sending [google.com.] dns lookup query to [209.244.0.4] dns host. ;; Query time: 27 msec
    Sending [google.com.] dns lookup query to [64.6.64.6] dns host. ;; Query time: 40 msec
    Sending [google.com.] dns lookup query to [64.6.65.6] dns host. ;; Query time: 37 msec
    Sending [google.com.] dns lookup query to [195.46.39.39] dns host. ;; Query time: 49 msec
    Sending [google.com.] dns lookup query to [195.46.39.40] dns host. ;; Query time: 36 msec
    PS. Ja nie powiedizalem, ze Cloudflare DNS jest najszybszy ;)

  • Po ponownym uruchomieniu zainstaluj Pi-hole z repo git:
    Bash:
    apt install bash git
    cd
    
    git clone --depth 1 https://github.com/pi-hole/pi-hole.git Pi-hole
    
    cd Pi-hole/automated\ install/
    bash basic-install.sh

    NOTE: Podczas instalacji dawałem cały czas dalej, dalej, tylko DNS'y podalem :)
    Upload 2019 3 1 12 24 42


    Awwwubuntubosscom content images 2017 11 step2 Awwwubuntubosscom content images 2017 11 step3 Awwwubuntubosscom content images 2017 11 step4 Awwwubuntubosscom content images 2017 11 step5 Awwwubuntubosscom content images 2017 11 step6 Awwwubuntubosscom content images 2017 11 step7 Awwwubuntubosscom content images 2017 11 step8

    Upload 2019 3 1 12 26 13

  • Dobrym pomysłem będzie zmiana hasła admina :)
    Bash:
    pihole -a -p
  • Wyłącz firewall...
    Bash:
    ufw allow http
    ufw allow 53
  • Zacznij używać Pi-Hole do filtrowania internetu i w ustawieniach routera w DHCP (lub DNS serwerze jeśli dostępny) usuń poprzednie ustawienia i DNS i zastąp je jednym serwerem, Pi-Hole, którego adres to adres IP maszyny wirtualnej z Pi-Hole (ustalony podczas zmiany VM z DHCP na statyczny).
  • Zaloguj się do panelu zarządzania Pi-Hole na adres:
    Bash:
    http://pi-hole/admin
    http://srv.pihole.ip.addr/admin
1b. Instalacja z repo qnapclub.eu -> AdGuard Home
  • Zainstaluj AdGaurd Home

  • Edytuj plik: /opt/AdGuard/AdGuardHome.yaml

  • Zmień domyślny login i hasło:
    Code:
    auth_name: qnap
    auth_pass: qnap

  • Zrestartuj AdGuard Home

  • Zaloguj się do AdGuard: http://IP_Twojego_serwera_NAS:9638

  • Dodaj listę:
    name: pl ad domains dns list
    url: https://raw.githubusercontent.com/xxcriticxx/.pl-host-file/master/hosts.txt

    [TODO] Poszukać więcej list ...
Podpowiedź: Aby zacząć korzystać z filtrowania treści wystarczy w ustawieniach routera w sekcji serwera DHCP (lub DNS jeśli dostępny) wprowadzić zamiast serwerów DNS od ISP adres DNS serwera NAS.


3. Mikrotik - skrypt automatycznie przelaczajacy v2
  • Dodajemy 4 linijki, wymuszające korzystanie z innego serwera DNS niż ten przydzielony przez DHCP dla adresów IP z zakresu 192.168.0.20-192.168.0.249

    NOTKA: Ważne, aby serwer Pi-Hole był z po za zakresu puli tych adresów, w przeciwnym wypadku reguła ta zablokuje samego Pi-Hole w odpytywaniu główne serwery DNS.
    A więc dobrze jest skonfigurować adresacje w ten sposób:
    - x.x.x.1 - router
    - x.x.x.5 - VM (Pi-hole)
    - x.x.x.10 - QNAP NAS
    - x.x.x.20-249 - pula adresów DHCP

    Code:
    /ip firewall nat
    add action=dst-nat chain=dstnat comment=pihole-redirect-dns-query dst-port=53 \
        protocol=tcp src-address=192.168.0.20-192.168.0.249 to-addresses=\
        192.168.0.5 to-ports=53
    add action=dst-nat chain=dstnat comment=pihole-redirect-dns-query dst-port=53 \
        protocol=udp src-address=192.168.0.20-192.168.0.249 to-addresses=\
        192.168.0.5 to-ports=53
    add action=dst-nat chain=dstnat comment=pihole-redirect-dns-query \
        dst-address=192.168.0.20-192.168.0.249 dst-port=53 protocol=tcp \
        to-addresses=192.168.0.5 to-ports=53
    add action=dst-nat chain=dstnat comment=pihole-redirect-dns-query \
        dst-address=192.168.0.20-192.168.0.249 dst-port=53 protocol=udp \
        to-addresses=192.168.0.5 to-ports=53
    - Zamienić: 192.168.0.5 na adres IP serwera Pi-Hole
    - a także pule adresową 192.168.0.20-192.168.0.249 na pule adresów przydzielanych przez DHCP

  • Dodać watchdog włączający lub wyłączający tą regułę względem dostępności na ping serwera z pi-hole:
    Code:
    /tool netwatch
    add comment="DNS Failover Script" down-script=\
        "/ip firewall nat disable [find comment=pihole-redirect-dns-query]" host=\
        192.168.0.9 interval=3s up-script=\
        "/ip firewall nat enable [find comment=pihole-redirect-dns-query]"
 
  • Like
Reactions: pigers
pigers

pigers

Maruda
Help us, GOD!
Jul 26, 2013
14,745
50
2,822
230
www.buymeacoffee.com
QNAP
null
Ethernet
100 GbE
  • ·
  • 100 GbE
  • ·
  • Ten którego QNAP jeszcze nie ma ! Najnowszy na Debianie !
You must log in or register to view this reply.
 
LEVY

LEVY

Entry Technician
Q Associate
Oct 19, 2014
98
15
8
Wroclaw
QNAP
TVS-871
Ethernet
1 GbE
You must log in or register to view this reply.
 
pigers

pigers

Maruda
Help us, GOD!
Jul 26, 2013
14,745
50
2,822
230
www.buymeacoffee.com
QNAP
null
Ethernet
100 GbE
  • ·
  • 100 GbE
  • ·
  • Ten którego QNAP jeszcze nie ma ! Najnowszy na Debianie !
You must log in or register to view this reply.
 
LEVY

LEVY

Entry Technician
Q Associate
Oct 19, 2014
98
15
8
Wroclaw
QNAP
TVS-871
Ethernet
1 GbE
You must log in or register to view this reply.
 
LEVY

LEVY

Entry Technician
Q Associate
Oct 19, 2014
98
15
8
Wroclaw
QNAP
TVS-871
Ethernet
1 GbE
You must log in or register to view this reply.
 
Spooky

Spooky

Network Architect
Q's Professional
Jul 11, 2018
526
219
43
40
QNAP
TS-x53A
Ethernet
1 GbE
You must log in or register to view this reply.
 
pigers

pigers

Maruda
Help us, GOD!
Jul 26, 2013
14,745
50
2,822
230
www.buymeacoffee.com
QNAP
null
Ethernet
100 GbE
  • ·
  • 100 GbE
  • ·
  • Ten którego QNAP jeszcze nie ma ! Najnowszy na Debianie !
You must log in or register to view this reply.
 
Spooky

Spooky

Network Architect
Q's Professional
Jul 11, 2018
526
219
43
40
QNAP
TS-x53A
Ethernet
1 GbE
You must log in or register to view this reply.
 
pigers

pigers

Maruda
Help us, GOD!
Jul 26, 2013
14,745
50
2,822
230
www.buymeacoffee.com
QNAP
null
Ethernet
100 GbE
  • ·
  • 100 GbE
  • ·
  • Ten którego QNAP jeszcze nie ma ! Najnowszy na Debianie !
You must log in or register to view this reply.
 
Penerros

Penerros

Enterprise Admin...
Q's Architect
Oct 28, 2016
628
77
28
36
Zielęcin
QNAP
TS-x53D
Ethernet
1 GbE
You must log in or register to view this reply.
 
Penerros

Penerros

Enterprise Admin...
Q's Architect
Oct 28, 2016
628
77
28
36
Zielęcin
QNAP
TS-x53D
Ethernet
1 GbE
You must log in or register to view this reply.
 
LEVY

LEVY

Entry Technician
Q Associate
Oct 19, 2014
98
15
8
Wroclaw
QNAP
TVS-871
Ethernet
1 GbE
You must log in or register to view this reply.
 
pigers

pigers

Maruda
Help us, GOD!
Jul 26, 2013
14,745
50
2,822
230
www.buymeacoffee.com
QNAP
null
Ethernet
100 GbE
  • ·
  • 100 GbE
  • ·
  • Ten którego QNAP jeszcze nie ma ! Najnowszy na Debianie !
You must log in or register to view this reply.
 
LEVY

LEVY

Entry Technician
Q Associate
Oct 19, 2014
98
15
8
Wroclaw
QNAP
TVS-871
Ethernet
1 GbE
You must log in or register to view this reply.
 

Users search this thread by keywords

  1. htop instalacja
  2. pihole statyczny adres
  3. adguardhome