|
#!/bin/bash |
|
seven |
|
|
|
echo "π Installing Docker and Docker Compose Plugin..." |
|
|
|
# Update and install dependencies |
|
sudo apt update |
|
sudo apt install -y ca-certificates curl gnupg lsb-release apt-transport-https |
|
|
|
# Add official Docker key |
|
sudo install -m 0755 -d /etc/apt/keyrings |
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg |
|
sudo chmod a+r /etc/apt/keyrings/docker.gpg |
|
|
|
# Add official Docker repository |
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null |
|
|
|
# Install Docker and Compose plugin |
|
sudo apt update |
|
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin |
|
|
|
echo "β
Docker installed successfully." |
|
|
|
# Add current user to docker group |
|
echo "π§ Adding user to docker group to avoid using sudo..." |
|
sudo usermod -aG docker $USER |
|
echo "β οΈ You must log out and re-enter the session (logout/login) for this change to take effect." |
|
|
|
# Disable systemd-resolved if enabled |
|
if systemctl is-active --quiet systemd-resolved; then |
|
echo "π§ Disabling systemd-resolved..." |
|
sudo systemctl disable systemd-resolved.service |
|
sudo systemctl stop systemd-resolved.service |
|
sudo rm -f /etc/resolv.conf |
|
echo "nameserver 1.1.1.1" | sudo tee /etc/resolv.conf |
|
fi |
|
|
|
echo "π Creating directory structure..." |
|
mkdir -p dns-stack/adguard/{conf,work} |
|
mkdir -p dns-stack/unbound |
|
|
|
echo "π¦ Downloading root.hints..." |
|
curl -o dns-stack/unbound/root.hints https://www.internic.net/domain/named.root |
|
|
|
echo "π Creating unbound.conf configuration file..." |
|
cat <<EOF > dns-stack/unbound/unbound.conf |
|
server: |
|
verbosity: 1 |
|
interface: 0.0.0.0 |
|
port: 53 |
|
do-ip4: yes |
|
do-udp: yes |
|
do-tcp: yes |
|
root-hints: "/opt/unbound/etc/unbound/root.hints" |
|
hide-identity: yes |
|
hide-version: yes |
|
harden-glue: yes |
|
harden-dnssec-stripped: yes |
|
use-caps-for-id: yes |
|
edns-buffer-size: 1232 |
|
prefetch: yes |
|
cache-min-ttl: 3600 |
|
cache-max-ttl: 86400 |
|
num-threads: 2 |
|
so-rcvbuf: 1m |
|
so-sndbuf: 1m |
|
msg-cache-size: 50m |
|
rrset-cache-size: 100m |
|
qname-minimization: yes |
|
rrset-roundrobin: yes |
|
access-control: 0.0.0.0/0 allow |
|
EOF |
|
|
|
echo "π§± Creating docker-compose.yml..." |
|
cat <<EOF > dns-stack/docker-compose.yml |
|
services: |
|
adguardhome: |
|
image: adguard/adguardhome:latest |
|
container_name: adguardhome |
|
volumes: |
|
- ./adguard/work:/opt/adguardhome/work |
|
- ./adguard/conf:/opt/adguardhome/conf |
|
ports: |
|
- "53:53/tcp" |
|
- "53:53/udp" |
|
- "3000:3000/tcp" |
|
- "80:80/tcp" |
|
- "443:443/tcp" |
|
restart: unless-stopped |
|
depends_on: |
|
- unbound |
|
networks: |
|
- dns_net |
|
|
|
unbound: |
|
image: mvance/unbound:latest |
|
container_name: unbound |
|
volumes: |
|
- ./unbound:/opt/unbound/etc/unbound |
|
restart: unless-stopped |
|
networks: |
|
dns_net: |
|
aliases: |
|
- unbound |
|
|
|
networks: |
|
dns_net: |
|
driver: bridge |
|
EOF |
|
|
|
echo "π³ Uploading containers..." |
|
cd dns-stack || exit 1 |
|
docker compose up -d |
|
|
|
echo "π Getting IP from Unbound..." |
|
UNBOUND_IP=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' unbound) |
|
|
|
echo "β
Environment ready!" |
|
echo "π Configure AdGuard with upstream DNS:" |
|
echo "tcp://$UNBOUND_IP:53" |