Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
17ab25b998 | ||
|
|
17ae656734 | ||
|
|
b28bb464c1 | ||
|
|
0fd5dc83f2 | ||
|
|
ee64d1e961 | ||
|
|
636bbfb62b | ||
|
|
bb19e4f7dd | ||
|
|
b8a0db90a3 | ||
|
|
ec7034f2f1 | ||
|
|
60f0b0940c | ||
|
|
a8da3fa115 | ||
|
|
37373fbdcd | ||
|
|
e96b379620 | ||
|
|
4795c730c9 | ||
|
|
bf4d22b10b | ||
|
|
22806b5657 | ||
|
|
9f86e73f61 | ||
|
|
fdceec75ba | ||
|
|
182a939f5e | ||
|
|
b71d013431 | ||
|
|
e64d6f9b7f |
@@ -156,7 +156,7 @@ $ apt dist-upgrade
|
|||||||
$ apt update
|
$ apt update
|
||||||
|
|
||||||
## 安装系统软件
|
## 安装系统软件
|
||||||
$ apt install htop lm-sensors unzip vim tmux unattended-upgrades powermgmt-base
|
$ apt install htop lm-sensors unzip neovim tmux unattended-upgrades powermgmt-base
|
||||||
|
|
||||||
## 安装网络工具
|
## 安装网络工具
|
||||||
$ apt install iperf iperf3 iftop
|
$ apt install iperf iperf3 iftop
|
||||||
@@ -248,11 +248,9 @@ $ update-pciids
|
|||||||
|
|
||||||
1. 如非特殊需求,通常情况下 PVE 系统无需使用 IPv6 网络。
|
1. 如非特殊需求,通常情况下 PVE 系统无需使用 IPv6 网络。
|
||||||
|
|
||||||
2. 根据实际测试,仅 PVE 纯内部网桥( `vmbr4` )可通过主路由获取公网 GUA IPv6 地址。
|
2. 主路由未配置 ULA IPv6 网段时,例如本文演示地址 `fdac::/64` ,无需填写 `IPv6/CIDR` 参数。
|
||||||
|
|
||||||
3. 主路由未配置 ULA IPv6 网段时,例如本文演示地址 `fdac::/64` ,无需填写 `IPv6/CIDR` 参数。
|
3. 通常情况下 IPv6 无需填写 `网关` 参数,IPv6 网关将通过 LLA IPv6 地址自动配置。
|
||||||
|
|
||||||
4. 通常情况下 IPv6 无需填写 `网关` 参数,IPv6 网关将通过 LLA IPv6 地址自动配置。
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
$ apt update
|
$ apt update
|
||||||
|
|
||||||
## 安装系统软件
|
## 安装系统软件
|
||||||
$ apt install htop lm-sensors unzip vim tmux unattended-upgrades powermgmt-base
|
$ apt install htop lm-sensors unzip neovim tmux unattended-upgrades powermgmt-base
|
||||||
|
|
||||||
## 安装网络工具
|
## 安装网络工具
|
||||||
$ apt install iperf iperf3 iftop
|
$ apt install iperf iperf3 iftop
|
||||||
@@ -43,9 +43,7 @@ Sun, 25 Jun 2023 12:12:12 +0800
|
|||||||
|
|
||||||
Debian 系统常用 `systemd-timesyncd.service` 来同步时间,而 PVE 系统使用 `chrony.service` 来同步时间。
|
Debian 系统常用 `systemd-timesyncd.service` 来同步时间,而 PVE 系统使用 `chrony.service` 来同步时间。
|
||||||
|
|
||||||
为了使用国内的 NTP 服务器,需要对 `chrony.service` 进行配置。
|
为了使用国内的 NTP 服务器,需要对 `chrony.service` 进行配置,执行以下命令。
|
||||||
|
|
||||||
执行以下命令对 `chrony` 的配置文件进行修改。
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 编辑 chrony 配置文件
|
## 编辑 chrony 配置文件
|
||||||
@@ -66,7 +64,7 @@ pool ntp.aliyun.com iburst
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
保存该配置文件后,需重启 `chrony` 服务,并再次检查系统 NTP 服务器地址。
|
保存该配置文件后,需重启 `chrony.service` ,并再次检查系统 NTP 服务器地址。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 重启 chrony 服务
|
## 重启 chrony 服务
|
||||||
@@ -215,7 +213,7 @@ $ crontab -e
|
|||||||
```bash
|
```bash
|
||||||
## 定时任务配置项
|
## 定时任务配置项
|
||||||
|
|
||||||
0 5 1,16 * * /usr/sbin/reboot
|
30 2 1,16 * * /usr/sbin/reboot
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -225,7 +223,7 @@ $ crontab -e
|
|||||||
|
|
||||||
配置系统自动更新之前,需检查系统当前定时器状态。
|
配置系统自动更新之前,需检查系统当前定时器状态。
|
||||||
|
|
||||||
后续将手动调整该定时器的时间,使其每 `5` 天凌晨 `02:00` 进行触发。
|
后续将手动调整该定时器的时间,使其每 `5` 天凌晨 `01:30` 进行触发。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 检查系统定时器
|
## 检查系统定时器
|
||||||
@@ -258,7 +256,7 @@ $ dpkg-reconfigure -plow unattended-upgrades
|
|||||||
Creating config file /etc/apt/apt.conf.d/20auto-upgrades with new version
|
Creating config file /etc/apt/apt.conf.d/20auto-upgrades with new version
|
||||||
```
|
```
|
||||||
|
|
||||||
进一步调整 apt 的 `20auto-upgrades` 配置文件。
|
进一步调整 `20auto-upgrades` 配置文件。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 进入 apt 的配置目录
|
## 进入 apt 的配置目录
|
||||||
@@ -282,7 +280,7 @@ APT::Periodic::CleanInterval "1";
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
进一步调整 apt 的 `50unattended-upgrades` 配置文件。
|
进一步调整 `50unattended-upgrades` 配置文件。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 编辑 50unattended-upgrades 配置文件
|
## 编辑 50unattended-upgrades 配置文件
|
||||||
@@ -307,7 +305,7 @@ $ nano /etc/apt/apt.conf.d/50unattended-upgrades
|
|||||||
|
|
||||||
- 自动重启:开启。
|
- 自动重启:开启。
|
||||||
|
|
||||||
- 自动重启时间:`05:00` 。
|
- 自动重启时间:`02:30` 。
|
||||||
|
|
||||||
因为该配置文件很长,完整的配置文件可查看 [pve_50unattended_upgrades.conf](./src/pve_50unattended_upgrades.conf) 以便对比。
|
因为该配置文件很长,完整的配置文件可查看 [pve_50unattended_upgrades.conf](./src/pve_50unattended_upgrades.conf) 以便对比。
|
||||||
|
|
||||||
@@ -336,7 +334,7 @@ Unattended-Upgrade::Remove-Unused-Dependencies "true";
|
|||||||
|
|
||||||
Unattended-Upgrade::Automatic-Reboot "true";
|
Unattended-Upgrade::Automatic-Reboot "true";
|
||||||
|
|
||||||
Unattended-Upgrade::Automatic-Reboot-Time "05:00";
|
Unattended-Upgrade::Automatic-Reboot-Time "02:30";
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -358,7 +356,7 @@ $ systemctl edit apt-daily-upgrade.timer
|
|||||||
|
|
||||||
[Timer]
|
[Timer]
|
||||||
OnCalendar=
|
OnCalendar=
|
||||||
OnCalendar=02:00
|
OnCalendar=01:30
|
||||||
RandomizedDelaySec=0
|
RandomizedDelaySec=0
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -377,14 +375,13 @@ $ systemctl status apt-daily-upgrade.timer
|
|||||||
Loaded: loaded (/lib/systemd/system/apt-daily-upgrade.timer; enabled; preset: enabled)
|
Loaded: loaded (/lib/systemd/system/apt-daily-upgrade.timer; enabled; preset: enabled)
|
||||||
Drop-In: /etc/systemd/system/apt-daily-upgrade.timer.d
|
Drop-In: /etc/systemd/system/apt-daily-upgrade.timer.d
|
||||||
└─override.conf
|
└─override.conf
|
||||||
Active: active (waiting) since Sun 2023-06-25 14:35:06 CST; 9s ago
|
Active: active (waiting) since Wed 2023-07-26 14:38:06 CST; 11s ago
|
||||||
Until: Sun 2023-06-25 14:35:06 CST; 9s ago
|
Trigger: Thu 2023-07-27 01:30:00 CST; 10h left
|
||||||
Trigger: Mon 2023-06-26 02:00:00 CST; 11h left
|
|
||||||
Triggers: ● apt-daily-upgrade.service
|
Triggers: ● apt-daily-upgrade.service
|
||||||
|
|
||||||
Jun 25 14:35:06 node01 systemd[1]: Stopped apt-daily-upgrade.timer - Daily apt upgrade and clean activities.
|
Jul 26 14:38:06 node01 systemd[1]: Stopped apt-daily-upgrade.timer - Daily apt upgrade and clean activities.
|
||||||
Jun 25 14:35:06 node01 systemd[1]: Stopping apt-daily-upgrade.timer - Daily apt upgrade and clean activities...
|
Jul 26 14:38:06 node01 systemd[1]: Stopping apt-daily-upgrade.timer - Daily apt upgrade and clean activities...
|
||||||
Jun 25 14:35:06 node01 systemd[1]: Started apt-daily-upgrade.timer - Daily apt upgrade and clean activities.
|
Jul 26 14:38:06 node01 systemd[1]: Started apt-daily-upgrade.timer - Daily apt upgrade and clean activities.
|
||||||
```
|
```
|
||||||
|
|
||||||
## 5.硬件直通
|
## 5.硬件直通
|
||||||
@@ -528,7 +525,7 @@ $ find /sys/kernel/iommu_groups/ -type l
|
|||||||
|
|
||||||
## 6.系统清理
|
## 6.系统清理
|
||||||
|
|
||||||
PVE 系统配置完成后,可逐条执行以下命令,对系统进行清理。
|
PVE 系统配置完成后,可逐行执行以下命令,对系统进行清理。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 清理系统软件包
|
## 清理系统软件包
|
||||||
|
|||||||
@@ -90,17 +90,14 @@ CPU `类别` 选择 `host` ,`插槽` 与 `核心` 数根据物理 CPU 核心
|
|||||||
|
|
||||||
### 2.2.导入镜像文件
|
### 2.2.导入镜像文件
|
||||||
|
|
||||||
使用 SSH 工具登录 PVE 服务器,并进入 `tmp` 目录,逐条执行以下命令创建一个文件夹。
|
使用 SSH 工具登录 PVE 服务器,并进入 `tmp` 目录,逐行执行以下命令创建一个文件夹。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 进入 tmp 目录
|
## 创建存放 Debian 云镜像的临时目录
|
||||||
$ cd /tmp
|
$ mkdir -p /tmp/Debian
|
||||||
|
|
||||||
## 创建文件夹
|
|
||||||
$ mkdir Debian
|
|
||||||
|
|
||||||
## 进入文件夹
|
## 进入文件夹
|
||||||
$ cd Debian
|
$ cd /tmp/Debian
|
||||||
```
|
```
|
||||||
|
|
||||||
将 Debian 云镜像传输到该文件夹,并检查 `hash` 。
|
将 Debian 云镜像传输到该文件夹,并检查 `hash` 。
|
||||||
@@ -216,20 +213,21 @@ Successfully imported disk as 'unused0:local-lvm:vm-1000-disk-0'
|
|||||||
|
|
||||||
|参数|值|说明|
|
|参数|值|说明|
|
||||||
|--|--|--|
|
|--|--|--|
|
||||||
|用户|fox|新系统的管理员账户|
|
|用户|`fox`|新系统的管理员账户|
|
||||||
|密码|********|使用强密码|
|
|密码|`********`|使用强密码|
|
||||||
|DNS域|fox.local|内网域名(可选)|
|
|DNS域|`fox.local`|内网域名(可选)|
|
||||||
|DNS服务器|`172.16.1.1 127.0.0.1`|本机DNS服务器,用空格隔开|
|
|DNS服务器|`172.16.1.1`|本机 DNS 服务器|
|
||||||
|SSH公钥|无|使用秘钥登录服务器,暂不使用|
|
|SSH公钥|`无`|使用秘钥登录服务器,暂不使用|
|
||||||
|
|Upgrade packages|`是`|启动时更新软件包,保持默认即可|
|
||||||
|IP配置(net0)|`ip=172.16.1.250/24,gw=172.16.1.1,ip6=auto`|模板的 IP 设置|
|
|IP配置(net0)|`ip=172.16.1.250/24,gw=172.16.1.1,ip6=auto`|模板的 IP 设置|
|
||||||
|
|
||||||
**额外说明:**
|
**额外说明:**
|
||||||
|
|
||||||
1. 修改 `Cloud-Init` 参数时,需要在虚拟机关机情况下修改才会生效。
|
1. 修改 `Cloud-Init` 参数时,需要在虚拟机关机情况下修改才会生效。
|
||||||
|
|
||||||
2. 在 `DNS服务器` 设置部分,如果先设置了 `127.0.0.1` 作为 DNS 服务器,后续其他 DNS 的 IP 地址将被忽略。
|
2. `DNS服务器` 参数支持输入多个 IPv4 / IPv6 地址,使用空格隔开。
|
||||||
|
|
||||||
此时内网没有其他 DNS 服务器,因此将 `DNS服务器` 设置为 `172.16.1.1 127.0.0.1` ,IP 之间用空格隔开。
|
3. 当前 `DNS服务器` 参数为主路由 LAN 口 IPv4 地址,确保虚拟机能正常联网。
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -245,7 +243,8 @@ Successfully imported disk as 'unused0:local-lvm:vm-1000-disk-0'
|
|||||||
|
|
||||||
|参数|值|说明|
|
|参数|值|说明|
|
||||||
|--|--|--|
|
|--|--|--|
|
||||||
|DNS服务器|`172.16.1.1 fdac::1 127.0.0.1`|本机DNS服务器,用空格隔开|
|
|DNS域|`fox.local`|内网域名(可选)|
|
||||||
|
|DNS服务器|`172.16.1.1 fdac::1`|本机 DNS 服务器|
|
||||||
|IP配置(net0)|`ip=172.16.1.250/24,gw=172.16.1.1,ip6=fdac::fa/64`|模板的 IP 设置|
|
|IP配置(net0)|`ip=172.16.1.250/24,gw=172.16.1.1,ip6=fdac::fa/64`|模板的 IP 设置|
|
||||||
|
|
||||||
`DNS服务器` 参数中需要加入主路由 LAN 口 ULA IPv6 地址。
|
`DNS服务器` 参数中需要加入主路由 LAN 口 ULA IPv6 地址。
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ $ sudo apt dist-upgrade
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 安装系统软件
|
## 安装系统软件
|
||||||
$ sudo apt install qemu-guest-agent zsh git htop tmux cron nftables sshguard
|
$ sudo apt install qemu-guest-agent zsh git htop tmux cron nftables sshguard neovim
|
||||||
|
|
||||||
## 安装系统自动更新工具
|
## 安装系统自动更新工具
|
||||||
$ sudo apt install unattended-upgrades powermgmt-base python3-gi
|
$ sudo apt install unattended-upgrades powermgmt-base python3-gi
|
||||||
@@ -170,11 +170,11 @@ $ sudo sync
|
|||||||
|
|
||||||
由于该 Debian 虚拟机模板将用于克隆内网 DNS 服务器,因此需要调整内核参数来简单优化性能。
|
由于该 Debian 虚拟机模板将用于克隆内网 DNS 服务器,因此需要调整内核参数来简单优化性能。
|
||||||
|
|
||||||
使用 `vim` 编辑器编辑 **内核参数** 配置文件,执行以下命令。
|
使用 `neovim` 编辑器编辑 **内核参数** 配置文件,执行以下命令。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 编辑 内核参数 配置文件
|
## 编辑 内核参数 配置文件
|
||||||
$ sudo vim /etc/sysctl.d/99-sysctl.conf
|
$ sudo nvim /etc/sysctl.d/99-sysctl.conf
|
||||||
```
|
```
|
||||||
|
|
||||||
在配置文件末尾输入以下配置项,注意配置中间的空格。
|
在配置文件末尾输入以下配置项,注意配置中间的空格。
|
||||||
@@ -215,7 +215,7 @@ $ sudo sysctl -f
|
|||||||
|
|
||||||
### 1.5.调整系统时间
|
### 1.5.调整系统时间
|
||||||
|
|
||||||
默认情况下的 Debian 云镜像的系统时间需要调整,执行以下命令将系统时区设置为中国时区。
|
默认情况下 Debian 云镜像的系统时间需要调整,执行以下命令将系统时区设置为中国时区。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 设置系统时区
|
## 设置系统时区
|
||||||
@@ -234,10 +234,10 @@ Debian 云镜像默认使用 `systemd-timesyncd.service` 同步时间,且需
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 创建 NTP 配置文件的文件夹
|
## 创建 NTP 配置文件的文件夹
|
||||||
$ sudo mkdir /etc/systemd/timesyncd.conf.d
|
$ sudo mkdir -p /etc/systemd/timesyncd.conf.d
|
||||||
|
|
||||||
## 创建 NTP 配置文件
|
## 创建 NTP 配置文件
|
||||||
$ sudo vim /etc/systemd/timesyncd.conf.d/server_ntp.conf
|
$ sudo nvim /etc/systemd/timesyncd.conf.d/server_ntp.conf
|
||||||
```
|
```
|
||||||
|
|
||||||
在配置文件中添加以下配置项,并保存。
|
在配置文件中添加以下配置项,并保存。
|
||||||
@@ -305,11 +305,11 @@ $ sudo dpkg-reconfigure -plow unattended-upgrades
|
|||||||
Creating config file /etc/apt/apt.conf.d/20auto-upgrades with new version
|
Creating config file /etc/apt/apt.conf.d/20auto-upgrades with new version
|
||||||
```
|
```
|
||||||
|
|
||||||
接下来调整 apt 的 `20auto-upgrades` 配置文件。
|
进一步调整 `20auto-upgrades` 配置文件。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 编辑 20auto-upgrades 配置文件
|
## 编辑 20auto-upgrades 配置文件
|
||||||
$ sudo vim /etc/apt/apt.conf.d/20auto-upgrades
|
$ sudo nvim /etc/apt/apt.conf.d/20auto-upgrades
|
||||||
```
|
```
|
||||||
|
|
||||||
删除里面全部内容,添加以下配置项,并保存。
|
删除里面全部内容,添加以下配置项,并保存。
|
||||||
@@ -326,11 +326,11 @@ APT::Periodic::CleanInterval "1";
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
进一步调整 apt 的 `50unattended-upgrades` 配置文件。
|
进一步调整 `50unattended-upgrades` 配置文件。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 编辑 50unattended-upgrades 配置文件
|
## 编辑 50unattended-upgrades 配置文件
|
||||||
$ sudo vim /etc/apt/apt.conf.d/50unattended-upgrades
|
$ sudo nvim /etc/apt/apt.conf.d/50unattended-upgrades
|
||||||
```
|
```
|
||||||
|
|
||||||
根据 “注释” 中相关说明,调整配置文件。
|
根据 “注释” 中相关说明,调整配置文件。
|
||||||
@@ -354,7 +354,7 @@ Unattended-Upgrade::Remove-Unused-Dependencies "true";
|
|||||||
|
|
||||||
Unattended-Upgrade::Automatic-Reboot "true";
|
Unattended-Upgrade::Automatic-Reboot "true";
|
||||||
|
|
||||||
Unattended-Upgrade::Automatic-Reboot-Time "04:30";
|
Unattended-Upgrade::Automatic-Reboot-Time "03:00";
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -406,7 +406,7 @@ $ sudo crontab -e
|
|||||||
```bash
|
```bash
|
||||||
## 定时任务配置项
|
## 定时任务配置项
|
||||||
|
|
||||||
0 6 8,24 * * /usr/sbin/reboot
|
30 4 8,24 * * /usr/sbin/reboot
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -435,7 +435,7 @@ Do you want to change your default shell to zsh? [Y/n] y
|
|||||||
|
|
||||||
Debian 模板虚拟机已经配置完成,在将其转换为模板前需要对系统进行清理。
|
Debian 模板虚拟机已经配置完成,在将其转换为模板前需要对系统进行清理。
|
||||||
|
|
||||||
逐条执行以下命令,注意命令中的空格。
|
逐行执行以下命令,注意命令中的空格。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 清理系统软件包
|
## 清理系统软件包
|
||||||
|
|||||||
@@ -63,11 +63,65 @@
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
## 4.安装 Adguard Home
|
## 4.调整系统端口
|
||||||
|
|
||||||
设置完成后,将该虚拟机开机,并使用 SSH 工具登录。
|
设置完成后,将该虚拟机开机,使用 SSH 工具登录,并使用以下命令检查端口占用。
|
||||||
|
|
||||||
Adguard Home 将采用 `snap` 形式安装,逐行执行以下命令。
|
```bash
|
||||||
|
## 检查 53 端口占用
|
||||||
|
$ sudo lsof -i :53
|
||||||
|
|
||||||
|
#### 端口占用示例输出
|
||||||
|
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
|
||||||
|
systemd-r 347 systemd-resolve 17u IPv4 13445 0t0 UDP localhost:domain
|
||||||
|
systemd-r 347 systemd-resolve 18u IPv4 13446 0t0 TCP localhost:domain (LISTEN)
|
||||||
|
systemd-r 347 systemd-resolve 19u IPv4 13447 0t0 UDP localhost:domain
|
||||||
|
systemd-r 347 systemd-resolve 20u IPv4 13448 0t0 TCP localhost:domain (LISTEN)
|
||||||
|
```
|
||||||
|
|
||||||
|
当前系统 `53` 端口被 `systemd-resolved.service` 占用,会导致设置 DNS 服务时监听端口失败。
|
||||||
|
|
||||||
|
为了正常使用 `53` 端口,需要对 `systemd-resolved.service` 进行配置,逐行执行以下命令。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
## 创建 systemd-resolved 配置文件夹
|
||||||
|
$ sudo mkdir -p /etc/systemd/resolved.conf.d
|
||||||
|
|
||||||
|
## 创建 systemd-resolved 配置文件
|
||||||
|
$ sudo nvim /etc/systemd/resolved.conf.d/server_dns.conf
|
||||||
|
```
|
||||||
|
|
||||||
|
在配置文件中添加以下配置项,并保存。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
## systemd-resolved 配置项
|
||||||
|
|
||||||
|
[Resolve]
|
||||||
|
DNS=127.0.0.1
|
||||||
|
DNSStubListener=no
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
保存该配置文件后,还需调整系统 `resolv.conf` 配置文件,逐行执行以下命令。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
## 备份 resolv.conf 配置文件
|
||||||
|
$ sudo mv /etc/resolv.conf /etc/resolv.conf.bak
|
||||||
|
|
||||||
|
## 创建 resolv.conf 软链接
|
||||||
|
$ sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
|
||||||
|
```
|
||||||
|
|
||||||
|
配置完成后,需重启 `systemd-resolved.service` 服务,并再次检查系统 `53` 端口占用。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
## 重启 systemd-resolved 服务
|
||||||
|
$ sudo systemctl restart systemd-resolved.service
|
||||||
|
```
|
||||||
|
|
||||||
|
## 5. Adguard Home
|
||||||
|
|
||||||
|
`Adguard Home` 将采用 `snap` 形式安装,逐行执行以下命令。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 安装 snap
|
## 安装 snap
|
||||||
@@ -77,16 +131,16 @@ $ sudo apt install snapd
|
|||||||
$ sudo snap install adguard-home
|
$ sudo snap install adguard-home
|
||||||
```
|
```
|
||||||
|
|
||||||
### 4.1. Snap 自动更新
|
### 5.1.自动更新
|
||||||
|
|
||||||
查看 Snap 当前的更新策略,执行以下命令。
|
查看 `Snap` 当前的更新策略,执行以下命令。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 显示当前 Snap 自动更新设置
|
## 显示当前 Snap 自动更新设置
|
||||||
$ sudo snap refresh --time
|
$ sudo snap refresh --time
|
||||||
```
|
```
|
||||||
|
|
||||||
将 Snap 自动更新时间设置为每天 `2:30-3:30` 和 `14:30-15:30` 两个时间段。
|
将 `Snap` 自动更新时间设置为每天 `2:30-3:30` 和 `14:30-15:30` 两个时间段。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 修改 Snap 自动更新时间
|
## 修改 Snap 自动更新时间
|
||||||
@@ -96,9 +150,13 @@ $ sudo snap set system refresh.timer=2:30-3:30,14:30-15:30
|
|||||||
$ sudo snap set system refresh.timer=mon,2:30,,fri,2:30
|
$ sudo snap set system refresh.timer=mon,2:30,,fri,2:30
|
||||||
```
|
```
|
||||||
|
|
||||||
### 4.2. Snap 定时任务
|
### 5.2.配置 Adguard Home
|
||||||
|
|
||||||
本步骤为可选操作,主要设置定时重启 Snap 服务。
|
关于 `Adguard Home` 配置相关内容,请参阅 [Adguard Home 折腾手记](https://gitee.com/callmer/agh_toss_notes) 。
|
||||||
|
|
||||||
|
### 5.3.定时任务
|
||||||
|
|
||||||
|
本步骤为可选操作,主要设置定时重启 `Adguard Home` 。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 查看系统定时任务
|
## 查看系统定时任务
|
||||||
@@ -113,13 +171,163 @@ $ sudo crontab -e
|
|||||||
```bash
|
```bash
|
||||||
## 定时任务配置项
|
## 定时任务配置项
|
||||||
|
|
||||||
0 5 * * * /usr/bin/snap restart adguard-home
|
30 4 * * * /usr/bin/snap restart adguard-home
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## 5.配置 Adguard Home
|
## 6. SmartDNS
|
||||||
|
|
||||||
关于 Adguard Home 配置相关内容,请参阅 [Adguard Home 折腾手记](https://gitee.com/callmer/agh_toss_notes) 。
|
若需使用 `SmartDNS` 代替 `Adguard Home` ,可使用 Debian 官方源进行安装,但其版本通常较为 “过时” 。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
## 安装 SmartDNS
|
||||||
|
$ sudo apt install smartdns
|
||||||
|
```
|
||||||
|
|
||||||
|
因此,更推荐使用其 Github 仓库中的最新稳定版进行安装,官方仓库请参阅 [pymumu/smartdns](https://github.com/pymumu/smartdns/releases) 。
|
||||||
|
|
||||||
|
下载 `SmartDNS` 最新版本时,请根据系统架构选择合适的版本,逐行执行以下命令。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
## 创建存放 SmartDNS 安装包的临时目录
|
||||||
|
$ mkdir -p /tmp/SmartDNS
|
||||||
|
|
||||||
|
## 进入文件夹
|
||||||
|
$ cd /tmp/SmartDNS
|
||||||
|
|
||||||
|
## 下载 SmartDNS 安装包
|
||||||
|
$ wget https://github.com/pymumu/smartdns/releases/download/Release42/smartdns.1.2023.05.07-1641.x86_64-linux-all.tar.gz
|
||||||
|
|
||||||
|
## 解压缩 SmartDNS 安装包
|
||||||
|
$ tar zxf smartdns.1.2023.05.07-1641.x86_64-linux-all.tar.gz
|
||||||
|
|
||||||
|
## 进入安装包目录
|
||||||
|
$ cd smartdns
|
||||||
|
|
||||||
|
## 赋予安装脚本执行权限
|
||||||
|
$ chmod +x ./install
|
||||||
|
|
||||||
|
## 安装 SmartDNS
|
||||||
|
$ sudo ./install -i
|
||||||
|
```
|
||||||
|
|
||||||
|
修改 `SmartDNS` 配置之前,需检查 `smartdns.service` 服务状态,确保该服务开机自启动。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
## 检查 smartdns.service
|
||||||
|
$ sudo systemctl status smartdns.service
|
||||||
|
|
||||||
|
## 设置 smartdns.service 开机自启动
|
||||||
|
$ sudo systemctl enable smartdns.service
|
||||||
|
```
|
||||||
|
|
||||||
|
### 6.1.配置 SmartDNS
|
||||||
|
|
||||||
|
`SmartDNS` 配置较为复杂,可按需制定各类 DNS 请求规则,建议先查阅官方提供的 [配置指导](https://pymumu.github.io/smartdns/config/basic-config/) 和 [配置选项](https://pymumu.github.io/smartdns/configuration/) 。
|
||||||
|
|
||||||
|
若需使用 `SmartDNS` 过滤广告,则需下载其广告过滤配置文件,为可选操作。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
## 下载广告过滤配置文件
|
||||||
|
$ sudo wget https://anti-ad.net/anti-ad-for-smartdns.conf -O /etc/smartdns/anti-ad-smartdns.conf
|
||||||
|
```
|
||||||
|
|
||||||
|
`SmartDNS` 的主配置文件一般位于 `/etc/smartdns` 目录下,修改配置文件之前,使用以下命令将其备份。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
## 备份 SmartDNS 主配置文件
|
||||||
|
$ sudo mv /etc/smartdns/smartdns.conf /etc/smartdns/smartdns.conf.bak
|
||||||
|
```
|
||||||
|
|
||||||
|
使用 `neovim` 编辑器创建 `SmartDNS` 主配置文件,执行以下命令。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
## 创建 SmartDNS 主配置文件
|
||||||
|
$ sudo nvim /etc/smartdns/smartdns.conf
|
||||||
|
```
|
||||||
|
|
||||||
|
在编辑器对话框中输入以下内容,并保存。
|
||||||
|
|
||||||
|
**额外说明:**
|
||||||
|
|
||||||
|
- 当不使用 `anti-ad-smartdns.conf` 进行广告过滤时,需移除主配置文件中对应配置项。
|
||||||
|
|
||||||
|
- 检查配置文件中关于本地域名及其上游 DNS 服务器相关配置,请根据实际情况进行调整。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# This configuration file is customized by fox,
|
||||||
|
# Optimize SmartDNS parameters for local DNS server.
|
||||||
|
#
|
||||||
|
# For use common DNS server as upstream DNS server,
|
||||||
|
# please modify 'server' parameter according to
|
||||||
|
# your network environment.
|
||||||
|
#
|
||||||
|
# eg:
|
||||||
|
# server 119.29.29.29
|
||||||
|
# server 223.5.5.5
|
||||||
|
# server 114.114.114.114
|
||||||
|
# server 2402:4e00::
|
||||||
|
# server 2400:3200::1
|
||||||
|
|
||||||
|
conf-file /etc/smartdns/anti-ad-smartdns.conf
|
||||||
|
cache-file /tmp/smartdns.cache
|
||||||
|
|
||||||
|
bind [::]:53
|
||||||
|
bind-tcp [::]:53
|
||||||
|
|
||||||
|
serve-expired yes
|
||||||
|
serve-expired-ttl 86400
|
||||||
|
serve-expired-reply-ttl 3
|
||||||
|
prefetch-domain yes
|
||||||
|
serve-expired-prefetch-time 43200
|
||||||
|
|
||||||
|
speed-check-mode ping,tcp:80,tcp:443
|
||||||
|
|
||||||
|
force-qtype-SOA 65
|
||||||
|
|
||||||
|
log-level notice
|
||||||
|
|
||||||
|
server-tcp 119.29.29.29 -group dnspod -exclude-default-group
|
||||||
|
server-tcp 2402:4e00:: -group dnspod -exclude-default-group
|
||||||
|
nameserver /doh.pub/dnspod
|
||||||
|
nameserver /dot.pub/dnspod
|
||||||
|
|
||||||
|
server-tcp 223.5.5.5 -group alidns -exclude-default-group
|
||||||
|
server-tcp 2400:3200::1 -group alidns -exclude-default-group
|
||||||
|
nameserver /dns.alidns.com/alidns
|
||||||
|
|
||||||
|
server 172.16.1.1 -group intranet -exclude-default-group
|
||||||
|
server fdac::1 -group intranet -exclude-default-group
|
||||||
|
nameserver /fox.local/intranet
|
||||||
|
domain-rules /fox.local/ -speed-check-mode none -no-cache
|
||||||
|
|
||||||
|
server-tls dot.pub
|
||||||
|
server-tls dns.alidns.com
|
||||||
|
|
||||||
|
server-https https://doh.pub/dns-query
|
||||||
|
server-https https://dns.alidns.com/dns-query
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### 6.2.定时任务
|
||||||
|
|
||||||
|
本步骤为可选操作,主要设置 `SmartDNS` 定时更新广告过滤配置文件和定时重启。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
## 编辑系统定时任务,编辑器选择 nano
|
||||||
|
$ sudo crontab -e
|
||||||
|
```
|
||||||
|
|
||||||
|
在配置文件末尾,增加以下配置项。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
## 定时任务配置项
|
||||||
|
|
||||||
|
0 5 * * * /usr/bin/wget -q --tries=10 --retry-connrefused --random-wait https://anti-ad.net/anti-ad-for-smartdns.conf -O /etc/smartdns/anti-ad-smartdns.conf
|
||||||
|
|
||||||
|
30 5 * * * /usr/bin/systemctl restart smartdns.service
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
至此,新虚拟机已配置完成,可作为内网 DNS 服务器使用。
|
至此,新虚拟机已配置完成,可作为内网 DNS 服务器使用。
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 101 KiB |
|
Before Width: | Height: | Size: 107 KiB After Width: | Height: | Size: 108 KiB |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 86 KiB |
|
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 88 KiB |
@@ -173,5 +173,5 @@ Unattended-Upgrade::Remove-Unused-Dependencies "true";
|
|||||||
|
|
||||||
Unattended-Upgrade::Automatic-Reboot "true";
|
Unattended-Upgrade::Automatic-Reboot "true";
|
||||||
|
|
||||||
Unattended-Upgrade::Automatic-Reboot-Time "04:30";
|
Unattended-Upgrade::Automatic-Reboot-Time "03:00";
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
# This configuration file is customized by fox,
|
||||||
|
# Optimize SmartDNS parameters for local DNS server.
|
||||||
|
#
|
||||||
|
# For use common DNS server as upstream DNS server,
|
||||||
|
# please modify 'server' parameter according to
|
||||||
|
# your network environment.
|
||||||
|
#
|
||||||
|
# eg:
|
||||||
|
# server 119.29.29.29
|
||||||
|
# server 223.5.5.5
|
||||||
|
# server 114.114.114.114
|
||||||
|
# server 2402:4e00::
|
||||||
|
# server 2400:3200::1
|
||||||
|
|
||||||
|
conf-file /etc/smartdns/anti-ad-smartdns.conf
|
||||||
|
cache-file /tmp/smartdns.cache
|
||||||
|
|
||||||
|
bind [::]:53
|
||||||
|
bind-tcp [::]:53
|
||||||
|
|
||||||
|
serve-expired yes
|
||||||
|
serve-expired-ttl 86400
|
||||||
|
serve-expired-reply-ttl 3
|
||||||
|
prefetch-domain yes
|
||||||
|
serve-expired-prefetch-time 43200
|
||||||
|
|
||||||
|
speed-check-mode ping,tcp:80,tcp:443
|
||||||
|
|
||||||
|
force-qtype-SOA 65
|
||||||
|
|
||||||
|
log-level notice
|
||||||
|
|
||||||
|
server-tcp 119.29.29.29 -group dnspod -exclude-default-group
|
||||||
|
server-tcp 2402:4e00:: -group dnspod -exclude-default-group
|
||||||
|
nameserver /doh.pub/dnspod
|
||||||
|
nameserver /dot.pub/dnspod
|
||||||
|
|
||||||
|
server-tcp 223.5.5.5 -group alidns -exclude-default-group
|
||||||
|
server-tcp 2400:3200::1 -group alidns -exclude-default-group
|
||||||
|
nameserver /dns.alidns.com/alidns
|
||||||
|
|
||||||
|
server 172.16.1.1 -group intranet -exclude-default-group
|
||||||
|
server fdac::1 -group intranet -exclude-default-group
|
||||||
|
nameserver /fox.local/intranet
|
||||||
|
domain-rules /fox.local/ -speed-check-mode none -no-cache
|
||||||
|
|
||||||
|
server-tls dot.pub
|
||||||
|
server-tls dns.alidns.com
|
||||||
|
|
||||||
|
server-https https://doh.pub/dns-query
|
||||||
|
server-https https://dns.alidns.com/dns-query
|
||||||
|
|
||||||
@@ -175,5 +175,5 @@ Unattended-Upgrade::Remove-Unused-Dependencies "true";
|
|||||||
|
|
||||||
Unattended-Upgrade::Automatic-Reboot "true";
|
Unattended-Upgrade::Automatic-Reboot "true";
|
||||||
|
|
||||||
Unattended-Upgrade::Automatic-Reboot-Time "05:00";
|
Unattended-Upgrade::Automatic-Reboot-Time "02:30";
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
[Timer]
|
[Timer]
|
||||||
OnCalendar=
|
OnCalendar=
|
||||||
OnCalendar=02:00
|
OnCalendar=01:30
|
||||||
RandomizedDelaySec=0
|
RandomizedDelaySec=0
|
||||||
|
|
||||||
### Lines below this comment will be discarded
|
### Lines below this comment will be discarded
|
||||||
|
|||||||