Compare commits

...
3 Commits
Author SHA1 Message Date
CallMeR 13b46590d0 修订 SmartDNS 配置命令 2026-07-27 01:05:01 +08:00
CallMeR 1984f7689e 精简 SmartDNS 配置 2026-07-27 00:45:41 +08:00
CallMeR 698969cadb 更新虚拟机设置和截图 2026-07-26 19:17:14 +08:00
48 changed files with 75 additions and 70 deletions
+56 -44
View File
@@ -18,45 +18,45 @@
勾选底部 `高级` 选项,显示完整的配置参数,节点即 “本机” ,`VM ID``名称` 可自定义。
![虚拟机名称](img/p04/vm_id.jpeg)
![虚拟机名称](img/p04/vm_id.jpg)
### 1.2.操作系统
无需使用任何安装介质,客户机操作系统类别选择 `Linux` 版本选择 `6.x - 2.6 Kernel` 即可。
无需使用任何安装介质,客户机操作系统类别选择 `Linux` 版本选择 `7.x - 2.6 Kernel` 即可。
![虚拟机操作系统](img/p04/vm_os.jpeg)
![虚拟机操作系统](img/p04/vm_os.jpg)
### 1.3.系统
SCSI 控制器保持默认 `VirtIO SCSI single` ,机型可选 `q35` ,并勾选 `Qemu代理` 选项。
SCSI 控制器保持默认 `VirtIO SCSI single` ,机型可选 `q35` ,并勾选 `Qemu 代理` 选项。
固件可选 `OVMF (UEFI)` ,并勾选 `添加 TPM` 选项,存储路径需根据实际情况进行调整,演示为 `local-lvm`
`预注册密钥` 可启用,启用后将预装特定于发行版和 Microsoft 标准的安全启动密钥。
![虚拟机系统](img/p04/vm_system.jpeg)
![虚拟机系统](img/p04/vm_system.jpg)
### 1.4.磁盘
因使用 Debian 云镜像制作虚拟机模板,此处需删除所有 `磁盘`
![虚拟机磁盘](img/p04/vm_hd.jpeg)
![虚拟机磁盘](img/p04/vm_hd.jpg)
### 1.5.CPU
CPU `类` 选择 `host` `插槽``核心` 数根据物理 CPU 核心数进行酌情设置。
CPU `类` 选择 `host` `插槽``核心` 数根据物理 CPU 核心数进行酌情设置。
若 PVE 服务器内有多颗物理 CPU ,则推荐勾选 `启用NUMA` 选项。
若 PVE 服务器内有多颗物理 CPU ,则推荐勾选 `启用 NUMA` 选项。
![虚拟机CPU](img/p04/vm_cpu.jpeg)
![虚拟机CPU](img/p04/vm_cpu.jpg)
### 1.6.内存
内存一般 `2G` 足够使用,取消勾选 `Ballooning设备`
内存一般 `2G` 足够使用,取消勾选 `Ballooning 设备`
对于 `Kernel Samepage Merging (KSM)` 内核同页合并功能,建议保留勾选状态。
对于 `允许 KSM` 内核同页合并功能,建议保留勾选状态。
![虚拟机内存](img/p04/vm_mem.jpeg)
![虚拟机内存](img/p04/vm_mem.jpg)
### 1.7.网络
@@ -64,7 +64,7 @@ CPU `类别` 选择 `host` `插槽` 与 `核心` 数根据物理 CPU 核心
因在 [02.PVE初始化配置](./02.PVE初始化配置.md) 中曾创建未桥接物理网口的内部网桥,故可根据实际需求选择是否使用纯内部网桥作为该参数值。
![虚拟机网口](img/p04/vm_network_port.jpeg)
![虚拟机网口](img/p04/vm_network_port.jpg)
多数情况下,无需使用 PVE 内建防火墙,因此 **取消勾选** 网络设备的 `防火墙` 选项。
@@ -72,13 +72,13 @@ CPU `类别` 选择 `host` `插槽` 与 `核心` 数根据物理 CPU 核心
即有 n 个 CPU 核心,此处多队列也设置为 n 。
![虚拟机网卡多队列](img/p04/vm_network_queue.jpeg)
![虚拟机网卡多队列](img/p04/vm_network_queue.jpg)
### 1.8.确认
接下来查看设置总览,确认无误后即可点击 `完成`
![虚拟机确认](img/p04/vm_confirm.jpeg)
![虚拟机确认](img/p04/vm_confirm.jpg)
## 2.调整硬件参数
@@ -86,9 +86,33 @@ CPU `类别` 选择 `host` `插槽` 与 `核心` 数根据物理 CPU 核心
查看虚拟机详情页,在虚拟机 `硬件` 配置页面,移除其 `CD/DVD驱动器`
![虚拟机删除光驱](img/p04/vm_delete_cd.jpeg)
![虚拟机删除光驱](img/p04/vm_delete_cd.jpg)
### 2.2.导入镜像文件
### 2.2.添加 VirtIO RNG
为确保系统拥有充足的可用熵,需为模板虚拟机添加 `VirtIO RNG` 熵源。
点击顶部 `新增` 菜单,选择 `VirtIO RNG`
![虚拟机添加RNG](img/p04/vm_rng.jpg)
`熵源` 选择 `/dev/urandom` ,其余参数保持默认即可。
![虚拟机RNG参数](img/p04/vm_rng_details.jpg)
### 2.3.添加串行端口
在基于 Debian Cloud Image 创建 VM 时,须在虚拟机硬件列表中添加 `串行端口` 设备 `serial0`
补全串口硬件可避免系统因缺失 `/dev/ttyS0` 而无限循环报 `agetty` 输入/输出错误,同时可启用 PVE 的 `xterm.js` 控制台(支持原生复制粘贴)。
![虚拟机添加串行端口](img/p04/vm_serial.jpg)
`串行端口` 设置为 `0` 即可。
![虚拟机RNG参数](img/p04/vm_serial_details.jpg)
### 2.4.导入镜像文件
使用终端工具登录 PVE 服务器,并进入 `/tmp` 目录,执行以下命令创建一个目录。
@@ -131,17 +155,17 @@ unused0: successfully imported disk 'local-lvm:vm-1001-disk-2'
磁盘导入成功后,虚拟机硬件列表中将显示一块未使用的磁盘设备,可鼠标 **双击** 该设备进行配置调整。
![虚拟机新磁盘](img/p04/vm_unused_hd.jpeg)
![虚拟机新磁盘](img/p04/vm_unused_hd.jpg)
当宿主机使用 SSD 作为物理存储设备,并且虚拟磁盘采用 Thin Provisioning (精简置备)模式时,可考虑开启以下选项:
- `Discard` `丢弃` 选项,有助于存储空间回收。
- `丢弃` `Discard` 选项,有助于存储空间回收。
- `SSD Emulation` `SSD 仿真` ) 选项,让虚拟机将虚拟磁盘视为 SSD 存储设备。
- `SSD 仿真` `SSD Emulation` ) 选项,让虚拟机将虚拟磁盘视为 SSD 存储设备。
在弹出的对话框中,确认 `IO thread` 选项为 **勾选** 状态,并点击 `添加`
在弹出的对话框中,确认 `IO thread` 选项为 **勾选** 状态,并点击 `新增`
![虚拟机使用该磁盘](img/p04/vm_enable_hd.jpeg)
![虚拟机使用该磁盘](img/p04/vm_enable_hd.jpg)
导入的镜像仅具备 `3G` 磁盘空间,为方便后续使用,可通过 `qm` 命令直接将该磁盘调整至目标容量。
@@ -156,39 +180,27 @@ $ qm disk resize 1001 scsi0 24G
或鼠标 **单击** 选中该磁盘,选择页面顶部 `磁盘操作` 菜单的子菜单 `调整大小`
![虚拟机磁盘扩容](img/p04/vm_hd_resize.jpeg)
![虚拟机磁盘扩容](img/p04/vm_hd_resize.jpg)
在弹出的对话框中,给该磁盘增加 `21G` 磁盘空间。
![虚拟机磁盘增加18G](img/p04/vm_hd_scale_up.jpeg)
![虚拟机磁盘增加18G](img/p04/vm_hd_scale_up.jpg)
### 2.3.添加 CloudInit
### 2.5.添加 CloudInit
为确保 Cloud-Init 能正常初始化系统,需为模板虚拟机添加 `CloudInit 设备`
点击顶部 `添加` 菜单,选择 `CloudInit 设备`
同样通过 `新增` 菜单,选择 `CloudInit 设备`
![虚拟机添加ci](img/p04/vm_cloudinit.jpeg)
![虚拟机添加ci](img/p04/vm_cloudinit.jpg)
`总线/设备` 选择 `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)
![虚拟机ci参数](img/p04/vm_ci_details.jpg)
虚拟机硬件设备修改完成后,如下图所示。
![虚拟机全部硬件](img/p04/vm_hardware_all.jpeg)
![虚拟机全部硬件](img/p04/vm_hardware_all.jpg)
## 3.调整配置参数
@@ -208,15 +220,15 @@ $ qm disk resize 1001 scsi0 24G
鼠标 **双击** `引导顺序` 选项,进入编辑界面。
`scsi0` 设备处勾选 “已启用” 复选框,并通过排序功能将其拖拽至首位,点击 `OK` 即可。
`scsi0` 设备处勾选 “已启用” 复选框,并通过排序功能将其拖拽至首位,点击 `确定` 即可。
![虚拟机引导顺序](img/p04/vm_boot.jpeg)
![虚拟机引导顺序](img/p04/vm_boot.jpg)
### 3.2.设置平板指针
关闭 `使用平板指针` 选项,可以一定程度上降低虚拟机的 CPU 使用率。
![虚拟机平板指针](img/p04/vm_tablet.jpeg)
![虚拟机平板指针](img/p04/vm_tablet.jpg)
## 4.设置 Cloud-Init
+4 -1
View File
@@ -418,7 +418,10 @@ Debian 模板虚拟机已经配置完成,在将其转换为模板前需要对
$ 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 bash -c 'find /var/cache/apt/ /var/lib/apt/lists/ /tmp/ -type f -print -delete'
## 清理 SmartDNS 缓存(按需)
$ sudo bash -c 'find /var/cache/smartdns/ /var/lib/smartdns/ -type f -print -delete'
## 重置机器标识符
$ sudo truncate -s 0 /etc/machine-id /var/lib/dbus/machine-id
+12 -21
View File
@@ -209,26 +209,11 @@ $ sudo systemctl stop dnsmasq.service
下载 `SmartDNS` 当前最新版本时,请根据系统架构选择合适的版本,执行以下命令。
```bash
## 创建存放 SmartDNS 安装包的临时目录
$ mkdir -p /tmp/SmartDNS
## 进入目录
$ cd /tmp/SmartDNS
## 下载 SmartDNS 安装包
$ 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
## 进入安装包目录
$ cd smartdns
## 设置脚本可执行权限
$ chmod +x ./install
$ curl -LR https://github.com/pymumu/smartdns/releases/download/Release48.2/smartdns.1.2026.06.28-1614.x86_64-linux-all.tar.gz | tar -xz -C /tmp
## 安装 SmartDNS
$ sudo ./install -i
$ sudo /tmp/smartdns/install -i
```
后续 `SmartDNS` 推出新版本需原位升级时:先下载最新版本,再将以下命令替代原安装命令执行,升级后现有配置不会丢失。
@@ -402,15 +387,21 @@ 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
server-quic dns.alidns.com -fallback
server-https https://doh.360.cn/dns-query -fallback
```
`SmartDNS` 主配置文件配置完成后,执行以下命令修正文件权限
```bash
## 修正 SmartDNS 主配置文件权限
$ sudo chmod 0640 /etc/smartdns/smartdns.conf
```
### 6.4.配置 Dnsmasq
Binary file not shown.

Before

Width:  |  Height:  |  Size: 302 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 362 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 259 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 447 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 328 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 168 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 391 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 343 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 219 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 166 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 187 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 161 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 385 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 240 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 200 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 275 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 318 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 KiB

+3 -4
View File
@@ -53,12 +53,11 @@ 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
server-quic dns.alidns.com -fallback
server-https https://doh.360.cn/dns-query -fallback