Compare commits

..
64 Commits
Author SHA1 Message Date
CallMeR 47ebcd6628 修复 omz 清理命令 2026-07-13 12:38:18 +08:00
CallMeR 190342575e omz 使用官方镜像 2026-07-11 12:29:54 +08:00
CallMeR 68dcf6ab21 简化 TS 安装步骤 2026-07-05 23:07:05 +08:00
CallMeR 0a926f1bae 更新 sysctl 参数 2026-07-05 01:54:21 +08:00
CallMeR 5ce44529bb 更新 SmartDNS 版本 2026-07-02 17:36:21 +08:00
CallMeR 67378607b3 更新 SmartDNS 版本 2026-06-07 14:53:50 +08:00
CallMeR df1b4e8907 更新图片 2026-05-25 23:48:53 +08:00
CallMeR 3989c31582 更新 SmartDNS 版本 2026-05-21 00:25:30 +08:00
CallMeR f5d82f7435 更新 dnsmasq 配置:no-round-robin 2026-02-08 04:26:52 +08:00
CallMeR 1794aa74fa 更新文案描述 2025-12-27 19:08:37 +08:00
CallMeR fce332798e 更新磁盘扩容命令 2025-12-27 19:03:52 +08:00
CallMeR 4a77288f57 更新磁盘扩容命令 2025-12-27 18:55:24 +08:00
CallMeR 4ddcd01688 更新 SmartDNS 配置 2025-12-09 23:38:36 +08:00
CallMeR ea2221c54c 更新 SmartDNS 配置 2025-12-09 17:21:27 +08:00
CallMeR b9473852b9 更新截图 2025-12-08 11:47:23 +08:00
CallMeR 8b8fc3e773 修复格式问题 2025-12-05 14:33:35 +08:00
CallMeR d2203618af 更新文案描述 2025-12-05 12:13:34 +08:00
CallMeR 96a23ad48f 优化文案描述 & 新增 TS UDP 优化 2025-12-04 18:22:56 +08:00
CallMeR 9f6a2fe42d 更新 sysctl 参数 2025-12-01 13:49:52 +08:00
CallMeR 55a391f95d 修正网卡名称 2025-11-29 20:29:26 +08:00
CallMeR 68ae3b55eb 更新截图 2025-11-29 20:25:03 +08:00
CallMeR edcefa98b3 更新截图 2025-11-29 18:41:05 +08:00
CallMeR 96356ac5d1 更新 SmartDNS 配置 2025-11-23 17:42:18 +08:00
CallMeR e0ccdbd5db PVE 9.1 更新 2025-11-20 12:49:49 +08:00
CallMeR 0b4d71977f 更新 SmartDNS 配置 2025-11-19 14:33:40 +08:00
CallMeR 93ffd7b960 新增 SmartDNS 更新命令 2025-11-10 12:25:16 +08:00
CallMeR bf387d1584 更新 SmartDNS 版本 2025-11-09 15:41:56 +08:00
CallMeR ae92d79d83 新增重置 machine-id 命令 2025-11-02 22:38:55 +08:00
CallMeR 44a1ee787c 改进虚拟机使用 EFI 模式引导 2025-10-24 16:24:29 +08:00
CallMeR 578d953950 增加 360 DoH 以提高可用性 2025-10-02 16:50:23 +08:00
CallMeR 792ce9e9e0 PVE 增加 kdig 工具 2025-09-23 11:49:46 +08:00
CallMeR df3cf10287 简化 SmartDNS 配置 2025-09-23 11:12:06 +08:00
CallMeR 63316af2d6 优化配置说明 2025-09-19 12:05:28 +08:00
CallMeR 77a41c719a SmartDNS Release 47 2025-09-19 05:04:38 +08:00
CallMeR 5efe450d78 更新 Dnsmasq 参数注意事项 2025-09-07 11:41:07 +08:00
CallMeR 2131e6ae58 修复参数一致性 2025-09-05 03:53:21 +08:00
CallMeR aefb7ceb00 更新截图 2025-08-29 12:19:33 +08:00
CallMeR c6ebb95ed3 优化 SmartDNS 插件脚本兼容性 2025-08-28 13:18:04 +08:00
CallMeR 4aaa101400 更新 SmartDNS 插件脚本 2025-08-28 12:21:07 +08:00
CallMeR 85c2d70b81 更新脚本存放路径 2025-08-28 09:59:15 +08:00
CallMeR ade7a53cad 优化部分文案 2025-08-27 23:18:26 +08:00
CallMeR c1812b2a45 修复 PVE 手动设置 IPv6 地址 2025-08-27 19:38:12 +08:00
CallMeR c9aa60ecfd 修复安全启动描述 2025-08-27 19:20:03 +08:00
CallMeR d912edeb89 优化部分文案 2025-08-27 19:16:19 +08:00
CallMeR 115cbb68fc 优化部分文案 2025-08-27 19:06:56 +08:00
CallMeR 9082083465 优化部分文案 2025-08-27 18:44:31 +08:00
CallMeR 3921329fe2 更新截图 2025-08-27 18:05:50 +08:00
CallMeR 31be875c67 更新示例输出 2025-08-27 15:38:33 +08:00
CallMeR 626dca3fd9 更新截图 2025-08-27 14:37:33 +08:00
CallMeR 1ad903bf10 更新截图 2025-08-27 13:29:45 +08:00
CallMeR c7c5270356 适配 trixie 版本 2025-08-18 12:33:52 +08:00
CallMeR d4f8fe6b52 适配 trixie 版本 2025-08-17 15:58:39 +08:00
CallMeR 9013217734 更新备注 2025-08-15 18:10:51 +08:00
CallMeR 9995008d1d 修复遗漏的命令提示符标记 2025-08-15 17:28:55 +08:00
CallMeR 63c299f206 更新示例输出 2025-08-12 17:32:17 +08:00
CallMeR 6f19505b83 更新示例输出 2025-08-12 17:29:55 +08:00
CallMeR 53221483fd 更新示例输出 2025-08-12 17:15:54 +08:00
CallMeR b0ede429fc 适配 trixie 版本 2025-08-12 02:40:53 +08:00
CallMeR c1446daf89 适配 trixie 版本 2025-08-11 13:12:21 +08:00
CallMeR 5b80990bd5 更新网络结构图 2025-08-11 12:51:21 +08:00
CallMeR 117020b8b4 适配 trixie 版本 2025-08-11 12:45:21 +08:00
CallMeR d49c98b6df 更新 PVE 软件安装描述 2025-08-11 01:31:32 +08:00
CallMeR 264bb156ff 更新 PVE 软件源配置方法 2025-08-11 01:19:06 +08:00
CallMeR 07efdcb28f 开始 PVE 9.0 系列 2025-08-06 00:41:56 +08:00
86 changed files with 750 additions and 635 deletions
+16 -20
View File
@@ -6,15 +6,11 @@ PVE 系统正式安装之前,需要准备 PVE 的安装镜像和一些必要
PVE 下载地址:[Proxmox Virtual Environment](https://www.proxmox.com/en/downloads/proxmox-virtual-environment/iso)
页面中有多个 PVE 相关文件,本文以目前最新的 `Proxmox VE 8.3-1 ISO Installer` 作为演示。
点击 `Proxmox VE 8.x ISO Installer` 链接,进入 PVE 下载页面。
![PVE下载页面](img/p01/pve_download_iso.jpeg)
页面中有多个 PVE 相关文件,本文以目前最新的 `Proxmox VE 9.x ISO Installer` 作为演示。
下载 ISO 时请注意 `SHA256SUM` ,后续将使用该校验信息对下载下来的 ISO 进行校验,以确保 ISO 文件的完整性。
![下载PVE](img/p01/pve_iso_hash.jpeg)
![PVE下载页面](img/p01/pve_download_iso.jpeg)
### 0.2.启动盘制作工具
@@ -24,11 +20,9 @@ PVE 下载地址:[Proxmox Virtual Environment](https://www.proxmox.com/en/down
官方网站地址:https://www.ventoy.net/cn/index.html
强烈推荐的引导盘制作工具,优点是可以在一个 U 盘中放入复数个可引导 ISO 文件。
其优点在于可在单个 U 盘内存储多个可引导 ISO 文件,省去多次格式化 U 盘并写入 ISO 的操作,使用便捷
免去了多次格式化 U 盘再写入 ISO 文件的操作,非常友好
缺点是只支持 Windows 、Linux 。
缺点是仅支持 Windows 与 Linux 系统,且部分机型可能无法在 UEFI 模式下启用 Secure Boot(安全启动)
![Ventoy写盘工具](img/p01/pve_ventoy.jpeg)
@@ -52,7 +46,7 @@ PVE 下载地址:[Proxmox Virtual Environment](https://www.proxmox.com/en/down
### 0.3.终端工具
考虑到配置 PVE 服务器、路由器DNS 服务器时,需要在 CLI 中输入命令,因此这里推荐几常用终端工具。
考虑到配置 PVE 服务器、路由器DNS 服务器时在 CLI 中执行命令,以下推荐几常用终端工具。
#### Windows Terminal
@@ -84,19 +78,21 @@ Microsoft 官方终端工具,可以在 Github 平台或 Microsoft 应用商店
在设置 BIOS 时需要注意以下几点:
- 建议暂时关闭 **安全启动**
- 确保启用了硬件虚拟化支持
- 确保打开硬件虚拟化支持
- 确保设备来电自动启动
- 对于不支持 `UEFI` 启动的设备,检查 `Legacy` 引导模式
- 确保启用了设备来电自启动
- 检查 CPU 的功耗设置(可选)
- PVE 8.1 及后续版本支持安全启动,详情参考 [PVE - Secure Boot Setup](https://pve.proxmox.com/wiki/Secure_Boot_Setup)
- 若通过 Ventoy 引导安装 PVE 系统,建议参考 [UEFI 模式安全启动操作说明](https://www.ventoy.net/cn/doc_secure.html) 或 **临时关闭** 安全启动
- 对设备安全性有要求时,建议使用 Etcher 工具制作启动 U 盘并直接安装 PVE 系统
### 1.1.设备引导
使用 Ventoy 进行设备引导后出现如下画面,选择 PVE 的安装 ISO 。
使用 Ventoy 进行设备引导后出现如下画面,选择 PVE 的安装 ISO 进行系统引导
![Ventoy引导设备](img/p01/pve_ventoy_boot.jpeg)
@@ -168,7 +164,7 @@ FQDN 为 PVE 的域,PVE 将使用 FQDN 中的二级域名作为其主机名。
未来主路由的 IPv4 地址为 `172.16.1.1` ,因此均使用该地址作为 PVE 的网关地址和 DNS 地址。
PVE 安装完成后, 将使用 PVE 提供的 WEB 管理面,进一步对该管理口的设置进行调整
PVE 安装完成后,可通过其提供的 Web 管理面,进一步调整管理口的相关设置。
|参数|值|说明|
|--|--|--|
@@ -211,7 +207,7 @@ $ cat /etc/fstab
$ cat /etc/os-release
```
此处显示出 PVE 底层使用的是 Debian 的系统,代号为 `bookworm` ,该代号后续会使用到。
此处显示出 PVE 底层使用的是 Debian 的系统,代号为 `trixie` ,该代号后续会使用到。
![PVE系统信息](img/p01/pve_sys_info.jpeg)
+88 -107
View File
@@ -4,88 +4,96 @@
![PVE系统信息](img/p01/pve_sys_info.jpeg)
此处显示出 PVE 底层使用的是 Debian 的系统,代号为 `bookworm`
此处显示出 PVE 底层使用的是 Debian 的系统,代号为 `trixie`
为了后续能对 PVE 系统进行升级,需要更换其镜像仓库,也就是大家熟知的软件源。
由于目前处于 **“离线”** 安装状态,因此更换软件源后,在没有网络的情况下无法对系统更新。
前处于 “离线” 安装状态,更换软件源后,因无网络连接,无法执行系统更新操作
### 1.1.系统软件源
使用终端工具登录到 PVE 服务器,首先对现有软件源配置进行备份
使用终端工具登录到 PVE 服务器,查看现有软件源配置文件
```bash
## 进入系统软件源配置目录
$ cd /etc/apt
## 查看系统默认软件源
$ cat /etc/apt/sources.list.d/debian.sources
## 查看系统默认镜像配置
$ cat sources.list
#### 系统默认软件源示例输出
Types: deb
URIs: http://deb.debian.org/debian/
Suites: trixie trixie-updates
Components: main contrib non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
## 将默认软件源配置文件进行备份
$ cp sources.list sources.list.bak
Types: deb
URIs: http://security.debian.org/debian-security/
Suites: trixie-security
Components: main contrib non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
```
系统默认镜像配置记录如下
这里将使用 [中国科技大(USTC](http://mirrors.ustc.edu.cn/help/proxmox.html) 的镜像仓库进行替换,使用如下命令
```bash
deb http://ftp.debian.org/debian bookworm main contrib
## 配置 PVE 系统默认软件源脚本
deb http://ftp.debian.org/debian bookworm-updates main contrib
$ cat > /etc/apt/sources.list.d/debian.sources <<EOF
Types: deb
URIs: https://mirrors.ustc.edu.cn/debian
Suites: trixie trixie-updates
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
# security updates
deb http://security.debian.org bookworm-security main contrib
```
Types: deb
URIs: https://mirrors.ustc.edu.cn/debian-security
Suites: trixie-security
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
这里我将使用 [中国科技大(USTC](http://mirrors.ustc.edu.cn/help/proxmox.html) 的镜像仓库进行替换,使用如下命令。
EOF
**注意:该命令为两行,在输入时请逐行输入并回车执行。**
```bash
## 替换系统软件仓库
$ sed -i 's|^deb http://ftp.debian.org|deb https://mirrors.ustc.edu.cn|g' /etc/apt/sources.list
$ sed -i 's|^deb http://security.debian.org|deb https://mirrors.ustc.edu.cn/debian-security|g' /etc/apt/sources.list
```
如果希望能更新 CPU 的 `microcode` ,则需要手动添加镜像 `non-free``non-free-firmware` 参数,完整系统源示例如下。
```bash
deb https://mirrors.ustc.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb https://mirrors.ustc.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
# security updates
deb https://mirrors.ustc.edu.cn/debian-security/ bookworm-security main contrib non-free non-free-firmware
```
### 1.2. PVE 软件源
默认情况下,PVE 额外启用了 2 个官方源,且为订阅收费制,因此需要替换为免源。
默认情况下,PVE 额外启用了 2 个官方源,且为订阅收费制,因此需要替换为免订阅源。
首先创建 PVE 免软件源,执行以下命令。
首先创建 PVE 免订阅软件源,执行以下命令。
```bash
## 创建 PVE 免费软件源
## 配置 PVE 系统免订阅软件源脚本
$ source /etc/os-release
$ cat > /etc/apt/sources.list.d/pve-no-subscription.sources <<EOF
Types: deb
URIs: https://mirrors.ustc.edu.cn/proxmox/debian/pve
Suites: trixie
Components: pve-no-subscription
Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg
EOF
$ echo "deb https://mirrors.ustc.edu.cn/proxmox/debian/pve $VERSION_CODENAME pve-no-subscription" > /etc/apt/sources.list.d/pve-no-subscription.list
```
对于 Proxmox Backup Server 和 Proxmox Mail Gateway,请将以上命令中的 `pve` 分别替换为 `pbs``pmg`
对于 Proxmox Backup Server 和 Proxmox Mail Gateway,请将以上命令路径中的 `pve` 分别替换为 `pbs``pmg`
进一步创建 PVE Ceph 免软件源,Ceph 软件源为 PVE 8 之后默认安装,执行以下命令。
进一步创建 PVE Ceph 免订阅软件源,Ceph 软件源为 PVE 8 之后默认安装,执行以下命令。
```bash
## 创建 PVE Ceph 免软件源脚本
## 配置 PVE Ceph 免订阅软件源脚本
if [ -f /etc/apt/sources.list.d/ceph.list ]; then
$ if [ -f /etc/apt/sources.list.d/ceph.sources ]; then
CEPH_CODENAME=`ceph -v | grep ceph | awk '{print $(NF-1)}'`
source /etc/os-release
echo "deb https://mirrors.ustc.edu.cn/proxmox/debian/ceph-$CEPH_CODENAME $VERSION_CODENAME no-subscription" > /etc/apt/sources.list.d/ceph-no-subscription.list
cat > /etc/apt/sources.list.d/pve-ceph-no-subscription.sources <<EOF
Types: deb
URIs: https://mirrors.ustc.edu.cn/proxmox/debian/ceph-$CEPH_CODENAME
Suites: $VERSION_CODENAME
Components: no-subscription
Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg
EOF
fi
```
最后,删除 PVE 官方付费软件源,执行以下命令。
@@ -94,7 +102,7 @@ fi
```bash
## 删除付费软件源
$ rm -rvf /etc/apt/sources.list.d/pve-enterprise.list /etc/apt/sources.list.d/ceph.list
$ rm -rvf /etc/apt/sources.list.d/pve-enterprise.sources /etc/apt/sources.list.d/ceph.sources
```
创建完成后对其进行检查。
@@ -104,13 +112,7 @@ $ rm -rvf /etc/apt/sources.list.d/pve-enterprise.list /etc/apt/sources.list.d/ce
$ cat /etc/apt/sources.list.d/*
```
如果输出结果中 USTC 的镜像地址,则表示命令已经正确执行。
```bash
#### PVE 免费软件源示例输出
deb https://mirrors.ustc.edu.cn/proxmox/debian/ceph-quincy bookworm no-subscription
deb https://mirrors.ustc.edu.cn/proxmox/debian/pve bookworm pve-no-subscription
```
如果输出结果中均为 USTC 的镜像地址,则表示命令已经正确执行。
### 1.3. PVE CT 源
@@ -119,11 +121,8 @@ deb https://mirrors.ustc.edu.cn/proxmox/debian/pve bookworm pve-no-subscription
由于该功能暂时未被使用,因此本文只做记录。
```bash
## 备份 CT Templates 源
$ cp /usr/share/perl5/PVE/APLInfo.pm /usr/share/perl5/PVE/APLInfo.pm.bak
## 替换 CT Templates 链接
$ sed -i 's|http://download.proxmox.com|https://mirrors.ustc.edu.cn/proxmox|g' /usr/share/perl5/PVE/APLInfo.pm
$ sed -i.bak 's|http://download.proxmox.com|https://mirrors.ustc.edu.cn/proxmox|g' /usr/share/perl5/PVE/APLInfo.pm
## 重启 PVE API 守护进程
$ systemctl restart pvedaemon.service
@@ -136,7 +135,7 @@ $ pveam update
更换完成系统源之后,需要同步系统源数据。
考虑到 **“离线”** 安装时无法同步系统源,因此该步骤可以等到 PVE 正确连接 Internet 后再执行。
“离线” 安装时无法同步系统源,此步骤可待 PVE 成功连接 Internet 后再执行。
```bash
## 清理软件包
@@ -151,26 +150,24 @@ $ apt full-upgrade
## 2.安装必要软件
安装软件前,同样需要让 PVE 能够访问外网。
安装 `iperf3` 后,系统将询问是否将其作为系统服务开机自启,选择 `no` 即可。
其中 `unattended-upgrades` 为系统自动更新服务,后续会对其进行配置。
`linux-cpupower` 为 CPU 调度器的配置工具,后续会对 CPU 调度算法进行调整。
`linux-cpupower` 为 CPU 调度器的配置工具,后续会对 CPU 调度进行调整。
```bash
## 同步镜像仓库
$ apt update
## 安装系统软件
$ apt install btop lm-sensors tmux neovim unzip unattended-upgrades powermgmt-base sshguard
$ apt install btop lm-sensors curl tmux neovim unzip unattended-upgrades powermgmt-base sshguard knot-dnsutils
## 安装 CPU 调度调整工具
$ apt install linux-cpupower
## 根据 CPU 厂商安装 CPU 微码工具
$ apt install intel-microcode (amd64-microcode)
## 更新 PCI 数据库
$ update-pciids
## 安装 Open vSwitch(可选)
$ apt install openvswitch-switch
@@ -178,25 +175,27 @@ $ apt install openvswitch-switch
## 安装网络检测工具(可选)
$ apt install iftop iperf3 iperf
## 更新 PCI 数据库
$ update-pciids
## 根据 CPU 厂商安装 CPU 微码工具(可选,现已默认安装)
$ apt install intel-microcode (amd64-microcode)
## 刷新 systemd 日志分类索引
$ journalctl --update-catalog
```
## 3.配置 PVE 网络
设置电脑的 IPv4 地址为静态地址,电脑 IPv4 地址段需要与 PVE 的地址段保持一致。
用网线电脑网口与 PVE 管理网口此时应为编号最小的第一个网口,相连接
用网线连接电脑网口与 PVE 管理网口此时应为编号最小的第一个网口
访问 PVE 的 WEB 管理界面,对 PVE 的网络进行一些调整。
根据 **网络设备** 规划, PVE 中虚拟机规划如下。
访问 PVE 的 Web 管理界面,根据 **网络设备** 规划调整其网络配置。
|系统|作用|说明|
|--|--|--|
|RouterOS|主路由|PPPoE 拨号上网|
|Debian12|Linux 服务器|内网 DNS 服务器|
|OpenWrt|旁路由|内网插件服务|
|Debian|DNS 服务器|内网 DNS 服务器|
|Debian|TS 服务器|内网 TS 组网服务|
|OpenWrt|旁路网关|内网插件服务|
根据 **内部网络地址** 规划,PVE IP 地址规划如下。
@@ -206,22 +205,18 @@ $ update-pciids
||网关地址|`172.16.1.1`|PVE IPv4 网关|
||DNS 地址|`172.16.1.1`|PVE IPv4 DNS 服务器|
|IPv6|管理地址|`fdac::fe`|PVE IPv6 地址(可选)|
||网关地址|`-`|IPv6 网关将使用 `SLAAC` 自动配置|
||网关地址|`-`|PVE IPv6 网关将使用 `SLAAC` 自动配置|
||DNS 地址|`fdac::1`|PVE IPv6 DNS 服务器(可选)|
![PVE网络规划](img/p02/pve_net_schematization.png)
![PVE网络规划](img/p02/pve_net_schematization.jpeg)
初次登录 PVE 的 WEB 管理后台,打开网络管理页面,此时只有一个 `vmbr0`
`vmbr0` 与列表中的第一个物理网口绑定,且在 `CIDR``网关` 处有 IP 地址参数,说明 `vmbr0` 为当前管理网口。
![PVE网桥最终设置显示](img/p02/pve_net_default.jpeg)
接下来将修改 PVE 网络配置,在修改完成前, **请不要点击 “应用配置”** ,否则会导致 PVE 无法访问。
在 PVE 内部网络设置完成后,将如图所示。
![PVE网桥最终设置显示](img/p02/pve_net_preview.jpeg)
![PVE默认网桥](img/p02/pve_net_default.jpeg)
### 3.1.修改 vmbr0
@@ -229,21 +224,17 @@ $ update-pciids
删除 `IPv4/CIDR``网关` 信息,确保 `自动启动` 为勾选状态。
在备注处填写 `wan` ,然后点击 `OK` 按钮
在备注处填写 `wan` ,然后点击 `OK`
![修改vmbr0](img/p02/pve_modify_vmbr0.jpeg)
### 3.2.创建网桥
点击左上角的 `创建` 按钮,选择 `Linux Bridge`
点击左上角的 `创建` 选项,选择 `Linux Bridge`
![创建物理接口网桥](img/p02/pve_br_create.jpeg)
因为 `vmbr0` 名称已被使用,因此名称填写 `vmbr1`
桥接端口填写顺序的第二个网卡名称,演示中为 `enp3s0`
确保 `自动启动` 为勾选状态,在备注处填写 `lan1` ,点击 `创建` 按钮。
桥接端口填写顺序的第二个网卡名称,演示中为 `nic1` ,在备注处填写 `lan1` ,并点击 `创建`
然后,依次创建所有物理接口的内部网桥,直到最后一个网桥,即 PVE 的管理网口。
@@ -251,7 +242,7 @@ $ update-pciids
### 3.3.创建管理网口
在创建最后一个物理网口的网桥时,需要额外配置 `IPv4` 地址和对应的 `网关` 参数。
在创建最后一个物理网口的网桥时,需配置 `IPv4` 地址和对应的 `网关` 参数。
![最后的物理接口网桥](img/p02/pve_br_last_phyport.jpeg)
@@ -259,41 +250,31 @@ $ update-pciids
1. 如非特殊需求,通常情况下 PVE 系统无需使用 IPv6 网络。
2. 主路由未配置 IPv6 ULA 网段时,如本文演示地址 `fdac::/64` ,无需填写 `IPv6/CIDR` 参数
2. 主路由未配置 IPv6 ULA 网段时,无需填写 `IPv6/CIDR` 参数(如本文演示地址 `fdac::fe/64`
3. 通常情况下 IPv6 无需填写 `网关` 参数,IPv6 网关将通过 LLA IPv6 地址自动配置。
3. 多数情况下无需填写 IPv6 `网关` 参数,网关将通过 IPv6 LLA (链路本地地址自动配置。
![最后的物理接口网桥](img/p02/pve_br_last_phyport_ipv6.jpeg)
所有物理网口的 PVE 网桥创建完成后,可以点击 `应用配置` 按钮,此时页面会失去连接。
所有物理网口的 PVE 网桥创建完成后,点击 `应用配置` 页面会断开连接。
无需担心,只需将电脑网线从 PVE 物理机的第一个网口拔出,并插入最后一个网口即可。
此时,只需将电脑网线从 PVE 物理机的第一个网口拔出,并插入最后一个网口即可恢复
如果万一还是无法访问 PVE,可尝试使用网线 “拔插” 方法,挨个测试 PVE 网口的访问情况
若仍无法访问 PVE,可尝试通过网线拔插的方式,逐一测试 PVE 网口的访问连通性
### 3.4.创建内部网桥
纯内部网桥,在没有内部路由系统提供额外桥接的情况下,无法直接通过物理网口进行访问。
纯内部网桥在无其他系统提供额外桥接,无法直接通过物理网口访问。
只有在主路由(例如 RouterOS )安装完成并建立了内部网桥后,才可正常使用
该纯内部网桥,其主要作用是通过 **主路由** 给内部其他虚拟机提供 **统一** 的网络访问接口。
其主要作用是借助其他系统创建的虚拟网桥,为内部虚拟机提供统一的网络访问接口
创建纯内部网桥的方法,与创建物理网口网桥的方法基本一致,唯一区别是 `桥接端口` 参数为 **空** 即可。
![纯内部网桥](img/p02/pve_br_nophyport.jpeg)
当然,内部网桥的作用不仅如此,比如还可以作为内部级联路由的连接器
在 PVE 内部网络设置完成后,将如图所示
例如,安装了 OPNsense 和 RouterOS 两个虚拟机,OPNsense 作为网关防火墙使用。
此时 RouterOS 作为二级路由系统,OPNsense 的 LAN 口需要与 RouterOS 的 WAN 口相连。
如果 OPNsense 和 RouterOS 均使用了绑定物理网口的 PVE 网桥,则需用网线在 PVE 服务器上连接两个物理网口。
浪费了宝贵的网线不说,还占用了网口,得不偿失。
而纯内部网桥则能很好的解决该问题,有了纯内部网桥,不论多少个虚拟机使用该网桥,只要 IP 地址段相同,即可相互访问。
![PVE网桥最终设置显示](img/p02/pve_net_preview.jpeg)
## 4.配置 PVE DNS
+93 -119
View File
@@ -4,36 +4,31 @@
在 PVE 系统调整之前,请确认必要的软件包已经安装完成,本文后续命令均在 SSH 终端下执行。
关于 [Neovim](https://neovim.io/) 的基础使用方法,请参阅:[Neovim 基础教程](https://cn.bing.com/search?q=Neovim+%E5%9F%BA%E7%A1%80%E6%95%99%E7%A8%8B) 。
Debian 系统默认编辑器为 `nano` ,推荐将其更换为 `neovim` 关于 [Neovim](https://neovim.io/) 的基础使用方法,请参阅:[Neovim 基础教程](https://cn.bing.com/search?q=Neovim+%E5%9F%BA%E7%A1%80%E6%95%99%E7%A8%8B) 。
```bash
## 同步镜像仓库
$ apt update
## 修改系统默认编辑器(选择 nvim 所在条目,即可将 neovim 设为默认编辑器)
$ update-alternatives --config editor
## 安装系统软件
$ apt install btop lm-sensors tmux neovim unzip unattended-upgrades powermgmt-base sshguard
#### 系统默认编辑器示例输出
There are 3 choices for the alternative editor (providing /usr/bin/editor).
## 安装 CPU 调度调整工具
$ apt install linux-cpupower
Selection Path Priority Status
------------------------------------------------------------
* 0 /bin/nano 40 auto mode
1 /bin/nano 40 manual mode
2 /usr/bin/nvim 30 manual mode
3 /usr/bin/vim.tiny 15 manual mode
## 根据 CPU 厂商安装 CPU 微码工具
$ apt install intel-microcode (amd64-microcode)
## 安装 Open vSwitch(可选)
$ apt install openvswitch-switch
## 安装网络检测工具(可选)
$ apt install iftop iperf3 iperf
## 更新 PCI 数据库
$ update-pciids
Press <enter> to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/bin/nvim to provide /usr/bin/editor (editor) in manual mode
```
## 1.系统时区
如果在安装 PVE 系统时选错了时区,导致系统时间和北京时间不一致,可以执行以下命令修正。
输出结果如果和北京时间一致,则代表修改正确。
输出结果和北京时间一致,则代表修改正确。
```bash
## 修改系统时区
@@ -43,7 +38,7 @@ $ timedatectl set-timezone Asia/Shanghai
$ date -R
#### 系统时间示例输出
Mon, 20 Jan 2025 18:24:41 +0800
Wed, 27 Aug 2025 15:12:21 +0800
```
Debian 系统常用 `systemd-timesyncd.service` 来同步时间,而 PVE 系统使用 `chrony.service` 来同步时间。
@@ -52,7 +47,7 @@ Debian 系统常用 `systemd-timesyncd.service` 来同步时间,而 PVE 系统
```bash
## 编辑 chrony 配置文件
$ nvim /etc/chrony/chrony.conf
$ editor /etc/chrony/chrony.conf
```
在编辑器对话框中,将 `pool 2.debian.pool.ntp.org iburst` “注释” 掉,并添加国内的 NTP 服务器。
@@ -115,7 +110,7 @@ analyzing CPU 0:
Supported: yes
Active: yes
#### 设备 CPU - N6005 示例输出
#### 设备 CPU - N100 示例输出
analyzing CPU 0:
driver: intel_pstate
CPUs which run at the same hardware frequency: 0
@@ -135,22 +130,9 @@ analyzing CPU 0:
这里面主要关注两个点:
- driver: `intel_cpufreq``intel_pstate`
- `driver` CPU 调频驱动方案,例如 `intel_cpufreq``intel_pstate`
- current policy: `governor "ondemand"``governor "performance"`
还有另外一个命令可用来显示 CPU 当前调度器。
```bash
## 检查 CPU 当前调度器
$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
#### 设备 CPU - J4125 示例输出
performance
#### 设备 CPU - N6005 示例输出
performance
```
- `governor` :调频策略中使用的调度器,例如 `performance`
CPU 驱动一般不建议手动调整,而 `governor` 后面的参数表示 CPU 当前调度器设置。
@@ -163,7 +145,7 @@ $ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
#### 设备 CPU - J4125 示例输出
conservative ondemand userspace powersave performance schedutil
#### 设备 CPU - N6005 示例输出
#### 设备 CPU - N100 示例输出
performance powersave
```
@@ -173,14 +155,14 @@ performance powersave
- CPU 驱动为 `intel_pstate` 时,推荐使用 `powersave` 调度器。
本文使用 `powersave` 调度器为演示,使用 `neovim` 编辑器创建 `cpupower` 的配置文件。
本文使用 `powersave` 调度器创建 `cpupower` 的配置文件。
```bash
## 创建 cpupower 默认配置文件
$ nvim /etc/default/cpupower
$ editor /etc/default/cpupower
```
在配置文件中修改以下配置项,并保存。
在配置文件中输入以下内容,并保存。
```bash
# This configuration file is customized by fox,
@@ -195,10 +177,10 @@ CPUPOWER_STOP_OPTS="frequency-set -g performance"
```bash
## 创建 cpupower.service 配置文件
$ nvim /etc/systemd/system/cpupower.service
$ editor /etc/systemd/system/cpupower.service
```
在服务配置文件中修改以下配置项,并保存。
在服务配置文件中输入以下内容,并保存。
```bash
# This configuration file is customized by fox,
@@ -261,7 +243,7 @@ $ crontab -l
$ crontab -e
```
在配置文件末尾,增加以下配置项
在配置文件末尾,增加以下内容
```bash
## 定时任务配置项
@@ -284,12 +266,13 @@ $ systemctl status apt-daily-upgrade.timer
#### 系统定时器示例输出
● apt-daily-upgrade.timer - Daily apt upgrade and clean activities
Loaded: loaded (/lib/systemd/system/apt-daily-upgrade.timer; enabled; preset: enabled)
Active: active (waiting) since Mon 2025-01-20 18:12:44 CST; 19min ago
Trigger: Tue 2025-01-21 06:52:19 CST; 12h left
Loaded: loaded (/usr/lib/systemd/system/apt-daily-upgrade.timer; enabled; preset: enabled)
Active: active (waiting) since Wed 2025-08-27 13:41:10 CST; 1h 37min ago
Invocation: 26ebb62a4f6545998522fff8c4104b3e
Trigger: Thu 2025-08-28 06:14:37 CST; 14h left
Triggers: ● apt-daily-upgrade.service
Jan 20 18:12:44 node01 systemd[1]: Started apt-daily-upgrade.timer - Daily apt upgrade and clean activities.
Aug 27 13:41:10 node01 systemd[1]: Started apt-daily-upgrade.timer - Daily apt upgrade and clean activities.
```
### 4.2.配置更新策略
@@ -313,10 +296,10 @@ $ dpkg-reconfigure -plow unattended-upgrades
$ cd /etc/apt/apt.conf.d
## 编辑 20auto-upgrades 配置文件
$ nvim /etc/apt/apt.conf.d/20auto-upgrades
$ editor /etc/apt/apt.conf.d/20auto-upgrades
```
删除里面全部内容,添加以下配置项,并保存。
清空当前全部配置项后,输入以下内容,并保存。
配置文件中,用来控制更新周期的参数为 `APT::Periodic::Unattended-Upgrade` `5` 表示更新周期为 `5` 天。
@@ -334,12 +317,12 @@ APT::Periodic::CleanInterval "1";
```bash
## 编辑 50unattended-upgrades 配置文件
$ nvim /etc/apt/apt.conf.d/50unattended-upgrades
$ editor /etc/apt/apt.conf.d/50unattended-upgrades
```
配置文件中,被修改的参数解释如下:
- 启用了 Debian `bookworm-updates` 相关更新。
- 启用了 Debian `trixie-updates` 相关更新。
- 增加并启用 PVE 自有仓库的更新。
@@ -370,9 +353,9 @@ $ nvim /etc/apt/apt.conf.d/50unattended-upgrades
## 按需添加 PVE Ceph 更新项目
"origin=Proxmox,codename=${distro_codename},label=Proxmox Ceph Debian Repository";
"origin=Proxmox,codename=${distro_codename},label=Proxmox Ceph 19 Squid Debian Repository";
## 在配置文件末尾增加以下配置项,代表启用,并调整参数
## 在配置文件末尾增加以下内容,代表启用,并调整参数
Unattended-Upgrade::AutoFixInterruptedDpkg "true";
@@ -399,7 +382,7 @@ Unattended-Upgrade::Automatic-Reboot-Time "02:30";
$ systemctl edit apt-daily-upgrade.timer
```
根据配置文件中的提示,在中间空白处填入以下配置项
根据配置文件中的提示,在中间空白处填入以下内容
```bash
## 定时器配置项
@@ -422,16 +405,16 @@ $ systemctl status apt-daily-upgrade.timer
#### 系统自动更新触发器示例输出
● apt-daily-upgrade.timer - Daily apt upgrade and clean activities
Loaded: loaded (/lib/systemd/system/apt-daily-upgrade.timer; enabled; preset: enabled)
Loaded: loaded (/usr/lib/systemd/system/apt-daily-upgrade.timer; enabled; preset: enabled)
Drop-In: /etc/systemd/system/apt-daily-upgrade.timer.d
└─override.conf
Active: active (waiting) since Mon 2025-01-20 18:43:03 CST; 7s ago
Trigger: Tue 2025-01-21 01:30:00 CST; 6h left
Active: active (waiting) since Wed 2025-08-27 15:23:29 CST; 8s ago
Invocation: e38354f06d284894b084a52e1f19af73
Trigger: Thu 2025-08-28 01:30:00 CST; 10h left
Triggers: ● apt-daily-upgrade.service
Jan 20 18:43:03 node01 systemd[1]: Stopped apt-daily-upgrade.timer - Daily apt upgrade and clean activities.
Jan 20 18:43:03 node01 systemd[1]: Stopping apt-daily-upgrade.timer - Daily apt upgrade and clean activities...
Jan 20 18:43:03 node01 systemd[1]: Started apt-daily-upgrade.timer - Daily apt upgrade and clean activities.
Aug 27 15:23:29 node01 systemd[1]: Stopping apt-daily-upgrade.timer - Daily apt upgrade and clean activities...
Aug 27 15:23:29 node01 systemd[1]: Started apt-daily-upgrade.timer - Daily apt upgrade and clean activities.
```
## 5.硬件直通
@@ -444,7 +427,7 @@ Jan 20 18:43:03 node01 systemd[1]: Started apt-daily-upgrade.timer - Daily apt u
```bash
## 编辑 Grub 配置文件
$ nvim /etc/default/grub
$ editor /etc/default/grub
```
在编辑器对话框中修改 `GRUB_CMDLINE_LINUX_DEFAULT` 参数,注意命令中间的空格。
@@ -474,17 +457,18 @@ $ update-grub
### 5.2.添加内核模块
修改系统 `/etc/modules` 配置文件,增加必要的系统模块。
编辑 **内核模块** 配置文件,增加必要的系统模块,执行以下命令
```bash
## 编辑系统配置文件
$ nvim /etc/modules
$ editor /etc/modules-load.d/10-server-modules.conf
```
在配置文件中添加以下配置项,并保存。
在配置文件中输入以下内容,并保存。
```bash
## 硬件直通配置项
# This configuration file is customized by fox,
# Optimize vfio related modules at system boot.
vfio
vfio_iommu_type1
@@ -509,36 +493,26 @@ PVE 服务器重启完成后,再次使用终端工具登录,并执行以下
## 检查系统硬件直通状态
$ dmesg | grep -e DMAR -e IOMMU -e AMD-Vi
#### 设备 CPU - N6005 示例输出
[ 0.017937] ACPI: DMAR 0x00000000746C2000 000088 (v02 INTEL EDK2 00000002 01000013)
[ 0.017965] ACPI: Reserving DMAR table memory at [mem 0x746c2000-0x746c2087]
[ 0.047812] DMAR: IOMMU enabled
[ 0.116031] DMAR: Host address width 39
[ 0.116032] DMAR: DRHD base: 0x000000fed90000 flags: 0x0
[ 0.116038] DMAR: dmar0: reg_base_addr fed90000 ver 4:0 cap 1c0000c40660462 ecap 49e2ff0505e
[ 0.116041] DMAR: DRHD base: 0x000000fed91000 flags: 0x1
[ 0.116046] DMAR: dmar1: reg_base_addr fed91000 ver 1:0 cap d2008c40660462 ecap f050da
[ 0.116048] DMAR: RMRR base: 0x0000007b800000 end: 0x0000007fbfffff
[ 0.116051] DMAR-IR: IOAPIC id 2 under DRHD base 0xfed91000 IOMMU 1
[ 0.116052] DMAR-IR: HPET id 0 under DRHD base 0xfed91000
[ 0.116053] DMAR-IR: Queued invalidation will be enabled to support x2apic and Intr-remapping.
[ 0.117774] DMAR-IR: Enabled IRQ remapping in x2apic mode
[ 1.746431] pci 0000:00:02.0: DMAR: Skip IOMMU disabling for graphics
[ 2.290116] DMAR: No ATSR found
[ 2.290117] DMAR: No SATC found
[ 2.290118] DMAR: IOMMU feature fl1gp_support inconsistent
[ 2.290119] DMAR: IOMMU feature pgsel_inv inconsistent
[ 2.290120] DMAR: IOMMU feature nwfs inconsistent
[ 2.290121] DMAR: IOMMU feature pds inconsistent
[ 2.290122] DMAR: IOMMU feature eafs inconsistent
[ 2.290123] DMAR: IOMMU feature prs inconsistent
[ 2.290123] DMAR: IOMMU feature nest inconsistent
[ 2.290124] DMAR: IOMMU feature mts inconsistent
[ 2.290124] DMAR: IOMMU feature sc_support inconsistent
[ 2.290125] DMAR: IOMMU feature dev_iotlb_support inconsistent
[ 2.290126] DMAR: dmar0: Using Queued invalidation
[ 2.290129] DMAR: dmar1: Using Queued invalidation
[ 2.290568] DMAR: Intel(R) Virtualization Technology for Directed I/O
#### 设备 CPU - J4125 示例输出
[ 0.008356] ACPI: DMAR 0x000000007953E000 0000A8 (v01 INTEL GLK-SOC 00000003 BRXT 0100000D)
[ 0.008406] ACPI: Reserving DMAR table memory at [mem 0x7953e000-0x7953e0a7]
[ 0.055618] AMD-Vi: Unknown option - 'on'
[ 0.220916] DMAR: Host address width 39
[ 0.220919] DMAR: DRHD base: 0x000000fed64000 flags: 0x0
[ 0.220939] DMAR: dmar0: reg_base_addr fed64000 ver 1:0 cap 1c0000c40660462 ecap 9e2ff0505e
[ 0.220944] DMAR: DRHD base: 0x000000fed65000 flags: 0x1
[ 0.220954] DMAR: dmar1: reg_base_addr fed65000 ver 1:0 cap d2008c40660462 ecap f050da
[ 0.220960] DMAR: RMRR base: 0x000000794a9000 end: 0x000000794c8fff
[ 0.220963] DMAR: RMRR base: 0x0000007b800000 end: 0x0000007fffffff
[ 0.220967] DMAR-IR: IOAPIC id 1 under DRHD base 0xfed65000 IOMMU 1
[ 0.220970] DMAR-IR: HPET id 0 under DRHD base 0xfed65000
[ 0.220973] DMAR-IR: Queued invalidation will be enabled to support x2apic and Intr-remapping.
[ 0.223069] DMAR-IR: Enabled IRQ remapping in x2apic mode
[ 0.493005] DMAR: No ATSR found
[ 0.493008] DMAR: No SATC found
[ 0.493010] DMAR: dmar0: Using Queued invalidation
[ 0.493018] DMAR: dmar1: Using Queued invalidation
[ 0.494092] DMAR: Intel(R) Virtualization Technology for Directed I/O
```
检查系统 `IOMMU` 分组,执行以下命令。
@@ -547,30 +521,30 @@ $ dmesg | grep -e DMAR -e IOMMU -e AMD-Vi
## 检查 IOMMU group
$ find /sys/kernel/iommu_groups/ -type l
#### 设备 CPU - N6005 示例输出
/sys/kernel/iommu_groups/7/devices/0000:00:1c.4
/sys/kernel/iommu_groups/15/devices/0000:04:00.0
/sys/kernel/iommu_groups/5/devices/0000:00:17.0
/sys/kernel/iommu_groups/13/devices/0000:02:00.0
/sys/kernel/iommu_groups/3/devices/0000:00:15.2
/sys/kernel/iommu_groups/3/devices/0000:00:15.0
/sys/kernel/iommu_groups/11/devices/0000:00:1f.0
/sys/kernel/iommu_groups/11/devices/0000:00:1f.5
/sys/kernel/iommu_groups/11/devices/0000:00:1f.3
/sys/kernel/iommu_groups/11/devices/0000:00:1f.4
#### 设备 CPU - J4125 示例输出
/sys/kernel/iommu_groups/17/devices/0000:04:00.0
/sys/kernel/iommu_groups/7/devices/0000:00:13.3
/sys/kernel/iommu_groups/15/devices/0000:02:00.0
/sys/kernel/iommu_groups/5/devices/0000:00:13.0
/sys/kernel/iommu_groups/13/devices/0000:00:1f.0
/sys/kernel/iommu_groups/13/devices/0000:00:1f.1
/sys/kernel/iommu_groups/3/devices/0000:00:0f.0
/sys/kernel/iommu_groups/11/devices/0000:00:17.0
/sys/kernel/iommu_groups/11/devices/0000:00:17.3
/sys/kernel/iommu_groups/11/devices/0000:00:17.1
/sys/kernel/iommu_groups/11/devices/0000:00:17.2
/sys/kernel/iommu_groups/1/devices/0000:00:00.0
/sys/kernel/iommu_groups/8/devices/0000:00:1c.5
/sys/kernel/iommu_groups/16/devices/0000:05:00.0
/sys/kernel/iommu_groups/6/devices/0000:00:1c.0
/sys/kernel/iommu_groups/14/devices/0000:03:00.0
/sys/kernel/iommu_groups/4/devices/0000:00:16.0
/sys/kernel/iommu_groups/12/devices/0000:01:00.0
/sys/kernel/iommu_groups/2/devices/0000:00:14.5
/sys/kernel/iommu_groups/2/devices/0000:00:14.2
/sys/kernel/iommu_groups/2/devices/0000:00:14.0
/sys/kernel/iommu_groups/10/devices/0000:00:1c.7
/sys/kernel/iommu_groups/18/devices/0000:05:00.0
/sys/kernel/iommu_groups/8/devices/0000:00:14.0
/sys/kernel/iommu_groups/16/devices/0000:03:00.0
/sys/kernel/iommu_groups/6/devices/0000:00:13.2
/sys/kernel/iommu_groups/14/devices/0000:01:00.0
/sys/kernel/iommu_groups/4/devices/0000:00:12.0
/sys/kernel/iommu_groups/12/devices/0000:00:1c.0
/sys/kernel/iommu_groups/2/devices/0000:00:0e.0
/sys/kernel/iommu_groups/10/devices/0000:00:15.0
/sys/kernel/iommu_groups/0/devices/0000:00:02.0
/sys/kernel/iommu_groups/9/devices/0000:00:1c.6
/sys/kernel/iommu_groups/9/devices/0000:00:14.1
```
## 6. BTRFS 调整
@@ -604,7 +578,7 @@ $ swapon /swap/swapfile
```bash
## 编辑 fstab 配置文件
$ nvim /etc/fstab
$ editor /etc/fstab
```
`fstab` 为系统关键配置文件,直接影响系统启动,修改此文件时,请注意以下几点:
+58 -39
View File
@@ -4,9 +4,9 @@
该虚拟机模板主要用作内网 DNS 服务器,由 `Adguard Home``SmartDNS` 提供 DNS 解析服务。
本文将使用 Debian 的云镜像 `debian-12-generic-amd64.qcow2` 作为模板虚拟机的镜像。
本文将使用 Debian 的云镜像 `debian-13-generic-amd64.qcow2` 作为模板虚拟机的镜像。
访问 [Debian Official Cloud Images](https://cloud.debian.org/images/cloud/) 官方网站,下载最新版 `Bookworm` 云镜像以及对应的校验文件。
访问 [Debian Official Cloud Images](https://cloud.debian.org/images/cloud/) 官方网站,下载最新版 `Trixie` 云镜像以及对应的校验文件。
![下载镜像](img/p04/download_generic_image_qcow2.jpeg)
@@ -30,13 +30,15 @@
SCSI 控制器保持默认 `VirtIO SCSI single` ,机型可选 `q35` ,并勾选 `Qemu代理` 选项。
固件可选 `OVMF (UEFI)` ,并勾选 `添加 TPM` 选项,存储路径需根据实际情况进行调整,演示为 `local-lvm`
`预注册密钥` 可启用,启用后将预装特定于发行版和 Microsoft 标准的安全启动密钥。
![虚拟机系统](img/p04/vm_system.jpeg)
### 1.4.磁盘
一般情况下,如果该虚拟机仅为 Adguard Home 服务器,`20G` 磁盘空间足够使用
由于使用 Debian 云镜像制作虚拟机模板,此处删除所有 `磁盘`
因使用 Debian 云镜像制作虚拟机模板,此处需删除所有 `磁盘`
![虚拟机磁盘](img/p04/vm_hd.jpeg)
@@ -52,21 +54,19 @@ CPU `类别` 选择 `host` `插槽` 与 `核心` 数根据物理 CPU 核心
内存一般 `2G` 足够使用,取消勾选 `Ballooning设备`
对于 `Kernel Samepage Merging (KSM)` 内核同页合并功能,建议保留勾选状态。
![虚拟机内存](img/p04/vm_mem.jpeg)
### 1.7.网络
在 [02.PVE初始化配置](./02.PVE初始化配置.md) 中,曾创建了一个没有桥接任何物理网口的内部网桥
通常情况下,模板虚拟机的 `桥接` 参数设为 PVE 管理口所在虚拟网桥即可
该内部网桥接口同属于主路由内部网桥成员接口
因此,模板虚拟机的 `桥接` 参数可设置为该纯内部网桥。
因在 [02.PVE初始化配置](./02.PVE初始化配置.md) 中曾创建未桥接物理网口的内部网桥,故可根据实际需求选择是否使用纯内部网桥作为该参数值
![虚拟机网口](img/p04/vm_network_port.jpeg)
由于演示环境中暂未安装主路由系统,因此选择其他网桥接口替代
通常情况下无需使用 PVE 内建防火墙,因此 **取消勾选** 网络设备的 `防火墙` 选项。
多数情况下,无需使用 PVE 内建防火墙,因此 **取消勾选** 网络设备的 `防火墙` 选项
推荐在 `Multiqueue` 处根据前面设置的 CPU 核心数进行网卡多队列设置,设置比例为 1:1 。
@@ -104,10 +104,10 @@ $ cd /tmp/Debian
```bash
## 下载云镜像校验文件
$ wget https://cloud.debian.org/images/cloud/bookworm/latest/SHA512SUMS
$ curl -LR -O https://cloud.debian.org/images/cloud/trixie/latest/SHA512SUMS
## 下载云镜像
$ wget https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2
$ curl -LR -O https://cloud.debian.org/images/cloud/trixie/latest/debian-13-generic-amd64.qcow2
## 检查文件是否存在
$ ls -lah
@@ -116,36 +116,45 @@ $ ls -lah
$ cat SHA512SUMS
## 计算文件 hash
$ sha512sum debian-12-generic-amd64.qcow2
$ sha512sum debian-13-generic-amd64.qcow2
```
确认无误后,将镜像文件导入刚才创建的虚拟机,命令中的 `VM ID` 需要根据实际情况替换,演示为 `1001`
```bash
## 将 qcow2 镜像导入虚拟机中
$ qm importdisk 1001 debian-12-generic-amd64.qcow2 local-lvm
$ qm importdisk 1001 debian-13-generic-amd64.qcow2 local-lvm
#### 镜像导入示例输出
unused0: successfully imported disk 'local-lvm:vm-1001-disk-0'
unused0: successfully imported disk 'local-lvm:vm-1001-disk-2'
```
磁盘导入成功后,虚拟机硬件列表中将显示一块未使用的磁盘设备,可鼠标 **双击** 该设备进行配置调整。
![虚拟机新磁盘](img/p04/vm_unused_hd.jpeg)
当宿主机使用 `SSD` 作为物理存储设备,并且虚拟磁盘采用 `精简置备` Thin Provisioning 模式时,可考虑开启以下选项:
当宿主机使用 SSD 作为物理存储设备,并且虚拟磁盘采用 Thin Provisioning (精简置备)模式时,可考虑开启以下选项:
- `丢弃` Discard) 选项,有助于存储空间回收。
- `Discard` `丢弃` 选项,有助于存储空间回收。
- `SSD仿真` SSD Emulation) 选项,让虚拟机将虚拟磁盘视为 `SSD` 存储设备。
- `SSD Emulation` `SSD 仿真` ) 选项,让虚拟机将虚拟磁盘视为 SSD 存储设备。
在弹出的对话框中,确认 `IO thread` 选项为 **勾选** 状态,并点击 `添加`
![虚拟机使用该磁盘](img/p04/vm_enable_hd.jpeg)
导入的镜像只有 `3G` 磁盘空间,为了后续方便使用,需要对磁盘进行扩容
导入的镜像仅具备 `3G` 磁盘空间,为方便后续使用,可通过 `qm` 命令直接将该磁盘调整至目标容量
鼠标 **单击** 选中该磁盘,选择页面顶部 `磁盘操作` 菜单的子菜单 `调整大小`
```bash
## 将镜像容量设置为 24G
$ qm disk resize 1001 scsi0 24G
#### 镜像扩容示例输出
Size of logical volume pve/vm-1001-disk-2 changed from 3.00 GiB (768 extents) to 24.00 GiB (6144 extents).
Logical volume pve/vm-1001-disk-2 successfully resized.
```
或鼠标 **单击** 选中该磁盘,选择页面顶部 `磁盘操作` 菜单的子菜单 `调整大小`
![虚拟机磁盘扩容](img/p04/vm_hd_resize.jpeg)
@@ -155,16 +164,28 @@ unused0: successfully imported disk 'local-lvm:vm-1001-disk-0'
### 2.3.添加 CloudInit
了能够正常使用 Cloud-Init 初始化系统,需要给模板虚拟机添加 `CloudInit设备`
确保 Cloud-Init 能正常初始化系统,需模板虚拟机添加 `CloudInit 设备`
点击顶部 `添加` 菜单,选择 `CloudInit设备`
点击顶部 `添加` 菜单,选择 `CloudInit 设备`
![虚拟机添加ci](img/p04/vm_cloudinit.jpeg)
`总线/设备` 选择 `SCSI` ,编号为 `1` `存储` 选择 `local-lvm`
`总线/设备` 选择 `SCSI` ,编号为 `1` 存储路径需根据实际情况进行调整,演示为 `local-lvm`
![虚拟机ci参数](img/p04/vm_ci_details.jpeg)
### 2.4.添加 VirtIO RNG
为确保系统拥有充足的可用熵,需为模板虚拟机添加 `VirtIO RNG` 熵源。
点击顶部 `添加` 菜单,选择 `VirtIO RNG`
![虚拟机添加RNG](img/p04/vm_rng.jpeg)
`熵源` 选择 `/dev/urandom` ,其余参数保持默认即可。
![虚拟机RNG参数](img/p04/vm_rng_details.jpeg)
虚拟机硬件设备修改完成后,如下图所示。
![虚拟机全部硬件](img/p04/vm_hardware_all.jpeg)
@@ -187,9 +208,7 @@ unused0: successfully imported disk 'local-lvm:vm-1001-disk-0'
鼠标 **双击** `引导顺序` 选项,进入编辑界面。
`scsi0` 设备处勾选前面的 “已启用” 复选框,并使用行首的排序功能,将该设备拖拽到第一个
然后点击 `OK` 按钮。
`scsi0` 设备处勾选 “已启用” 复选框,并通过排序功能将其拖拽至首位,点击 `OK` 即可
![虚拟机引导顺序](img/p04/vm_boot.jpeg)
@@ -211,11 +230,11 @@ unused0: successfully imported disk 'local-lvm:vm-1001-disk-0'
|--|--|--|
|用户|`fox`|新系统的管理员账户|
|密码|`********`|使用强密码|
|DNS域|`fox.internal`|内网域名(可选)|
|DNS服务器|`172.16.1.1`|本机 DNS 服务器|
|SSH公钥|`无`|使用秘钥登录服务器,暂不使用|
|Upgrade packages|`是`|启动时更新软件包,保持默认即可|
|IP配置(net0)|`ip=172.16.1.250/24,gw=172.16.1.1,ip6=auto`|模板的 IP 设置|
|DNS 域|`fox.internal`|内网域名(可选)|
|DNS 服务器|`172.16.1.1`|本机 DNS 服务器|
|SSH 公钥|`无`|使用秘钥登录服务器,暂不使用|
|升级程序包|`是`|启动时更新软件包,保持默认即可|
|IP 配置 (net0)|`ip=172.16.1.250/24,gw=172.16.1.1,ip6=auto`|模板的 IP 设置|
**额外说明:**
@@ -227,7 +246,7 @@ unused0: successfully imported disk 'local-lvm:vm-1001-disk-0'
![CI网络配置](img/p04/vm_ci_dns.jpeg)
`Cloud-Init``IP配置` IPv4 使用静态地址,IPv6 使用 `SLAAC` 自动配置,如下图所示。
`Cloud-Init``IP 配置` IPv4 使用 `静态` 地址,IPv6 使用 `SLAAC` 自动配置,如下图所示。
![CI网络配置](img/p04/vm_ci_network_slaac.jpeg)
@@ -235,7 +254,7 @@ unused0: successfully imported disk 'local-lvm:vm-1001-disk-0'
当主路由配置了 IPv6 ULA 网段,且希望指定内网 DNS 服务器的 IPv6 ULA 地址时,需要调整 `Cloud-Init` 参数。
本文 IPv6 ULA 演示地址为 `fdac::/64` `DNS服务器``IP配置` 参数调整如下。
本文 IPv6 ULA 演示地址`fdac::/64` `DNS 服务器``IP 配置` 参数调整如下。
|参数|值|说明|
|--|--|--|
@@ -243,13 +262,13 @@ unused0: successfully imported disk 'local-lvm:vm-1001-disk-0'
|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 设置|
`DNS服务器` 参数中需要加入主路由 LAN 口 IPv6 ULA 地址。
`DNS 服务器` 参数中需要加入主路由 LAN 口 IPv6 ULA 地址。
![CI网络配置](img/p04/vm_ci_dns_ula.jpeg)
`IP配置` 参数,IPv4 使用静态地址,IPv6 同样使用静态地址,如下图所示。
`IP 配置` 参数,IPv4 使用 `静态` 地址,IPv6 同样使用 `静态` 地址,如下图所示。
IPv6 使用静态地址后,并不影响虚拟机通过主路由获取公网 GUA IPv6 地址。
IPv6 使用 `静态` 地址后,并不影响虚拟机通过主路由获取 IPv6 GUA 公网地址。
![CI网络配置](img/p04/vm_ci_network_static.jpeg)
@@ -260,7 +279,7 @@ IPv6 使用静态地址后,并不影响虚拟机通过主路由获取公网 GU
```bash
### 服务器信息
- 系统: Debian12
- 系统: Debian 13
- 用途: 内网 DNS 服务器 ( 模板 )
+90 -118
View File
@@ -1,10 +1,8 @@
## 1.配置系统
在上一篇文章 [04.PVE创建模板虚拟机](./04.PVE创建模板虚拟机.md) 中,已经创建好了用于制作虚拟机模板的模板虚拟机。
在上一篇文章 [04.PVE创建模板虚拟机](./04.PVE创建模板虚拟机.md) 中,已经创建好了用于制作 `虚拟机模板` 的虚拟机。
并调整了模板虚拟机的硬件参数、配置参数,但还需对 Debian 系统进行调整
此时将模板虚拟机开机后,使用 `Cloud-Init` 中设置的账号密码进行登录。
此时将该虚拟机开机后,使用 `Cloud-Init` 中设置的账号密码进行登录
### 1.1.配置 SSH
@@ -16,16 +14,16 @@
`vim` 编辑器常用操作如下:
- 编辑文件按下键盘 `i` 键,进入编辑模式。
- 编辑文件按下键盘 `i` 键,进入编辑模式。
- 保存文件按下键盘 `Esc` 键,退出编辑模式,再输入组合键 `:wq` 即可保存。
- 保存文件按下键盘 `Esc` 键,退出编辑模式,再输入组合键 `:wq` 即可保存。
```bash
## 编辑 SSH 配置文件
$ sudo vim /etc/ssh/sshd_config.d/10-server-sshd.conf
```
在配置文件中添加以下配置项,并保存。
在配置文件中输入以下内容,并保存。
```bash
## SSH 配置项
@@ -51,76 +49,26 @@ $ sudo systemctl restart ssh.service
当系统版本发生变化时,请参考 USTC 镜像站的官方说明 [USTC Mirror Help - Debian](https://mirrors.ustc.edu.cn/help/debian.html) 。
Debian12 云镜像的软件源配置采用了 `DEB822` 格式,新版 `sources.list` 配置文件内容如下
使用如下命令对 `debian.sources` 配置文件进行修改
```bash
## 查看镜像配置文件
$ cat /etc/apt/sources.list
#### 配置文件示例输出
# See /etc/apt/sources.list.d/debian.sources
```
进一步查看新配置文件 `debian.sources` 的内容,其配置包含 `3` 个部分。
```bash
## 查看新版镜像配置文件
$ cat /etc/apt/sources.list.d/debian.sources
#### 新版配置文件示例输出 (主体部分)
Types: deb deb-src
URIs: mirror+file:///etc/apt/mirrors/debian.list
Suites: bookworm bookworm-updates bookworm-backports
Components: main
Types: deb deb-src
URIs: mirror+file:///etc/apt/mirrors/debian-security.list
Suites: bookworm-security
Components: main
## 查看关联的配置文件
$ cat /etc/apt/mirrors/debian.list
#### 关联配置文件示例输出 (关联部分 1 )
https://deb.debian.org/debian
## 查看关联的配置文件
$ cat /etc/apt/mirrors/debian-security.list
#### 关联配置文件示例输出 (关联部分 2 )
https://deb.debian.org/debian-security
```
因此,修改 Debian12 软件源的方式也有两种,本文将尝试使用第 `2` 种修改方案。
1. 删除当前软件源配置文件,重新启用常规 `sources.list` 配置文件的配置方案。
2. 根据当前软件源配置文件的语法规则,仅修改配置文件。
使用 `vim` 编辑器编辑 `debian.sources` 配置文件,执行以下命令。
```bash
## 编辑 debian.sources 配置文件
$ sudo vim /etc/apt/sources.list.d/debian.sources
```
删除里面全部内容,添加以下配置项,并保存。
```bash
## 系统软件源配置项
## 配置 Debian 系统默认软件源脚本
$ sudo bash -c 'cat > /etc/apt/sources.list.d/debian.sources <<EOF
Types: deb
URIs: https://mirrors.ustc.edu.cn/debian
Suites: bookworm bookworm-updates
Suites: trixie trixie-updates
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
Types: deb
URIs: https://mirrors.ustc.edu.cn/debian-security
Suites: bookworm-security
Suites: trixie-security
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
EOF'
```
为了防止 `Cloud-Init` 服务意外修改软件源配置,需要添加文件保护,执行以下命令。
@@ -155,10 +103,10 @@ $ sudo apt full-upgrade
```bash
## 安装系统软件
$ sudo apt install qemu-guest-agent btop tmux logrotate cron neovim zsh git
$ sudo apt install qemu-guest-agent btop curl tmux logrotate cron neovim zsh git
## 安装系统自动更新工具
$ sudo apt install unattended-upgrades powermgmt-base python3-gi
$ sudo apt install unattended-upgrades powermgmt-base
## 安装网络工具
$ sudo apt install nftables sshguard lsof knot-dnsutils
@@ -166,6 +114,9 @@ $ sudo apt install nftables sshguard lsof knot-dnsutils
## 安装网络检测工具(可选)
$ sudo apt install iftop iperf3 iperf
## 刷新 systemd 日志分类索引
$ sudo journalctl --update-catalog
## 写入磁盘
$ sudo sync
```
@@ -175,10 +126,8 @@ $ sudo sync
`Zsh` 是比 `Bash` 好用的 `Shell` 程序,使用 `oh-my-zsh` 进行配置。
```bash
## 使用清华大学镜像站安装 oh-my-zsh
$ cd && git clone --depth=1 https://mirrors.tuna.tsinghua.edu.cn/git/ohmyzsh.git
$ cd ohmyzsh/tools && REMOTE=https://mirrors.tuna.tsinghua.edu.cn/git/ohmyzsh.git sh install.sh
## 安装 oh-my-zsh
$ sh -c "$(curl -fsSL https://install.ohmyz.sh)"
## 询问是否切换默认 shell,输入 Y
@@ -187,21 +136,44 @@ Time to change your default shell to zsh:
Do you want to change your default shell to zsh? [Y/n] y
## oh-my-zsh 安装后清理
$ cd && rm -rvf ohmyzsh .bash_history .zsh_history .shell.pre-oh-my-zsh
$ cd && rm -rvf .bash_history .zsh_history .shell.pre-oh-my-zsh
```
### 1.5.调整内核参数
### 1.5.配置默认编辑器
由于该 Debian 虚拟机模板将用于克隆内网 DNS 服务器,因此需要调整内核参数来简单优化性能
Debian 系统默认编辑器为 `nano` ,推荐将默认编辑器更换为 `neovim` ,执行以下命令
使用 `neovim` 编辑器编辑 **内核参数** 配置文件,执行以下命令。
```bash
## 修改系统默认编辑器(选择 nvim 所在条目,即可将 neovim 设为默认编辑器)
$ sudo update-alternatives --config editor
#### 系统默认编辑器示例输出
There are 4 choices for the alternative editor (providing /usr/bin/editor).
Selection Path Priority Status
------------------------------------------------------------
* 0 /bin/nano 40 auto mode
1 /bin/nano 40 manual mode
2 /usr/bin/nvim 30 manual mode
3 /usr/bin/vim.basic 30 manual mode
4 /usr/bin/vim.tiny 15 manual mode
Press <enter> to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/bin/nvim to provide /usr/bin/editor (editor) in manual mode
```
### 1.6.调整内核参数
由于该虚拟机将作为内网 DNS 服务器的克隆模板,需调整内核参数以优化性能。
编辑 **内核参数** 配置文件,执行以下命令。
```bash
## 编辑 内核参数 配置文件
$ sudo nvim /etc/sysctl.d/99-sysctl.conf
$ sudo editor /etc/sysctl.d/99-sysctl.conf
```
在配置文件中添加以下配置项,注意配置中间的空格。
在配置文件中输入以下内容,注意配置中间的空格。
```bash
# This configuration file is customized by fox,
@@ -215,22 +187,20 @@ net.core.default_qdisc = fq_codel
# Other adjustable system parameters
net.core.netdev_budget = 600
net.core.netdev_budget_usecs = 20000
net.core.netdev_max_backlog = 4096
net.core.somaxconn = 8192
net.core.rmem_max = 26214400
net.core.wmem_max = 655360
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.igmp_max_memberships = 256
net.ipv4.tcp_challenge_ack_limit = 1000
net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 120
net.ipv4.tcp_max_syn_backlog = 512
net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_max_syn_backlog = 4096
net.ipv4.tcp_notsent_lowat = 131072
net.ipv4.tcp_rmem = 4096 87380 26214400
net.ipv4.tcp_wmem = 4096 16384 655360
net.ipv4.tcp_rmem = 4096 524288 16777216
net.ipv4.tcp_wmem = 4096 524288 16777216
net.ipv6.conf.all.use_tempaddr = 0
net.ipv6.conf.default.use_tempaddr = 0
@@ -244,7 +214,7 @@ net.ipv6.conf.default.use_tempaddr = 0
$ sudo sysctl --system
```
### 1.6.调整系统时间
### 1.7.调整系统时间
默认情况下 Debian 云镜像的系统时间需要调整,执行以下命令将系统时区设置为中国时区。
@@ -256,7 +226,7 @@ $ sudo timedatectl set-timezone Asia/Shanghai
$ date -R
#### 系统时间示例输出
Mon, 26 Jun 2023 16:16:16 +0800
Wed, 27 Aug 2025 17:02:17 +0800
```
Debian 云镜像默认使用 `systemd-timesyncd.service` 同步时间,且需要调整为使用国内 NTP 服务器。
@@ -268,10 +238,10 @@ Debian 云镜像默认使用 `systemd-timesyncd.service` 同步时间,且需
$ sudo mkdir -p /etc/systemd/timesyncd.conf.d
## 创建 NTP 配置文件
$ sudo nvim /etc/systemd/timesyncd.conf.d/10-server-ntp.conf
$ sudo editor /etc/systemd/timesyncd.conf.d/10-server-ntp.conf
```
在配置文件中添加以下配置项,并保存。
在配置文件中输入以下内容,并保存。
```bash
# This configuration file is customized by fox,
@@ -297,24 +267,25 @@ $ sudo systemctl status systemd-timesyncd.service
```bash
#### NTP 服务示例输出
● systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; preset: enabled)
Active: active (running) since Mon 2024-10-07 18:06:29 CST; 9s ago
Loaded: loaded (/usr/lib/systemd/system/systemd-timesyncd.service; enabled; preset: enabled)
Active: active (running) since Wed 2025-08-27 17:03:13 CST; 6s ago
Invocation: 7dcb974725ac43638a4ae3df51644f84
Docs: man:systemd-timesyncd.service(8)
Main PID: 1706 (systemd-timesyn)
Main PID: 4540 (systemd-timesyn)
Status: "Contacted time server 203.107.6.88:123 (ntp.aliyun.com)."
Tasks: 2 (limit: 2315)
Memory: 1.4M
CPU: 113ms
Tasks: 2 (limit: 2317)
Memory: 1.5M (peak: 2.2M)
CPU: 261ms
CGroup: /system.slice/systemd-timesyncd.service
└─1706 /lib/systemd/systemd-timesyncd
└─4540 /usr/lib/systemd/systemd-timesyncd
Oct 07 18:06:29 DNS01 systemd[1]: Starting systemd-timesyncd.service - Network Time Synchronization...
Oct 07 18:06:29 DNS01 systemd[1]: Started systemd-timesyncd.service - Network Time Synchronization.
Oct 07 18:06:29 DNS01 systemd-timesyncd[1706]: Contacted time server 203.107.6.88:123 (ntp.aliyun.com).
Oct 07 18:06:29 DNS01 systemd-timesyncd[1706]: Initial clock synchronization to Mon 2024-10-07 18:06:29.499548 CST.
Aug 27 17:03:12 DNST01 systemd[1]: Starting systemd-timesyncd.service - Network Time Synchronization...
Aug 27 17:03:13 DNST01 systemd[1]: Started systemd-timesyncd.service - Network Time Synchronization.
Aug 27 17:03:13 DNST01 systemd-timesyncd[4540]: Contacted time server 203.107.6.88:123 (ntp.aliyun.com).
Aug 27 17:03:13 DNST01 systemd-timesyncd[4540]: Initial clock synchronization to Wed 2025-08-27 17:03:13.200663 CST.
```
### 1.7.配置自动更新
### 1.8.配置自动更新
配置 Debian 云镜像的系统自动更新,与配置 PVE 系统自动更新方法基本一致,参阅 [03.PVE系统调整](./03.PVE系统调整.md) 。
@@ -339,10 +310,10 @@ $ sudo dpkg-reconfigure -plow unattended-upgrades
```bash
## 编辑 20auto-upgrades 配置文件
$ sudo nvim /etc/apt/apt.conf.d/20auto-upgrades
$ sudo editor /etc/apt/apt.conf.d/20auto-upgrades
```
删除里面全部内容,添加以下配置项,并保存。
清空当前全部配置项后,输入以下内容,并保存。
配置文件中,用来控制更新周期的参数为 `APT::Periodic::Unattended-Upgrade` `3` 表示更新周期为 `3` 天。
@@ -360,11 +331,9 @@ APT::Periodic::CleanInterval "1";
```bash
## 编辑 50unattended-upgrades 配置文件
$ sudo nvim /etc/apt/apt.conf.d/50unattended-upgrades
$ sudo editor /etc/apt/apt.conf.d/50unattended-upgrades
```
根据 “注释” 中相关说明,调整配置文件。
因为该配置文件很长,完整的配置文件可查看 [debian_dns_50unattended_upgrades.conf](./src/debian/debian_dns_50unattended_upgrades.conf) 以便对比。
```bash
@@ -372,7 +341,7 @@ $ sudo nvim /etc/apt/apt.conf.d/50unattended-upgrades
"origin=Debian,codename=${distro_codename}-updates";
## 在配置文件末尾增加以下配置项,代表启用,并调整参数
## 在配置文件末尾增加以下内容,代表启用,并调整参数
Unattended-Upgrade::AutoFixInterruptedDpkg "true";
@@ -388,14 +357,14 @@ Unattended-Upgrade::Automatic-Reboot-Time "03:00";
```
系统自动更新配置文件修改完成后,需要重设自动更新定时器,执行以下命令。
系统自动更新配置文件修改完成后,需调整自动更新定时器,执行以下命令。
```bash
## 配置系统定时器
$ sudo systemctl edit apt-daily-upgrade.timer
```
根据配置文件中的提示,在中间空白处填入以下配置项
根据配置文件中的提示,在中间空白处填入以下内容
```bash
## 定时器配置项
@@ -419,7 +388,7 @@ $ sudo systemctl restart apt-daily-upgrade.timer
$ sudo systemctl status apt-daily-upgrade.timer
```
### 1.8.配置定时任务
### 1.9.配置定时任务
本步骤为可选操作,主要设置系统定时重启。
@@ -431,7 +400,7 @@ $ sudo crontab -l
$ sudo crontab -e
```
在配置文件末尾,增加以下配置项
在配置文件末尾,增加以下内容
```bash
## 定时任务配置项
@@ -440,7 +409,7 @@ $ sudo crontab -e
```
### 1.9.清理系统
### 1.10.清理系统
Debian 模板虚拟机已经配置完成,在将其转换为模板前需要对系统进行清理。
@@ -451,6 +420,9 @@ $ sudo bash -c 'apt clean && apt autoclean && apt autoremove --purge'
## 清理系统缓存
$ sudo bash -c 'find /var/cache/apt/ /var/cache/smartdns/ /var/lib/apt/lists/ /tmp/ -type f -print -delete'
## 重置机器标识符
$ sudo truncate -s 0 /etc/machine-id /var/lib/dbus/machine-id
## 清理系统日志
$ sudo bash -c 'find /var/log/ -type f -print -delete'
@@ -463,13 +435,13 @@ $ sudo shutdown now
## 2.虚拟机转为模板
Debian 模板虚拟机关机后,进入 PVE 的 WEB 管理界面。
在模板虚拟机关机后,进入 PVE 的 WEB 管理界面。
在左侧虚拟机列表中,鼠标 **右键单击** Debian 模板虚拟机,在弹出的菜单中选择 `转换成模板`
在左侧虚拟机列表中,鼠标 **右键单击** 模板虚拟机,在弹出的菜单中选择 `转换成模板`
需要说明的是,虚拟机 `转换成模板` 的操作不可逆
需要说明的是,虚拟机 `转换成模板` 的操作具有不可逆
如果某些 Debian 系统配置项有问题,能在该模板克隆出来的新虚拟机中进行修改,或删除并重新制作模板
系统配置存在问题,能在该模板克隆的新虚拟机中修改,或删除现有模板并重新制作。
![虚拟机转模板](img/p05/vm_to_template.jpeg)
+51 -25
View File
@@ -2,7 +2,7 @@
在上一篇文章 [05.PVE制作虚拟机模板](./05.PVE制作虚拟机模板.md) 中,已经制作好了虚拟机模板。
接下来将使用该模板克隆出新的虚拟机,并安装 Adguard Home 作为内网 DNS 服务器。
接下来将基于该模板克隆虚拟机,并通过安装 DNS 服务器软件,完成内网 DNS 服务器的搭建
鼠标 **右键单击** 虚拟机模板,在弹出的菜单中选择 `克隆`
@@ -78,11 +78,11 @@
$ sudo lsof -n -i :53
#### 端口占用示例输出
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
systemd-r 1797 systemd-resolve 18u IPv4 23024 0t0 UDP 127.0.0.53:domain
systemd-r 1797 systemd-resolve 19u IPv4 23025 0t0 TCP 127.0.0.53:domain (LISTEN)
systemd-r 1797 systemd-resolve 20u IPv4 23026 0t0 UDP 127.0.0.54:domain
systemd-r 1797 systemd-resolve 21u IPv4 23027 0t0 TCP 127.0.0.54:domain (LISTEN)
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
systemd-r 357 systemd-resolve 18u IPv4 3293 0t0 UDP 127.0.0.53:domain
systemd-r 357 systemd-resolve 19u IPv4 3294 0t0 TCP 127.0.0.53:domain (LISTEN)
systemd-r 357 systemd-resolve 20u IPv4 3295 0t0 UDP 127.0.0.54:domain
systemd-r 357 systemd-resolve 21u IPv4 3296 0t0 TCP 127.0.0.54:domain (LISTEN)
```
当前系统 `53` 端口被 `systemd-resolved.service` 占用,会导致设置 DNS 服务时监听端口失败。
@@ -94,10 +94,10 @@ systemd-r 1797 systemd-resolve 21u IPv4 23027 0t0 TCP 127.0.0.54:domai
$ sudo mkdir -p /etc/systemd/resolved.conf.d
## 创建 systemd-resolved 配置文件
$ sudo nvim /etc/systemd/resolved.conf.d/10-server-dns.conf
$ sudo editor /etc/systemd/resolved.conf.d/10-server-dns.conf
```
在配置文件中添加以下配置项,并保存。
在配置文件中输入以下内容,并保存。
```bash
# This configuration file is customized by fox,
@@ -171,7 +171,7 @@ $ sudo crontab -l
$ sudo crontab -e
```
在配置文件末尾,增加以下配置项
在配置文件末尾,增加以下内容
```bash
## 定时任务配置项
@@ -206,7 +206,7 @@ $ sudo systemctl enable dnsmasq.service
$ sudo systemctl stop dnsmasq.service
```
下载 `SmartDNS` 最新版本时,请根据系统架构选择合适的版本,执行以下命令。
下载 `SmartDNS` 当前最新版本时,请根据系统架构选择合适的版本,执行以下命令。
```bash
## 创建存放 SmartDNS 安装包的临时目录
@@ -216,7 +216,7 @@ $ mkdir -p /tmp/SmartDNS
$ cd /tmp/SmartDNS
## 下载 SmartDNS 安装包
$ curl -LR -O https://github.com/pymumu/smartdns/releases/download/Release46.1/smartdns.1.2025.03.02-1533.x86_64-linux-all.tar.gz
$ curl -LR -O https://github.com/pymumu/smartdns/releases/download/Release48.2/smartdns.1.2026.06.28-1614.x86_64-linux-all.tar.gz
## 解压缩 SmartDNS 安装包
$ tar zxf smartdns.*.x86_64-linux-all.tar.gz
@@ -231,6 +231,13 @@ $ chmod +x ./install
$ sudo ./install -i
```
后续 `SmartDNS` 推出新版本需原位升级时:先下载最新版本,再将以下命令替代原安装命令执行,升级后现有配置不会丢失。
```bash
## 升级 SmartDNS
$ sudo ./install -U
```
修改 `SmartDNS` 配置之前,需检查 `smartdns.service` 服务状态,确保该服务开机自启。
```bash
@@ -261,16 +268,16 @@ $ sudo curl -LR -o /etc/smartdns.d/anti-ad.smartdns.conf https://anti-ad.net/ant
```bash
## 下载加速规则安装脚本
$ sudo curl -LR -o /opt/smartdns-plugin.sh https://gitee.com/callmer/smartdns_china_list_installer/raw/main/smartdns_plugin.sh
$ sudo curl -LR -o /usr/local/bin/smartdns-plugin.sh https://gitee.com/callmer/smartdns_china_list_installer/raw/main/smartdns_plugin.sh
## 设置脚本可执行权限
$ sudo chmod +x /opt/smartdns-plugin.sh
$ sudo chmod +x /usr/local/bin/smartdns-plugin.sh
## 设置脚本文件防篡改
$ sudo chattr +i /opt/smartdns-plugin.sh
$ sudo chattr +i /usr/local/bin/smartdns-plugin.sh
## 执行脚本
$ sudo bash /opt/smartdns-plugin.sh
$ sudo /usr/local/bin/smartdns-plugin.sh
```
### 6.2.定时任务
@@ -282,7 +289,7 @@ $ sudo bash /opt/smartdns-plugin.sh
$ sudo crontab -e
```
在配置文件末尾,增加以下配置项
在配置文件末尾,增加以下内容
```bash
## 定时任务配置项
@@ -300,7 +307,7 @@ $ sudo crontab -e
20 9 * * * /usr/bin/curl --retry-connrefused --retry 5 --retry-delay 5 --retry-max-time 60 -fsSLR -o /etc/smartdns.d/anti-ad.smartdns.conf https://anti-ad.net/anti-ad-for-smartdns.conf
30 9 * * * /usr/bin/bash /opt/smartdns-plugin.sh
30 9 * * * /usr/local/bin/smartdns-plugin.sh
```
### 6.3. SmartDNS 主配置
@@ -324,20 +331,20 @@ $ sudo rm -rvf /var/run/smartdns.pid /run/smartdns.pid
$ sudo mv /etc/smartdns/smartdns.conf /etc/smartdns/smartdns.conf.bak
```
使用 `neovim` 编辑器创建 `SmartDNS` 主配置文件,执行以下命令。
创建 `SmartDNS` 主配置文件,执行以下命令。
```bash
## 创建 SmartDNS 主配置文件
$ sudo nvim /etc/smartdns/smartdns.conf
$ sudo editor /etc/smartdns/smartdns.conf
```
在编辑器对话框中输入以下内容,并保存。
**额外说明:**
- `SmartDNS` 端口监听参数为 `6053@lo` ,请根据实际情况进行调整
- `SmartDNS` 端口监听参数为 `6053@lo` WebUI 端口监听参数为 `5380` ,请根据实际情况进行调整
- 检查配置文件中关于本地域名及其上游 DNS 服务器相关配置,请根据实际情况进行调整
- WebUI 默认用户名密码为 `admin/password` ,若需公网访问建议将默认密码修改为强密码
```bash
# This configuration file is customized by fox,
@@ -359,6 +366,18 @@ conf-file /etc/smartdns.d/*.conf
log-level notice
log-console yes
log-size 16M
log-num 8
audit-enable yes
audit-SOA yes
audit-size 16M
audit-num 8
plugin smartdns_ui.so
smartdns-ui.ip https://[::]:5380
smartdns-ui.token-expire 1800
smartdns-ui.max-query-log-age 604800
bind [::]:6053@lo
bind-tcp [::]:6053@lo
@@ -379,12 +398,16 @@ rr-ttl-max 28800
rr-ttl-reply-max 14400
server-tcp 180.184.1.1 -bootstrap-dns
server-tcp 114.114.114.114 -bootstrap-dns
server-tcp 101.226.4.6 -bootstrap-dns
server-tcp 2400:3200::1 -bootstrap-dns
server-tcp 2400:3200:baba::1 -bootstrap-dns
server-tls dot.360.cn -fallback
server-quic dns.alidns.com -fallback
server-https https://doh.360.cn/dns-query -fallback
server-tls dot.pub
server-tls dns.alidns.com
server-https https://doh.pub/dns-query
server-https https://dns.alidns.com/dns-query
@@ -399,11 +422,11 @@ server-https https://dns.alidns.com/dns-query
$ sudo mkdir -p /etc/dnsmasq.d
```
使用 `neovim` 编辑器创建 `Dnsmasq` 主配置文件,执行以下命令。
创建 `Dnsmasq` 主配置文件,执行以下命令。
```bash
## 创建 Dnsmasq 主配置文件
$ sudo nvim /etc/dnsmasq.d/10-server-dnsmasq.conf
$ sudo editor /etc/dnsmasq.d/10-server-dnsmasq.conf
```
在编辑器对话框中输入以下内容,并保存。
@@ -412,6 +435,8 @@ $ sudo nvim /etc/dnsmasq.d/10-server-dnsmasq.conf
- 请根据系统内存使用情况,调整缓存参数 `cache-size`
- 配置文件中监听的网卡名为 `eth0` ,请根据实际情况进行调整
- 配置文件中内网域名为 `fox.internal` ,请根据实际情况进行调整
- `Dnsmasq` 有且仅有 `SmartDNS` 作为上游 DNS 服务器
@@ -441,6 +466,7 @@ domain-needed
no-hosts
no-negcache
no-resolv
no-round-robin
rebind-localhost-ok
stop-dns-rebind
+188 -92
View File
@@ -23,7 +23,7 @@
### 1.1.配置 SSH
与配置内网 DNS 服务器时一样,首先需要调整系统的 SSH 登录权限参数。
与配置 Debian 模板虚拟机时一样,首先需要调整系统的 SSH 登录权限参数。
在虚拟机的命令行界面,使用 `vim` 编辑器编辑 `sshd` 服务的配置文件,执行以下命令。
@@ -32,7 +32,7 @@
$ sudo vim /etc/ssh/sshd_config.d/10-server-sshd.conf
```
在配置文件中添加以下配置项,并保存。
在配置文件中输入以下内容,并保存。
```bash
## SSH 配置项
@@ -52,36 +52,26 @@ $ sudo systemctl restart ssh.service
### 1.2.配置软件源
使用终端工具登录 TS 服务器,常用终端工具请参阅 [01.PVE系统安装](./01.PVE系统安装.md)
首先需要对 Debian 系统软件源进行修改,这里使用 [USTC](https://mirrors.ustc.edu.cn) 镜像站作为演示。
当系统版本发生变化时,请参考 USTC 镜像站的官方说明 [USTC Mirror Help - Debian](https://mirrors.ustc.edu.cn/help/debian.html) 。
使用 `vim` 编辑器编辑 `debian.sources` 配置文件,执行以下命令。
使用如下命令对 `debian.sources` 配置文件进行修改
```bash
## 编辑 debian.sources 配置文件
$ sudo vim /etc/apt/sources.list.d/debian.sources
```
删除里面全部内容,添加以下配置项,并保存。
```bash
## 系统软件源配置项
## 配置 Debian 系统默认软件源脚本
$ sudo bash -c 'cat > /etc/apt/sources.list.d/debian.sources <<EOF
Types: deb
URIs: https://mirrors.ustc.edu.cn/debian
Suites: bookworm bookworm-updates
Suites: trixie trixie-updates
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
Types: deb
URIs: https://mirrors.ustc.edu.cn/debian-security
Suites: bookworm-security
Suites: trixie-security
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
EOF'
```
为了防止 `Cloud-Init` 服务意外修改软件源配置,需要添加文件保护,执行以下命令。
@@ -97,16 +87,6 @@ $ lsattr /etc/apt/sources.list.d/debian.sources
----i---------e------- /etc/apt/sources.list.d/debian.sources
```
进一步添加 TS 签名密钥以及软件源,执行以下命令。
```bash
## 添加 TS 签名密钥
$ curl -fsSL https://pkgs.tailscale.com/stable/debian/bookworm.noarmor.gpg | sudo tee /usr/share/keyrings/tailscale-archive-keyring.gpg > /dev/null
## 添加 TS 软件源
$ curl -fsSL https://pkgs.tailscale.com/stable/debian/bookworm.tailscale-keyring.list | sudo tee /etc/apt/sources.list.d/tailscale.list
```
### 1.3.安装软件
软件源设置完成后,需要更新系统,执行以下命令。
@@ -126,20 +106,23 @@ $ sudo apt full-upgrade
```bash
## 安装系统软件
$ sudo apt install qemu-guest-agent btop tmux logrotate cron neovim zsh git
$ sudo apt install qemu-guest-agent btop curl tmux logrotate cron neovim zsh git
## 安装系统自动更新工具
$ sudo apt install unattended-upgrades powermgmt-base python3-gi
$ sudo apt install unattended-upgrades powermgmt-base
## 安装网络工具
$ sudo apt install dnsmasq conntrack nftables sshguard lsof knot-dnsutils
$ sudo apt install ethtool dnsmasq conntrack nftables sshguard lsof knot-dnsutils
## 安装 TS
$ sudo apt install tailscale
$ curl -fsSL https://tailscale.com/install.sh | sh
## 安装网络检测工具(可选)
$ sudo apt install iftop iperf3 iperf
## 刷新 systemd 日志分类索引
$ sudo journalctl --update-catalog
## 写入磁盘
$ sudo sync
```
@@ -149,10 +132,8 @@ $ sudo sync
`Zsh` 是比 `Bash` 好用的 `Shell` 程序,使用 `oh-my-zsh` 进行配置。
```bash
## 使用清华大学镜像站安装 oh-my-zsh
$ cd && git clone --depth=1 https://mirrors.tuna.tsinghua.edu.cn/git/ohmyzsh.git
$ cd ohmyzsh/tools && REMOTE=https://mirrors.tuna.tsinghua.edu.cn/git/ohmyzsh.git sh install.sh
## 安装 oh-my-zsh
$ sh -c "$(curl -fsSL https://install.ohmyz.sh)"
## 询问是否切换默认 shell,输入 Y
@@ -161,19 +142,42 @@ Time to change your default shell to zsh:
Do you want to change your default shell to zsh? [Y/n] y
## oh-my-zsh 安装后清理
$ cd && rm -rvf ohmyzsh .bash_history .zsh_history .shell.pre-oh-my-zsh
$ cd && rm -rvf .bash_history .zsh_history .shell.pre-oh-my-zsh
```
### 1.5.调整内核模块
### 1.5.配置默认编辑器
使用 `neovim` 编辑器编辑 **内核模块** 配置文件,执行以下命令。
Debian 系统默认编辑器为 `nano` ,推荐将默认编辑器更换为 `neovim` ,执行以下命令。
```bash
## 修改系统默认编辑器(选择 nvim 所在条目,即可将 neovim 设为默认编辑器)
$ sudo update-alternatives --config editor
#### 系统默认编辑器示例输出
There are 4 choices for the alternative editor (providing /usr/bin/editor).
Selection Path Priority Status
------------------------------------------------------------
* 0 /bin/nano 40 auto mode
1 /bin/nano 40 manual mode
2 /usr/bin/nvim 30 manual mode
3 /usr/bin/vim.basic 30 manual mode
4 /usr/bin/vim.tiny 15 manual mode
Press <enter> to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/bin/nvim to provide /usr/bin/editor (editor) in manual mode
```
### 1.6.调整内核模块
编辑 **内核模块** 配置文件,执行以下命令。
```bash
## 创建 内核模块 配置文件
$ sudo nvim /etc/modules-load.d/10-server-modules.conf
$ sudo editor /etc/modules-load.d/10-server-modules.conf
```
在配置文件中添加以下配置项,并保存。
在配置文件中输入以下内容,并保存。
```bash
# This configuration file is customized by fox,
@@ -183,16 +187,16 @@ nf_conntrack
```
### 1.6.调整内核参数
### 1.7.调整内核参数
使用 `neovim` 编辑器编辑 **内核参数** 配置文件,执行以下命令。
编辑 **内核参数** 配置文件,执行以下命令。
```bash
## 编辑 内核参数 配置文件
$ sudo nvim /etc/sysctl.d/99-sysctl.conf
$ sudo editor /etc/sysctl.d/99-sysctl.conf
```
在配置文件中添加以下配置项,注意配置中间的空格。
在配置文件中输入以下内容,注意配置中间的空格。
```bash
# This configuration file is customized by fox,
@@ -201,7 +205,7 @@ $ sudo nvim /etc/sysctl.d/99-sysctl.conf
kernel.panic = 20
kernel.panic_on_oops = 1
net.core.default_qdisc = fq_codel
net.core.default_qdisc = fq_pie
net.ipv4.tcp_congestion_control = bbr
net.ipv4.ip_forward = 1
@@ -211,13 +215,13 @@ net.ipv6.conf.default.forwarding = 1
# Other adjustable system parameters
net.core.netdev_budget = 600
net.core.netdev_budget_usecs = 20000
net.core.netdev_budget = 800
net.core.netdev_max_backlog = 8192
net.core.rps_sock_flow_entries = 32768
net.core.somaxconn = 8192
net.core.rmem_max = 26214400
net.core.wmem_max = 655360
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 67108864
net.core.wmem_max = 67108864
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
@@ -236,21 +240,13 @@ net.ipv4.conf.default.send_redirects = 0
net.ipv4.igmp_max_memberships = 256
net.ipv4.route.error_burst = 500
net.ipv4.route.error_cost = 100
net.ipv4.route.redirect_load = 2
net.ipv4.route.redirect_silence = 2048
net.ipv4.tcp_adv_win_scale = -2
net.ipv4.tcp_challenge_ack_limit = 1000
net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 120
net.ipv4.tcp_max_syn_backlog = 512
net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_max_syn_backlog = 4096
net.ipv4.tcp_notsent_lowat = 131072
net.ipv4.tcp_rmem = 8192 262144 536870912
net.ipv4.tcp_wmem = 4096 16384 536870912
net.ipv4.tcp_rmem = 4096 1048576 67108864
net.ipv4.tcp_wmem = 4096 1048576 67108864
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0
@@ -262,7 +258,7 @@ net.ipv6.conf.all.use_tempaddr = 0
net.ipv6.conf.default.use_tempaddr = 0
net.netfilter.nf_conntrack_acct = 1
net.netfilter.nf_conntrack_checksum = 0
net.netfilter.nf_conntrack_checksum = 1
net.netfilter.nf_conntrack_tcp_timeout_established = 7440
```
@@ -274,7 +270,7 @@ net.netfilter.nf_conntrack_tcp_timeout_established = 7440
$ sudo sysctl --system
```
### 1.7.调整系统时间
### 1.8.调整系统时间
默认情况下 Debian 云镜像的系统时间需要调整,执行以下命令将系统时区设置为中国时区。
@@ -295,10 +291,10 @@ Debian 云镜像默认使用 `systemd-timesyncd.service` 同步时间,且需
$ sudo mkdir -p /etc/systemd/timesyncd.conf.d
## 创建 NTP 配置文件
$ sudo nvim /etc/systemd/timesyncd.conf.d/10-server-ntp.conf
$ sudo editor /etc/systemd/timesyncd.conf.d/10-server-ntp.conf
```
在配置文件中添加以下配置项,并保存。
在配置文件中输入以下内容,并保存。
```bash
# This configuration file is customized by fox,
@@ -319,7 +315,7 @@ $ sudo systemctl restart systemd-timesyncd.service
$ sudo systemctl status systemd-timesyncd.service
```
### 1.8.配置自动更新
### 1.9.配置自动更新
配置系统自动更新策略,执行以下命令,使用键盘 `左右方向键` 进行选择,`回车键` 进行确认。
@@ -335,10 +331,10 @@ $ sudo dpkg-reconfigure -plow unattended-upgrades
```bash
## 编辑 20auto-upgrades 配置文件
$ sudo nvim /etc/apt/apt.conf.d/20auto-upgrades
$ sudo editor /etc/apt/apt.conf.d/20auto-upgrades
```
删除里面全部内容,添加以下配置项,并保存。
清空当前全部配置项后,输入以下内容,并保存。
配置文件中,用来控制更新周期的参数为 `APT::Periodic::Unattended-Upgrade` `7` 表示更新周期为 `7` 天。
@@ -356,11 +352,9 @@ APT::Periodic::CleanInterval "1";
```bash
## 编辑 50unattended-upgrades 配置文件
$ sudo nvim /etc/apt/apt.conf.d/50unattended-upgrades
$ sudo editor /etc/apt/apt.conf.d/50unattended-upgrades
```
根据 “注释” 中相关说明,调整配置文件。
因为该配置文件很长,完整的配置文件可查看 [debian_ts_50unattended_upgrades.conf](./src/debian/debian_ts_50unattended_upgrades.conf) 以便对比。
```bash
@@ -372,7 +366,7 @@ $ sudo nvim /etc/apt/apt.conf.d/50unattended-upgrades
"origin=Tailscale,codename=${distro_codename},label=Tailscale";
## 在配置文件末尾增加以下配置项,代表启用,并调整参数
## 在配置文件末尾增加以下内容,代表启用,并调整参数
Unattended-Upgrade::AutoFixInterruptedDpkg "true";
@@ -388,14 +382,14 @@ Unattended-Upgrade::Automatic-Reboot-Time "13:00";
```
系统自动更新配置文件修改完成后,需要重设自动更新定时器,执行以下命令。
系统自动更新配置文件修改完成后,需调整自动更新定时器,执行以下命令。
```bash
## 配置系统定时器
$ sudo systemctl edit apt-daily-upgrade.timer
```
根据配置文件中的提示,在中间空白处填入以下配置项
根据配置文件中的提示,在中间空白处填入以下内容
```bash
## 定时器配置项
@@ -409,7 +403,7 @@ RandomizedDelaySec=0
设置完成后,重启自动更新定时器并检查其状态,执行以下命令。
在输出结果中,看到系统自动更新的触发时间为 `02:00` 则表示设置正确。
在输出结果中,看到系统自动更新的触发时间为 `12:00` 则表示设置正确。
```bash
## 重启触发器
@@ -419,7 +413,7 @@ $ sudo systemctl restart apt-daily-upgrade.timer
$ sudo systemctl status apt-daily-upgrade.timer
```
### 1.9.配置防火墙
### 1.10.配置防火墙
修改防火墙配置之前,需检查 `nftables.service` 服务状态,确保该服务开机自启。
@@ -431,14 +425,14 @@ $ sudo systemctl status nftables.service
$ sudo systemctl enable nftables.service
```
使用 `neovim` 编辑器修改 `nftables` 配置文件,执行以下命令。
修改 `nftables` 配置文件,执行以下命令。
```bash
## 备份 nftables 配置文件
$ sudo mv /etc/nftables.conf /etc/nftables.conf.bak
## 创建新的 nftables 配置文件
$ sudo nvim /etc/nftables.conf
$ sudo editor /etc/nftables.conf
```
由于防火墙配置文件很长,因此请查阅文件 [debian_ts_nftables.conf](./src/debian/debian_ts_nftables.conf) 进行复制。
@@ -450,7 +444,7 @@ $ sudo nvim /etc/nftables.conf
$ sudo systemctl restart nftables.service
```
### 1.10.调整系统端口
### 1.11.调整系统端口
为了正常使用 `53` 端口,需要对 `systemd-resolved.service` 进行配置,执行以下命令。
@@ -459,10 +453,10 @@ $ sudo systemctl restart nftables.service
$ sudo mkdir -p /etc/systemd/resolved.conf.d
## 创建 systemd-resolved 配置文件
$ sudo nvim /etc/systemd/resolved.conf.d/10-server-dns.conf
$ sudo editor /etc/systemd/resolved.conf.d/10-server-dns.conf
```
在配置文件中添加以下配置项,并保存。
在配置文件中输入以下内容,并保存。
```bash
# This configuration file is customized by fox,
@@ -489,7 +483,7 @@ $ sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
$ sudo systemctl restart systemd-resolved.service
```
### 1.11.配置 Dnsmasq
### 1.12.配置 Dnsmasq
检查 `dnsmasq.service` 服务状态,确保该服务开机自启。
@@ -508,11 +502,11 @@ $ sudo systemctl enable dnsmasq.service
$ sudo mkdir -p /etc/dnsmasq.d
```
使用 `neovim` 编辑器创建 `Dnsmasq` 主配置文件,执行以下命令。
创建 `Dnsmasq` 主配置文件,执行以下命令。
```bash
## 创建 Dnsmasq 主配置文件
$ sudo nvim /etc/dnsmasq.d/10-server-dnsmasq.conf
$ sudo editor /etc/dnsmasq.d/10-server-dnsmasq.conf
```
在编辑器对话框中输入以下内容,并保存。
@@ -521,6 +515,8 @@ $ sudo nvim /etc/dnsmasq.d/10-server-dnsmasq.conf
- 请根据系统内存使用情况,调整缓存参数 `cache-size`
- 配置文件中监听的网卡名为 `eth0``tailscale0` ,请根据实际情况进行调整
- 配置文件中内网域名为 `fox.internal` ,请根据实际情况进行调整
- `Dnsmasq` 上游 DNS 服务器分为三类,请根据实际情况进行调整
@@ -553,6 +549,7 @@ domain-needed
no-hosts
no-negcache
no-resolv
no-round-robin
rebind-localhost-ok
stop-dns-rebind
@@ -589,7 +586,106 @@ $ sudo systemctl restart dnsmasq.service
根据不同的启动参数,TS 服务将具有不同的业务能力。
### 2.1.启动模式
### 2.1.网卡调优
根据 TS 官方文档 [Performance best practices](https://tailscale.com/kb/1320/performance-best-practices) 的技术指引,优化网卡的 `rx-udp-gro-forwarding``rx-gro-list` 参数可提升 UDP 转发性能。
本文将使用 `ethtool` 工具并结合 `systemd` 服务提供参数自动配置方案。
```bash
## 创建 tailscale-nic-optim 优化脚本
$ sudo editor /usr/local/bin/tailscale-nic-optim.sh
```
在脚本文件中输入以下内容,并保存。
```bash
#!/bin/sh
ETHTOOL_PATH=$(command -v ethtool)
if [ -z "$ETHTOOL_PATH" ]; then
echo "Error: ethtool command not found. Please install ethtool."
exit 1
fi
NETDEV=$(ip route show default | awk '{for (i=1; i<=NF; i++) {if ($i == "dev") {print $(i+1); exit;}}}')
if [ -z "$NETDEV" ]; then
echo "Error: Could not determine default network device using 'ip route show default'."
exit 1
fi
echo "Configuring network device $NETDEV using $ETHTOOL_PATH for Tailscale optimizations..."
"$ETHTOOL_PATH" -K "$NETDEV" rx-udp-gro-forwarding on rx-gro-list off
if [ "$?" -eq 0 ]; then
echo "Configuration successful for $NETDEV."
exit 0
else
echo "Error: ethtool configuration failed. Check permissions or device status."
exit 1
fi
```
设置脚本可执行权限,并防止脚本被意外修改。
```bash
## 设置脚本可执行权限
$ sudo chmod +x /usr/local/bin/tailscale-nic-optim.sh
## 设置脚本文件防篡改
$ sudo chattr +i /usr/local/bin/tailscale-nic-optim.sh
```
进一步创建 `tailscale-nic-optim` 服务配置文件,以满足系统自动化设置需求。
```bash
## 创建 tailscale-nic-optim.service 配置文件
$ sudo editor /etc/systemd/system/tailscale-nic-optim.service
```
在服务配置文件中输入以下内容,并保存。
```bash
# This configuration file is customized by fox,
# Optimize for TS UDP performance.
[Unit]
Description=Tailscale Network Optimization for Subnet/Exit Nodes
ConditionVirtualization=!container
After=network-online.target
Wants=network-online.target
Before=tailscaled.service
[Service]
Type=oneshot
ExecStart=/usr/local/bin/tailscale-nic-optim.sh
RemainAfterExit=yes
StandardOutput=journal
[Install]
WantedBy=multi-user.target
```
由于修改了服务项,需要执行以下命令进行重载。
```bash
## 服务重载
$ sudo systemctl daemon-reload
```
执行以下命令让 `tailscale-nic-optim` 服务开机自启动。
```bash
## 设置 tailscale-nic-optim 服务开机自启
$ sudo systemctl enable --now tailscale-nic-optim.service
```
### 2.2.启动模式
若仅需 TS 组网功能,执行以下命令。
@@ -621,7 +717,7 @@ $ sudo tailscale up --advertise-exit-node --accept-routes --advertise-routes=172
执行命令后,TS 将自动显示登录链接,只需根据链接进行登录操作即可。
### 2.2.自动更新
### 2.3.自动更新
目前 TS 将跟随系统自动更新,若需额外开启 TS 的自动更新功能,执行以下命令。
@@ -633,7 +729,7 @@ $ sudo tailscale set --auto-update
$ sudo tailscale set --auto-update=false
```
### 2.3.定时任务
### 2.4.定时任务
本步骤为可选操作,主要用于设置 TS 定时重启。
@@ -642,7 +738,7 @@ $ sudo tailscale set --auto-update=false
$ sudo crontab -e
```
在配置文件末尾,增加以下配置项
在配置文件末尾,增加以下内容
```bash
## 定时任务配置项
+19 -16
View File
@@ -2,13 +2,11 @@
在所有虚拟机创建并配置完成后,可以使用 PVE 自带的备份功能周期性的将虚拟机备份。
点击 PVE 的 `数据中心` ,在右侧菜单中选择 `备份` 功能。
点击顶部 `添加` 按钮,添加一个 `备份作业`
点击 PVE 的 `数据中心` ,在右侧菜单中选择 `备份` 功能,并点击顶部 `添加`
![添加备份作业](img/p08/vm_new_backup_job.jpeg)
### 1.1.常规选项
### 1.1.常规
在弹出的 `创建:备份作业` 对话框中,勾选底部 `高级` 选项,`备份作业` 的各项参数如下。
@@ -17,10 +15,7 @@
|节点|`node01`|选择当前 PVE 服务器节点|
|存储|`local`|选择存放备份文件的路径|
|计划|`*-01,16 03:30`|`备份作业` 执行的时间计划|
|选择模式|`包括选中的VMs`|执行备份的虚拟机对象|
|通知模式|`默认(自动)`|执行备份时的通知模式,保持默认即可|
|发送邮箱至|`your_email@domain.com`|`备份作业` 邮件的收件人邮箱|
|发送邮件|`总是`|发送 `备份作业` 邮件提醒的条件|
|选择模式|`包括选中的虚拟机`|执行备份的虚拟机对象|
|压缩|`ZSTD`|选择备份文件的压缩算法|
|模式|`停止`|选择备份虚拟机的方式,推荐使用 `停止` |
|启用|**勾选**|表示该 `备份作业` 为启用状态|
@@ -38,25 +33,33 @@
![备份作业常规选项](img/p08/vm_job_normal.jpeg)
### 1.2.保留选项
### 1.2.通知
|参数|值|说明|
|--|--|--|
|通知模式|`使用全局通知设置`|执行备份时的通知模式,保持默认即可|
![备份作业通知选项](img/p08/vm_job_email.jpeg)
### 1.3.保留
该选项将控制备份文件的保留个数,选择保留最近 `3` 份备份文件。
![备份作业保留选项](img/p08/vm_job_keep.jpeg)
### 1.3.备注模板
### 1.4.备注模板
该选项将按照设置的内容,自动重命名备份文件。
`备份日志` 右侧文本框中输入 `{{vmid}}_{{guestname}}_Auto_Backup`
点击 `创建` 按钮,`备份作业` 创建完成。
`备份日志` 右侧文本框中输入 `{{vmid}}-{{guestname}}-Autobackup`
![备份作业备注选项](img/p08/vm_job_notes.jpeg)
### 1.4.高级选项
### 1.5.高级
该选项提供 `备份作业` 行时的高级可调参数,仅需勾选 `重复错过` 选项即可。
该选项提供 `备份作业` 行时的高级可调参数,仅需勾选 `重复错过` 选项即可。
点击 `创建` ,此 `备份作业` 即完成设置与创建。
![备份作业高级选项](img/p08/vm_job_advanced.jpeg)
@@ -68,7 +71,7 @@
![备份作业调度模拟器](img/p08/vm_job_time_test.jpeg)
`计划` 处将显示 `备份作业` 的执行时间参数,点击 `模拟` 按钮,在右侧将显示模拟的时间结果。
`计划` 处将显示 `备份作业` 的执行时间参数,点击 `模拟` ,在右侧将显示模拟的时间结果。
确认 `备份作业` 的执行时间周期是否符合预期。
+1 -7
View File
@@ -3,13 +3,7 @@
## 介绍
PVE 虚拟化平台的安装以及折腾手记。
- PVE ISO 版本:8.3-1 (更新时间: 2024-11-21)
- 演示机:
- CPUN6005
- 内存:16GB DDR4
- 网卡:I226-V
- 硬盘:500GB NVMe
- PVE ISO 版本:9.1-1 (更新时间: 2025-11-19)
- PVE 网络:
- IPv4 网络
Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 KiB

After

Width:  |  Height:  |  Size: 227 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 293 KiB

After

Width:  |  Height:  |  Size: 261 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 KiB

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 308 KiB

After

Width:  |  Height:  |  Size: 310 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 455 KiB

After

Width:  |  Height:  |  Size: 218 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 303 KiB

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 318 KiB

After

Width:  |  Height:  |  Size: 156 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 269 KiB

After

Width:  |  Height:  |  Size: 273 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 203 KiB

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 303 KiB

After

Width:  |  Height:  |  Size: 307 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 194 KiB

After

Width:  |  Height:  |  Size: 266 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 331 KiB

After

Width:  |  Height:  |  Size: 603 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 281 KiB

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 370 KiB

After

Width:  |  Height:  |  Size: 375 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 429 KiB

After

Width:  |  Height:  |  Size: 403 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 375 KiB

After

Width:  |  Height:  |  Size: 404 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 KiB

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 132 KiB

After

Width:  |  Height:  |  Size: 244 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 141 KiB

After

Width:  |  Height:  |  Size: 230 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 165 KiB

After

Width:  |  Height:  |  Size: 248 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 495 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 189 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 499 KiB

After

Width:  |  Height:  |  Size: 664 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 KiB

After

Width:  |  Height:  |  Size: 302 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 143 KiB

After

Width:  |  Height:  |  Size: 222 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 192 KiB

After

Width:  |  Height:  |  Size: 362 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 223 KiB

After

Width:  |  Height:  |  Size: 259 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 124 KiB

After

Width:  |  Height:  |  Size: 447 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 184 KiB

After

Width:  |  Height:  |  Size: 328 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 129 KiB

After

Width:  |  Height:  |  Size: 168 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 KiB

After

Width:  |  Height:  |  Size: 391 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 185 KiB

After

Width:  |  Height:  |  Size: 343 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 135 KiB

After

Width:  |  Height:  |  Size: 219 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 139 KiB

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 111 KiB

After

Width:  |  Height:  |  Size: 222 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 187 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 154 KiB

After

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 385 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 200 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 179 KiB

After

Width:  |  Height:  |  Size: 275 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 175 KiB

After

Width:  |  Height:  |  Size: 318 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 288 KiB

After

Width:  |  Height:  |  Size: 427 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

After

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 198 KiB

After

Width:  |  Height:  |  Size: 259 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 231 KiB

After

Width:  |  Height:  |  Size: 230 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 KiB

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

After

Width:  |  Height:  |  Size: 139 KiB

@@ -31,6 +31,7 @@ Unattended-Upgrade::Origins-Pattern {
"origin=Debian,codename=${distro_codename},label=Debian";
"origin=Debian,codename=${distro_codename},label=Debian-Security";
"origin=Debian,codename=${distro_codename}-security,label=Debian-Security";
// "o=Debian Backports,n=${distro_codename}-backports,l=Debian Backports";
// Archive or Suite based matching:
// Note that this will silently match a different release after
@@ -39,7 +40,7 @@ Unattended-Upgrade::Origins-Pattern {
// "o=Debian,a=stable";
// "o=Debian,a=stable-updates";
// "o=Debian,a=proposed-updates";
// "o=Debian Backports,a=${distro_codename}-backports,l=Debian Backports";
// "o=Debian Backports,a=stable-backports,l=Debian Backports";
};
// Python regular expressions, matching packages to exclude from upgrading
@@ -72,7 +73,7 @@ Unattended-Upgrade::Package-Blacklist {
// Split the upgrade into the smallest possible chunks so that
// they can be interrupted with SIGTERM. This makes the upgrade
// a bit slower but it has the benefit that shutdown while a upgrade
// a bit slower but it has the benefit that shutdown while an upgrade
// is running is possible (with a small delay)
//Unattended-Upgrade::MinimalSteps "true";
+9 -11
View File
@@ -9,22 +9,20 @@ net.core.default_qdisc = fq_codel
# Other adjustable system parameters
net.core.netdev_budget = 600
net.core.netdev_budget_usecs = 20000
net.core.netdev_max_backlog = 4096
net.core.somaxconn = 8192
net.core.rmem_max = 26214400
net.core.wmem_max = 655360
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.igmp_max_memberships = 256
net.ipv4.tcp_challenge_ack_limit = 1000
net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 120
net.ipv4.tcp_max_syn_backlog = 512
net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_max_syn_backlog = 4096
net.ipv4.tcp_notsent_lowat = 131072
net.ipv4.tcp_rmem = 4096 87380 26214400
net.ipv4.tcp_wmem = 4096 16384 655360
net.ipv4.tcp_rmem = 4096 524288 16777216
net.ipv4.tcp_wmem = 4096 524288 16777216
net.ipv6.conf.all.use_tempaddr = 0
net.ipv6.conf.default.use_tempaddr = 0
+1
View File
@@ -22,6 +22,7 @@ domain-needed
no-hosts
no-negcache
no-resolv
no-round-robin
rebind-localhost-ok
stop-dns-rebind
+5 -5
View File
@@ -1,18 +1,18 @@
## 下载加速规则安装脚本
$ sudo curl -LR -o /opt/dnsmasq-plugin.sh https://gitee.com/felixonmars/dnsmasq-china-list/raw/master/install.sh
$ sudo curl -LR -o /usr/local/bin/dnsmasq-plugin.sh https://gitee.com/felixonmars/dnsmasq-china-list/raw/master/install.sh
## 设置脚本可执行权限
$ sudo chmod +x /opt/dnsmasq-plugin.sh
$ sudo chmod +x /usr/local/bin/dnsmasq-plugin.sh
## 设置脚本文件防篡改
$ sudo chattr +i /opt/dnsmasq-plugin.sh
$ sudo chattr +i /usr/local/bin/dnsmasq-plugin.sh
## 执行脚本
$ sudo bash /opt/dnsmasq-plugin.sh
$ sudo /usr/local/bin/dnsmasq-plugin.sh
## 设置 crontab
25 9 * * * /usr/bin/curl --retry-connrefused --retry 5 --retry-delay 5 --retry-max-time 60 -fsSLR -o /etc/dnsmasq.d/anti-ad.dnsmasq.conf https://anti-ad.net/anti-ad-for-dnsmasq.conf
35 9 * * * /usr/bin/bash /opt/dnsmasq-plugin.sh
35 9 * * * /usr/local/bin/dnsmasq-plugin.sh
+18 -2
View File
@@ -17,6 +17,18 @@ conf-file /etc/smartdns.d/*.conf
log-level notice
log-console yes
log-size 16M
log-num 8
audit-enable yes
audit-SOA yes
audit-size 16M
audit-num 8
plugin smartdns_ui.so
smartdns-ui.ip https://[::]:5380
smartdns-ui.token-expire 1800
smartdns-ui.max-query-log-age 604800
bind [::]:6053@lo
bind-tcp [::]:6053@lo
@@ -37,12 +49,16 @@ rr-ttl-max 28800
rr-ttl-reply-max 14400
server-tcp 180.184.1.1 -bootstrap-dns
server-tcp 114.114.114.114 -bootstrap-dns
server-tcp 101.226.4.6 -bootstrap-dns
server-tcp 2400:3200::1 -bootstrap-dns
server-tcp 2400:3200:baba::1 -bootstrap-dns
server-tls dot.360.cn -fallback
server-quic dns.alidns.com -fallback
server-https https://doh.360.cn/dns-query -fallback
server-tls dot.pub
server-tls dns.alidns.com
server-https https://doh.pub/dns-query
server-https https://dns.alidns.com/dns-query
+1 -1
View File
@@ -10,5 +10,5 @@
20 9 * * * /usr/bin/curl --retry-connrefused --retry 5 --retry-delay 5 --retry-max-time 60 -fsSLR -o /etc/smartdns.d/anti-ad.smartdns.conf https://anti-ad.net/anti-ad-for-smartdns.conf
30 9 * * * /usr/bin/bash /opt/smartdns-plugin.sh
30 9 * * * /usr/local/bin/smartdns-plugin.sh
+39 -38
View File
@@ -1,72 +1,73 @@
#!/bin/bash
#!/bin/sh
set -e
WORKDIR="$(mktemp -d)"
CONFDIR="/etc/smartdns.d"
SERVERS=(223.5.5.5 180.184.1.1 119.29.29.29 114.114.114.114 2402:4e00:: 2400:3200::1)
GROUP=(flash)
SERVERS="223.5.5.5 180.184.1.1 119.29.29.29 114.114.114.114 2402:4e00:: 2400:3200::1"
GROUP="flash"
# Others: 223.6.6.6 119.28.28.28
# Not using best possible CDN pop: 1.2.4.8 210.2.4.8
# Broken?: 180.76.76.76
CONF_WITH_SERVERS=(accelerated-domains.china google.china apple.china)
CONF_WITH_GROUP=(dns-group.china)
CONF_SIMPLE=(bogus-nxdomain.china)
CONF_WITH_SERVERS="accelerated-domains.china google.china apple.china"
CONF_WITH_GROUP="dns-group.china"
CONF_SIMPLE="bogus-nxdomain.china"
echo "Checking whether the configuration folder exists..."
if [ ! -d "$CONFDIR" ]; then
mkdir -p "$CONFDIR"
fi
[ -d "$CONFDIR" ] || mkdir -p "$CONFDIR"
echo "Downloading latest configurations..."
git clone --depth=1 https://gitee.com/felixonmars/dnsmasq-china-list.git "$WORKDIR"
git clone --depth=1 https://gitee.com/felixonmars/dnsmasq-china-list.git "$WORKDIR" || { echo "Git clone failed"; rm -rf "$WORKDIR"; exit 1; }
#git clone --depth=1 https://pagure.io/dnsmasq-china-list.git "$WORKDIR"
#git clone --depth=1 https://github.com/felixonmars/dnsmasq-china-list.git "$WORKDIR"
#git clone --depth=1 https://bitbucket.org/felixonmars/dnsmasq-china-list.git "$WORKDIR"
#git clone --depth=1 https://gitlab.com/felixonmars/dnsmasq-china-list.git "$WORKDIR"
#git clone --depth=1 https://e.coding.net/felixonmars/dnsmasq-china-list.git "$WORKDIR"
#git clone --depth=1 https://atomgit.com/felixonmars/dnsmasq-china-list.git "$WORKDIR"
#git clone --depth=1 https://codehub.devcloud.huaweicloud.com/dnsmasq-china-list00001/dnsmasq-china-list.git "$WORKDIR"
#git clone --depth=1 http://repo.or.cz/dnsmasq-china-list.git "$WORKDIR"
echo "Removing old configurations..."
for _conf in "${CONF_WITH_SERVERS[@]}" "${CONF_WITH_GROUP[@]}" "${CONF_SIMPLE[@]}"; do
rm -f "$CONFDIR/$_conf"*.conf
for _conf in $CONF_WITH_SERVERS $CONF_WITH_GROUP $CONF_SIMPLE; do
rm -f "$CONFDIR/$_conf"*.conf
done
echo "Installing new configurations..."
for _conf in "${CONF_WITH_SERVERS[@]}" "${CONF_WITH_GROUP[@]}" "${CONF_SIMPLE[@]}"; do
if [[ "${CONF_WITH_SERVERS[@]}" =~ $_conf ]]; then
sed -En 's|^server=/([^/]*)/114.114.114.114$|\1|p' "$WORKDIR/$_conf.conf" | grep -Ev '^#' > "$WORKDIR/$_conf.step1.raw"
sed -En "s/(.*)/nameserver \\/\\1\\/${GROUP[@]}/p" "$WORKDIR/$_conf.step1.raw" > "$WORKDIR/$_conf.step2.raw"
cp "$WORKDIR/$_conf.step2.raw" "$CONFDIR/$_conf.smartdns.conf"
fi
for _conf in $CONF_WITH_SERVERS $CONF_WITH_GROUP $CONF_SIMPLE; do
if [[ "${CONF_WITH_GROUP[@]}" =~ $_conf ]]; then
for _server in "${SERVERS[@]}"; do
echo "server $_server -group ${GROUP[@]} -exclude-default-group" >> "$WORKDIR/$_conf.raw"
done
cp "$WORKDIR/$_conf.raw" "$CONFDIR/$_conf.smartdns.conf"
fi
if echo " $CONF_WITH_SERVERS " | grep -q " $_conf "; then
sed -n 's/^server=\/\([^\/]*\)\/114.114.114.114$/\1/p' "$WORKDIR/$_conf.conf" | grep -v '^#' > "$WORKDIR/$_conf.step1.raw"
sed -e "s/.*/nameserver \/&\/$GROUP/" "$WORKDIR/$_conf.step1.raw" > "$WORKDIR/$_conf.step2.raw"
cp "$WORKDIR/$_conf.step2.raw" "$CONFDIR/$_conf.smartdns.conf"
fi
if echo " $CONF_WITH_GROUP " | grep -q " $_conf "; then
for _server in $SERVERS; do
echo "server $_server -group $GROUP -exclude-default-group" >> "$WORKDIR/$_conf.raw"
done
cp "$WORKDIR/$_conf.raw" "$CONFDIR/$_conf.smartdns.conf"
fi
if echo " $CONF_SIMPLE " | grep -q " $_conf "; then
sed -e "s/=/ /" "$WORKDIR/$_conf.conf" > "$WORKDIR/$_conf.raw"
cp "$WORKDIR/$_conf.raw" "$CONFDIR/$_conf.smartdns.conf"
fi
if [[ "${CONF_SIMPLE[@]}" =~ $_conf ]]; then
sed -e "s|=| |" "$WORKDIR/$_conf.conf" > "$WORKDIR/$_conf.raw"
cp "$WORKDIR/$_conf.raw" "$CONFDIR/$_conf.smartdns.conf"
fi
done
echo "Restarting smartdns service..."
if hash systemctl 2>/dev/null; then
systemctl restart smartdns
elif hash service 2>/dev/null; then
service smartdns restart
elif hash rc-service 2>/dev/null; then
rc-service smartdns restart
elif hash busybox 2>/dev/null && [[ -d "/etc/init.d" ]]; then
/etc/init.d/smartdns restart
if command -v systemctl >/dev/null 2>&1; then
systemctl restart smartdns
elif command -v service >/dev/null 2>&1; then
service smartdns restart
elif command -v rc-service >/dev/null 2>&1; then
rc-service smartdns restart
elif [ -x "/etc/init.d/smartdns" ]; then
/etc/init.d/smartdns restart
else
echo "Now please restart smartdns since I don't know how to do it."
echo "Now please restart smartdns manually."
fi
echo "Cleaning up..."
rm -r "$WORKDIR"
rm -rf "$WORKDIR"
+2 -2
View File
@@ -1,12 +1,12 @@
Types: deb
URIs: https://mirrors.ustc.edu.cn/debian
Suites: bookworm bookworm-updates
Suites: trixie trixie-updates
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
Types: deb
URIs: https://mirrors.ustc.edu.cn/debian-security
Suites: bookworm-security
Suites: trixie-security
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
@@ -31,6 +31,7 @@ Unattended-Upgrade::Origins-Pattern {
"origin=Debian,codename=${distro_codename},label=Debian";
"origin=Debian,codename=${distro_codename},label=Debian-Security";
"origin=Debian,codename=${distro_codename}-security,label=Debian-Security";
// "o=Debian Backports,n=${distro_codename}-backports,l=Debian Backports";
"origin=Tailscale,codename=${distro_codename},label=Tailscale";
// Archive or Suite based matching:
@@ -40,7 +41,7 @@ Unattended-Upgrade::Origins-Pattern {
// "o=Debian,a=stable";
// "o=Debian,a=stable-updates";
// "o=Debian,a=proposed-updates";
// "o=Debian Backports,a=${distro_codename}-backports,l=Debian Backports";
// "o=Debian Backports,a=stable-backports,l=Debian Backports";
};
// Python regular expressions, matching packages to exclude from upgrading
@@ -73,7 +74,7 @@ Unattended-Upgrade::Package-Blacklist {
// Split the upgrade into the smallest possible chunks so that
// they can be interrupted with SIGTERM. This makes the upgrade
// a bit slower but it has the benefit that shutdown while a upgrade
// a bit slower but it has the benefit that shutdown while an upgrade
// is running is possible (with a small delay)
//Unattended-Upgrade::MinimalSteps "true";
@@ -174,5 +175,5 @@ Unattended-Upgrade::Remove-Unused-Dependencies "true";
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "03:00";
Unattended-Upgrade::Automatic-Reboot-Time "13:00";
+12 -20
View File
@@ -4,7 +4,7 @@
kernel.panic = 20
kernel.panic_on_oops = 1
net.core.default_qdisc = fq_codel
net.core.default_qdisc = fq_pie
net.ipv4.tcp_congestion_control = bbr
net.ipv4.ip_forward = 1
@@ -14,13 +14,13 @@ net.ipv6.conf.default.forwarding = 1
# Other adjustable system parameters
net.core.netdev_budget = 600
net.core.netdev_budget_usecs = 20000
net.core.netdev_budget = 800
net.core.netdev_max_backlog = 8192
net.core.rps_sock_flow_entries = 32768
net.core.somaxconn = 8192
net.core.rmem_max = 26214400
net.core.wmem_max = 655360
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 67108864
net.core.wmem_max = 67108864
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
@@ -39,21 +39,13 @@ net.ipv4.conf.default.send_redirects = 0
net.ipv4.igmp_max_memberships = 256
net.ipv4.route.error_burst = 500
net.ipv4.route.error_cost = 100
net.ipv4.route.redirect_load = 2
net.ipv4.route.redirect_silence = 2048
net.ipv4.tcp_adv_win_scale = -2
net.ipv4.tcp_challenge_ack_limit = 1000
net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 120
net.ipv4.tcp_max_syn_backlog = 512
net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_max_syn_backlog = 4096
net.ipv4.tcp_notsent_lowat = 131072
net.ipv4.tcp_rmem = 8192 262144 536870912
net.ipv4.tcp_wmem = 4096 16384 536870912
net.ipv4.tcp_rmem = 4096 1048576 67108864
net.ipv4.tcp_wmem = 4096 1048576 67108864
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0
@@ -65,6 +57,6 @@ net.ipv6.conf.all.use_tempaddr = 0
net.ipv6.conf.default.use_tempaddr = 0
net.netfilter.nf_conntrack_acct = 1
net.netfilter.nf_conntrack_checksum = 0
net.netfilter.nf_conntrack_checksum = 1
net.netfilter.nf_conntrack_tcp_timeout_established = 7440
+1
View File
@@ -22,6 +22,7 @@ domain-needed
no-hosts
no-negcache
no-resolv
no-round-robin
rebind-localhost-ok
stop-dns-rebind
+28
View File
@@ -0,0 +1,28 @@
#!/bin/sh
ETHTOOL_PATH=$(command -v ethtool)
if [ -z "$ETHTOOL_PATH" ]; then
echo "Error: ethtool command not found. Please install ethtool."
exit 1
fi
NETDEV=$(ip route show default | awk '{for (i=1; i<=NF; i++) {if ($i == "dev") {print $(i+1); exit;}}}')
if [ -z "$NETDEV" ]; then
echo "Error: Could not determine default network device using 'ip route show default'."
exit 1
fi
echo "Configuring network device $NETDEV using $ETHTOOL_PATH for Tailscale optimizations..."
"$ETHTOOL_PATH" -K "$NETDEV" rx-udp-gro-forwarding on rx-gro-list off
if [ "$?" -eq 0 ]; then
echo "Configuration successful for $NETDEV."
exit 0
else
echo "Error: ethtool configuration failed. Check permissions or device status."
exit 1
fi
@@ -0,0 +1,19 @@
# This configuration file is customized by fox,
# Optimize for TS UDP performance.
[Unit]
Description=Tailscale Network Optimization for Subnet/Exit Nodes
ConditionVirtualization=!container
After=network-online.target
Wants=network-online.target
Before=tailscaled.service
[Service]
Type=oneshot
ExecStart=/usr/local/bin/tailscale-nic-optim.sh
RemainAfterExit=yes
StandardOutput=journal
[Install]
WantedBy=multi-user.target
-5
View File
@@ -1,5 +0,0 @@
# This configuration file is customized by fox,
# Optimize netfilter related modules at system boot.
nf_conntrack
+4 -3
View File
@@ -31,8 +31,9 @@ Unattended-Upgrade::Origins-Pattern {
"origin=Debian,codename=${distro_codename},label=Debian";
"origin=Debian,codename=${distro_codename},label=Debian-Security";
"origin=Debian,codename=${distro_codename}-security,label=Debian-Security";
// "o=Debian Backports,n=${distro_codename}-backports,l=Debian Backports";
"origin=Proxmox,codename=${distro_codename},label=Proxmox Debian Repository";
// "origin=Proxmox,codename=${distro_codename},label=Proxmox Ceph Debian Repository";
// "origin=Proxmox,codename=${distro_codename},label=Proxmox Ceph 19 Squid Debian Repository";
// Archive or Suite based matching:
// Note that this will silently match a different release after
@@ -41,7 +42,7 @@ Unattended-Upgrade::Origins-Pattern {
// "o=Debian,a=stable";
// "o=Debian,a=stable-updates";
// "o=Debian,a=proposed-updates";
// "o=Debian Backports,a=${distro_codename}-backports,l=Debian Backports";
// "o=Debian Backports,a=stable-backports,l=Debian Backports";
};
// Python regular expressions, matching packages to exclude from upgrading
@@ -74,7 +75,7 @@ Unattended-Upgrade::Package-Blacklist {
// Split the upgrade into the smallest possible chunks so that
// they can be interrupted with SIGTERM. This makes the upgrade
// a bit slower but it has the benefit that shutdown while a upgrade
// a bit slower but it has the benefit that shutdown while an upgrade
// is running is possible (with a small delay)
//Unattended-Upgrade::MinimalSteps "true";