电视盒子(N1)重生记 第三章 安装 AdGuardHome

一、安装 AdGuardHome

1、创建基于 Debian 的 AdGuardHome 容器

1
lxc-create --name AdGuardHome --template download -- --dist debian --release bookworm --arch arm64 --server mirrors.bfsu.edu.cn/lxc-images

2、修改 AdGuardHome 配置

1
nano /var/lib/lxc/AdGuardHome/config

2.1、直接替换原来的配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 设置开机自启
lxc.start.auto = 1

# Distribution configuration
lxc.include = /usr/share/lxc/config/common.conf
lxc.arch = aarch64

# Container specific configuration
lxc.apparmor.profile = generated
lxc.apparmor.allow_nesting = 1
lxc.rootfs.path = dir:/var/lib/lxc/AdGuardHome/rootfs
lxc.uts.name = AdGuardHome

# Network configuration eth0
lxc.net.0.type = veth
lxc.net.0.link = vmbr0
lxc.net.0.flags = up

3、进入、启动容器

1
2
3
4
5
# 启动 mohimo
lxc-start AdGuardHome

# 进入 AdGuardHome
lxc-attach AdGuardHome

4、安装基础环境

1
apt install -y  openssh-server nano curl wget git apt-transport-https ca-certificates

5、配置 AdGuardHome 网络

1
nano /etc/systemd/network/eth0.network

5.1、根据你实际 IP 地址修改

1
2
3
4
5
6
7
8
9
[Match]
Name=eth0
[Network]
Address=192.168.0.4/24
DNS=192.168.0.1
IPForward=yes
IPv6AcceptRA=true
[Route]
Gateway=192.168.0.1

6、官方一键脚本安装

1
wget --no-verbose -O - https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh -s -- -v

如果使用Debian or Ubuntu的rootfs

某些rootfs会内置systemd-resolved的配置会占用53端口,这会影响到adguard的正常运行

1
2
apt install lsof -y
lsof -i :53 ###查看端口占用情况

如果显示如下,需要调整一下这个业务

1
2
3
COMMAND     PID            USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
systemd-r 14542 systemd-resolve 13u IPv4 86178 0t0 UDP 127.0.0.53:domain
systemd-r 14542 systemd-resolve 14u IPv4 86179 0t0 TCP 127.0.0.53:domain

使用下面命令

1
mkdir -p /etc/systemd/resolved.conf.d
1
nano /etc/systemd/resolved.conf.d/adguardhome.conf
1
2
3
[Resolve]
DNS=127.0.0.1
DNSStubListener=no
1
2
mv /etc/resolv.conf /etc/resolv.conf.backup
ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

重启这个服务

1
systemctl reload-or-restart systemd-resolved

特别鸣谢

教程根据 cooip-jm 修改而来