Wireguard, pihole, unbound | предотвращаем утечку dns

Опубликовано 17 12 2022 
3 min на чтение

Смотри видео с детальной настройкой youtube.com.
  • unbound
  • wireguard
  • pihole
apt install wg...

wget https://raw.githubusercontent.com/burghardt/easy-wg-quick/master/easy-wg-quick
chmod +x easy-wg-quick

sudo cp wghub.conf /etc/wireguard/wghub.conf
sudo systemctl enable --now wg-quick@wghub

# new client
./easy-wg-quick bla
sudo cp -r wghub.conf /etc/wireguard/wghub.conf
sudo systemctl restart wg-quick@wghub
sudo wg-quick down ./wghub.conf # if already configured
sudo wg-quick up ./wghub.conf
sudo wg show
# sudo nano /etc/sysctl.conf

net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
net.ipv4.ip_forward = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.rp_filter = 1
net.ipv4.tcp_syncookies = 1

# sudo sysctl -p
sudo cat /etc/wireguard/wghub.conf
# open port
curl -o /var/lib/unbound/root.hints https://www.internic.net/domain/named.cache
# mv access-control: > wg network | ip a
# sudo nano /etc/unbound/unbound.conf.d/pi-hole.conf

    # if no logfile is specified, syslog is used
    # logfile: "/var/log/unbound/unbound.log"
    verbosity: 1
    port: 5353

    do-ip4: yes
    do-udp: yes
    do-tcp: yes

    # may be set to yes if you have IPv6 connectivity
    do-ip6: no

    # use this only when you downloaded the list of primary root servers
    root-hints: "/var/lib/unbound/root.hints"

    # respond to DNS requests on all interfaces
    max-udp-size: 3072

    # IPs authorised to access the DNS Server
    access-control:                 refuse
    access-control:                 allow
    access-control:            allow

    # hide DNS Server info
    hide-identity: yes
    hide-version: yes

    # limit DNS fraud and use DNSSEC
    harden-glue: yes
    harden-dnssec-stripped: yes
    harden-referral-path: yes

    # add an unwanted reply threshold to clean the cache and avoid, when possible, DNS poisoning
    unwanted-reply-threshold: 10000000

    # have the validator print validation failures to the log val-log-level: 1
    # don't use Capitalisation randomisation as it known to cause DNSSEC issues sometimes
    # see https://discourse.pi-hole.net/t/unbound-stubby-or-dnscrypt-proxy/9378 for further details
    use-caps-for-id: no

    # reduce EDNS reassembly buffer size
    # suggested by the unbound man page to reduce fragmentation reassembly problems
    edns-buffer-size: 1472

    # TTL bounds for cache
    cache-min-ttl: 3600
    cache-max-ttl: 86400

    # perform prefetching of close to expired message cache entries
    # this only applies to domains that have been frequently queried
    prefetch: yes
    prefetch-key: yes
    # one thread should be sufficient, can be increased on beefy machines
    num-threads: 1
    # ensure kernel buffer is large enough to not lose messages in traffic spikes
    so-rcvbuf: 1m

    # ensure privacy of local IP ranges
    private-address: fd00::/8
    private-address: fe80::/10
sudo systemctl enable --now unbound
# intfs  wghub
curl -sSL https://install.pi-hole.net | bash


# Settings - DNS наш Unbound

# open port 5353
dig pi-hole.net @ -p 5353  # NOERROR
dig sigok.verteiltesysteme.net @ -p 5353
dig sigfail.verteiltesysteme.net @ -p 5353  # SERFAIL
# wg client conf dns > wghub | ip a
# wg
nano intnetdns.txt

# replace ip default > wghub ip :
# dns wghub ip :

# 10: 10 > wgclient_10.conf
Address =
PrivateKey = oBj9b47cvZaGaCdHQUl1tu6in6L4yoL8hXxUd1EpU1c=
MTU = 1280

PublicKey = G7VcOHBqXYFPppKNUZ25RJLjEXEDq+Gsn/jmczX5HB0=
PresharedKey = LDgByqF8J/TgBI9vE+17aRNWnlJwQoD6i6xZCbwbdBk=
AllowedIPs =, ::/0
Endpoint =
PersistentKeepalive = 25

# open ports
ufw allow ssh
ufw allow 44828/udp

# net
ufw allow 80/tcp
ufw allow 53/udp

# wg
sudo ufw allow from to any port 80
sudo ufw allow from to any port 53
sudo ufw reject https

ss -tulpn
  • http://pi.hole/admin
  • https://dnsleak.com