Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
68dcf6ab21 | ||
|
|
0a926f1bae | ||
|
|
5ce44529bb | ||
|
|
67378607b3 | ||
|
|
df1b4e8907 | ||
|
|
3989c31582 | ||
|
|
f5d82f7435 | ||
|
|
1794aa74fa | ||
|
|
fce332798e | ||
|
|
4a77288f57 | ||
|
|
4ddcd01688 | ||
|
|
ea2221c54c | ||
|
|
b9473852b9 | ||
|
|
8b8fc3e773 | ||
|
|
d2203618af | ||
|
|
96a23ad48f | ||
|
|
9f6a2fe42d | ||
|
|
55a391f95d | ||
|
|
68ae3b55eb | ||
|
|
edcefa98b3 | ||
|
|
96356ac5d1 | ||
|
|
e0ccdbd5db | ||
|
|
0b4d71977f | ||
|
|
93ffd7b960 | ||
|
|
bf387d1584 | ||
|
|
ae92d79d83 | ||
|
|
44a1ee787c | ||
|
|
578d953950 | ||
|
|
792ce9e9e0 | ||
|
|
df3cf10287 | ||
|
|
63316af2d6 | ||
|
|
77a41c719a | ||
|
|
5efe450d78 | ||
|
|
2131e6ae58 | ||
|
|
aefb7ceb00 | ||
|
|
c6ebb95ed3 | ||
|
|
4aaa101400 | ||
|
|
85c2d70b81 | ||
|
|
ade7a53cad | ||
|
|
c1812b2a45 | ||
|
|
c9aa60ecfd | ||
|
|
d912edeb89 | ||
|
|
115cbb68fc | ||
|
|
9082083465 | ||
|
|
3921329fe2 | ||
|
|
31be875c67 | ||
|
|
626dca3fd9 | ||
|
|
1ad903bf10 | ||
|
|
c7c5270356 | ||
|
|
d4f8fe6b52 | ||
|
|
9013217734 | ||
|
|
9995008d1d | ||
|
|
63c299f206 | ||
|
|
6f19505b83 | ||
|
|
53221483fd | ||
|
|
b0ede429fc | ||
|
|
c1446daf89 | ||
|
|
5b80990bd5 | ||
|
|
117020b8b4 | ||
|
|
d49c98b6df | ||
|
|
264bb156ff | ||
|
|
07efdcb28f | ||
|
|
fb78eec84e | ||
|
|
f5e85ddbc2 | ||
|
|
97ffd13089 | ||
|
|
8f08c4af81 | ||
|
|
1edfd2c06f | ||
|
|
fc27f25f94 | ||
|
|
5f8f9603dc | ||
|
|
c768194983 | ||
|
|
509e328c03 | ||
|
|
1dd2c5ae24 | ||
|
|
ea74679b4a | ||
|
|
8a6bdbe207 | ||
|
|
7c6c92d7ed | ||
|
|
01f00f4bc7 | ||
|
|
6d5693a73a | ||
|
|
a0c8b88bab | ||
|
|
1fe6812f30 | ||
|
|
19f5d89152 | ||
|
|
5e228452ec | ||
|
|
1e52d61178 | ||
|
|
d425c1275b | ||
|
|
b129dd215d | ||
|
|
613c562c1c | ||
|
|
184508f0fd | ||
|
|
2b24267c0c | ||
|
|
b5a44c52b2 | ||
|
|
1606e0c74b | ||
|
|
5293258eb8 | ||
|
|
1c88c7327f | ||
|
|
b3fb776f91 | ||
|
|
c69fedc984 | ||
|
|
1915273f81 | ||
|
|
8a72ccebbe | ||
|
|
4600694a36 | ||
|
|
fad611823f | ||
|
|
f13d108c7b | ||
|
|
cb205dda2f | ||
|
|
d613ea63a1 | ||
|
|
664bf13a20 | ||
|
|
ccd3942725 | ||
|
|
573468ca94 | ||
|
|
2c22ba9212 | ||
|
|
c1c6282713 | ||
|
|
8cca306890 | ||
|
|
6b49519190 | ||
|
|
688d6e0809 | ||
|
|
ad51e789de | ||
|
|
0a7fda4e15 | ||
|
|
100c012314 | ||
|
|
945b25304d | ||
|
|
82066a8a21 | ||
|
|
f8b3bfd75e | ||
|
|
36d4809b37 | ||
|
|
b7e6978342 | ||
|
|
03ee8135c8 | ||
|
|
1ce40c7a36 | ||
|
|
8d2f3e98de | ||
|
|
c3e0205fdf | ||
|
|
a606d3f6e4 | ||
|
|
42e0359d03 | ||
|
|
0377b500b6 | ||
|
|
90c7adc62d | ||
|
|
17c0a3f87d | ||
|
|
3143d46834 | ||
|
|
4dda73f087 | ||
|
|
45bcf699d9 | ||
|
|
d153773b1f | ||
|
|
7d8da1f68e | ||
|
|
641aa555b9 | ||
|
|
34e55b8daa | ||
|
|
777e4bb9d7 | ||
|
|
7dceb23655 | ||
|
|
81c5c3456a | ||
|
|
0731dd1fde | ||
|
|
7e62ab3012 | ||
|
|
14022aebbf | ||
|
|
8738625ad9 | ||
|
|
51a6d0005d | ||
|
|
f3a4231218 | ||
|
|
422384497c | ||
|
|
8c26dd2569 | ||
|
|
ae963404b7 | ||
|
|
96f89812de | ||
|
|
968d0637dd | ||
|
|
1166516576 | ||
|
|
f664975bcc | ||
|
|
26fa0b0c10 | ||
|
|
ac2740f888 | ||
|
|
aa1a12757b | ||
|
|
ccef3195ff | ||
|
|
dd3bda21f5 | ||
|
|
547389c182 | ||
|
|
ace58ce24d | ||
|
|
adaeb4a650 | ||
|
|
fa29b0d633 | ||
|
|
94273ae2b6 | ||
|
|
2d32561415 | ||
|
|
0dcfa86d11 | ||
|
|
557ae16217 | ||
|
|
49083bf184 | ||
|
|
9634a10686 | ||
|
|
6f7c78b749 | ||
|
|
04fc40c8e1 | ||
|
|
05ba8586ae | ||
|
|
e8cb9b14f4 | ||
|
|
7b794c11e4 | ||
|
|
d4673a204a | ||
|
|
95913b4d0d | ||
|
|
964fc699e3 | ||
|
|
b3b147ab37 | ||
|
|
cdcc71462b | ||
|
|
999a06f938 | ||
|
|
4bf1e1d523 | ||
|
|
ddc60fd6f1 | ||
|
|
c94872a931 | ||
|
|
d09bd30a25 | ||
|
|
cc5ec05502 | ||
|
|
e0894f3e13 | ||
|
|
360d5b6cab | ||
|
|
8d2cab7155 | ||
|
|
afb5a5859c | ||
|
|
53c3fe877a | ||
|
|
835cbf9b43 | ||
|
|
1b97935413 | ||
|
|
fc67f6f575 | ||
|
|
bc5ea890ad | ||
|
|
fefcd16f82 | ||
|
|
10050fa7ff | ||
|
|
20086c63f7 | ||
|
|
619b96a6fc | ||
|
|
4fbb729d85 | ||
|
|
78fd87188c | ||
|
|
8a737cfb34 | ||
|
|
fcfd177593 |
@@ -6,15 +6,11 @@ PVE 系统正式安装之前,需要准备 PVE 的安装镜像和一些必要
|
||||
|
||||
PVE 下载地址:[Proxmox Virtual Environment](https://www.proxmox.com/en/downloads/proxmox-virtual-environment/iso)
|
||||
|
||||
页面中有多个 PVE 相关文件,本文以目前最新的 `Proxmox VE 8.2-1 ISO Installer` 作为演示。
|
||||
|
||||
点击 `Proxmox VE 8.x ISO Installer` 链接,进入 PVE 下载页面。
|
||||
|
||||

|
||||
页面中有多个 PVE 相关文件,本文以目前最新的 `Proxmox VE 9.x ISO Installer` 作为演示。
|
||||
|
||||
下载 ISO 时请注意 `SHA256SUM` ,后续将使用该校验信息对下载下来的 ISO 进行校验,以确保 ISO 文件的完整性。
|
||||
|
||||

|
||||

|
||||
|
||||
### 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(安全启动)。
|
||||
|
||||

|
||||
|
||||
@@ -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 进行系统引导。
|
||||
|
||||

|
||||
|
||||
@@ -162,17 +158,17 @@ PVE 为最关键的虚拟化层,建议使用强密码,包含大小写字母
|
||||
|
||||
FQDN 为 PVE 的域,PVE 将使用 FQDN 中的二级域名作为其主机名。
|
||||
|
||||
演示中 FQDN 为 `node01.fox.home.arpa` ,因此 PVE 的主机名为 `node01` 。
|
||||
演示中 FQDN 为 `node01.fox.internal` ,因此 PVE 的主机名为 `node01` 。
|
||||
|
||||
根据规划,PVE 的 IPv4 管理地址为 `172.16.1.254` 。
|
||||
|
||||
未来主路由的 IPv4 地址为 `172.16.1.1` ,因此均使用该地址作为 PVE 的网关地址和 DNS 地址。
|
||||
|
||||
当 PVE 安装完成后, 将使用 PVE 提供的 WEB 管理页面,进一步对该管理口的设置进行调整。
|
||||
PVE 安装完成后,可通过其提供的 Web 管理界面,进一步调整管理口的相关设置。
|
||||
|
||||
|参数|值|说明|
|
||||
|--|--|--|
|
||||
|Hostname (FQDN)|`node01.fox.home.arpa`|设置 PVE `域` 和 `主机名` |
|
||||
|Hostname (FQDN)|`node01.fox.internal`|设置 PVE `域` 和 `主机名` |
|
||||
|IP Address (CIDR)|`172.16.1.254/24`|设置 PVE IPv4 地址|
|
||||
|Gateway|`172.16.1.1`|设置 PVE IPv4 网关|
|
||||
|DNS Server|`172.16.1.1`|设置 PVE IPv4 DNS |
|
||||
@@ -211,7 +207,7 @@ $ cat /etc/fstab
|
||||
$ cat /etc/os-release
|
||||
```
|
||||
|
||||
此处显示出 PVE 底层使用的是 Debian 的系统,代号为 `bookworm` ,该代号后续会使用到。
|
||||
此处显示出 PVE 底层使用的是 Debian 的系统,代号为 `trixie` ,该代号后续会使用到。
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -4,88 +4,96 @@
|
||||
|
||||

|
||||
|
||||
此处显示出 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,30 +102,17 @@ 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
|
||||
```
|
||||
|
||||
创建完成后对其进行检查。
|
||||
|
||||
```bash
|
||||
## 检查 PVE 免费源
|
||||
|
||||
$ cat /etc/apt/sources.list.d/pve-no-subscription.list
|
||||
|
||||
$ cat /etc/apt/sources.list.d/ceph-no-subscription.list
|
||||
$ cat /etc/apt/sources.list.d/*
|
||||
```
|
||||
|
||||
如果输出结果中有 USTC 的镜像地址,则表示命令已经正确执行。
|
||||
|
||||
```bash
|
||||
#### PVE 免费软件源示例输出
|
||||
|
||||
#### PVE
|
||||
deb https://mirrors.ustc.edu.cn/proxmox/debian/pve bookworm pve-no-subscription
|
||||
|
||||
#### Ceph
|
||||
deb https://mirrors.ustc.edu.cn/proxmox/debian/ceph-quincy bookworm no-subscription
|
||||
```
|
||||
如果输出结果中均为 USTC 的镜像地址,则表示命令已经正确执行。
|
||||
|
||||
### 1.3. PVE CT 源
|
||||
|
||||
@@ -126,11 +121,8 @@ deb https://mirrors.ustc.edu.cn/proxmox/debian/ceph-quincy bookworm no-subscript
|
||||
由于该功能暂时未被使用,因此本文只做记录。
|
||||
|
||||
```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
|
||||
@@ -143,7 +135,7 @@ $ pveam update
|
||||
|
||||
更换完成系统源之后,需要同步系统源数据。
|
||||
|
||||
考虑到 **“离线”** 安装时无法同步系统源,因此该步骤可以等到 PVE 正确连接 Internet 后再执行。
|
||||
因 “离线” 安装时无法同步系统源,此步骤可待 PVE 成功连接 Internet 后再执行。
|
||||
|
||||
```bash
|
||||
## 清理软件包
|
||||
@@ -158,49 +150,52 @@ $ 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 unzip neovim tmux unattended-upgrades powermgmt-base
|
||||
|
||||
## 安装网络工具
|
||||
$ apt install iperf iperf3 iftop sshguard openvswitch-switch
|
||||
$ 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
|
||||
|
||||
## 安装网络检测工具(可选)
|
||||
$ apt install iftop iperf3 iperf
|
||||
|
||||
## 根据 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 地址规划如下。
|
||||
|
||||
@@ -210,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 的 WEB 管理后台,打开网络管理页面,此时只有一个 `vmbr0` 。
|
||||
|
||||
该 `vmbr0` 与列表中的第一个物理网口绑定,且在 `CIDR` 和 `网关` 处有 IP 地址参数,说明 `vmbr0` 为当前管理网口。
|
||||
|
||||

|
||||
|
||||
接下来将修改 PVE 网络配置,在修改完成前, **请不要点击 “应用配置”** ,否则会导致 PVE 无法访问。
|
||||
|
||||
在 PVE 内部网络设置完成后,将如图所示。
|
||||
|
||||

|
||||

|
||||
|
||||
### 3.1.修改 vmbr0
|
||||
|
||||
@@ -233,21 +224,17 @@ $ update-pciids
|
||||
|
||||
删除 `IPv4/CIDR` 和 `网关` 信息,确保 `自动启动` 为勾选状态。
|
||||
|
||||
在备注处填写 `wan` ,然后点击 `OK` 按钮。
|
||||
在备注处填写 `wan` ,然后点击 `OK` 。
|
||||
|
||||

|
||||
|
||||
### 3.2.创建网桥
|
||||
|
||||
点击左上角的 `创建` 按钮,选择 `Linux Bridge` :
|
||||
点击左上角的 `创建` 选项,选择 `Linux Bridge` 。
|
||||
|
||||

|
||||
|
||||
因为 `vmbr0` 名称已被使用,因此名称填写 `vmbr1` 。
|
||||
|
||||
桥接端口填写顺序的第二个网卡名称,演示中为 `enp3s0` 。
|
||||
|
||||
确保 `自动启动` 为勾选状态,在备注处填写 `lan1` ,点击 `创建` 按钮。
|
||||
桥接端口填写顺序的第二个网卡名称,演示中为 `nic1` ,在备注处填写 `lan1` ,并点击 `创建` 。
|
||||
|
||||
然后,依次创建所有物理接口的内部网桥,直到最后一个网桥,即 PVE 的管理网口。
|
||||
|
||||
@@ -255,7 +242,7 @@ $ update-pciids
|
||||
|
||||
### 3.3.创建管理网口
|
||||
|
||||
在创建最后一个物理网口的网桥时,需要额外配置 `IPv4` 地址和对应的 `网关` 参数。
|
||||
在创建最后一个物理网口的网桥时,需配置 `IPv4` 地址和对应的 `网关` 参数。
|
||||
|
||||

|
||||
|
||||
@@ -263,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 (链路本地地址)自动配置。
|
||||
|
||||

|
||||
|
||||
在所有物理网口的 PVE 网桥创建完成后,可以点击 `应用配置` 按钮,此时页面会失去连接。
|
||||
所有物理网口的 PVE 网桥创建完成后,点击 `应用配置` ,页面会断开连接。
|
||||
|
||||
无需担心,只需要将电脑的网线从 PVE 物理机的第一个网口拔出,并插入到最后一个网口即可。
|
||||
此时,只需将电脑网线从 PVE 物理机的第一个网口拔出,并插入最后一个网口即可恢复。
|
||||
|
||||
如果万一还是无法访问到 PVE,可以尝试使用网线 “拔插” 方法,挨个测试 PVE 网口的访问情况。
|
||||
若仍无法访问 PVE,可尝试通过网线拔插的方式,逐一测试各 PVE 网口的访问连通性。
|
||||
|
||||
### 3.4.创建内部网桥
|
||||
|
||||
纯内部网桥,在没有内部路由系统提供额外桥接的情况下,无法直接通过物理网口进行访问。
|
||||
纯内部网桥在无其他系统提供额外桥接时,无法直接通过物理网口访问。
|
||||
|
||||
只有在主路由(例如 RouterOS )安装完成并建立了内部网桥后,才可正常使用。
|
||||
|
||||
该纯内部网桥,其主要作用是通过 **主路由** 给内部其他虚拟机提供 **统一** 的网络访问接口。
|
||||
其主要作用是借助其他系统创建的虚拟网桥,为内部虚拟机提供统一的网络访问接口。
|
||||
|
||||
创建纯内部网桥的方法,与创建物理网口网桥的方法基本一致,唯一区别是 `桥接端口` 参数为 **空** 即可。
|
||||
|
||||

|
||||
|
||||
当然,内部网桥的作用不仅如此,比如还可以作为内部级联路由的连接器。
|
||||
在 PVE 内部网络设置完成后,将如图所示。
|
||||
|
||||
例如,安装了 OPNsense 和 RouterOS 两个虚拟机,OPNsense 作为网关防火墙使用。
|
||||
|
||||
此时 RouterOS 作为二级路由系统,OPNsense 的 LAN 口需要与 RouterOS 的 WAN 口相连。
|
||||
|
||||
如果 OPNsense 和 RouterOS 均使用了绑定物理网口的 PVE 网桥,则需用网线在 PVE 服务器上连接两个物理网口。
|
||||
|
||||
浪费了宝贵的网线不说,还占用了网口,得不偿失。
|
||||
|
||||
而纯内部网桥则能很好的解决该问题,有了纯内部网桥,不论多少个虚拟机使用该网桥,只要 IP 地址段相同,即可相互访问。
|
||||

|
||||
|
||||
## 4.配置 PVE DNS
|
||||
|
||||
|
||||
@@ -4,31 +4,31 @@
|
||||
|
||||
在 PVE 系统调整之前,请确认必要的软件包已经安装完成,本文后续命令均在 SSH 终端下执行。
|
||||
|
||||
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 unzip neovim tmux unattended-upgrades powermgmt-base
|
||||
#### 系统默认编辑器示例输出
|
||||
There are 3 choices for the alternative editor (providing /usr/bin/editor).
|
||||
|
||||
## 安装网络工具
|
||||
$ apt install iperf iperf3 iftop sshguard openvswitch-switch
|
||||
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 调度调整工具
|
||||
$ apt install linux-cpupower
|
||||
|
||||
## 根据 CPU 厂商安装 CPU 微码工具
|
||||
$ apt install intel-microcode (amd64-microcode)
|
||||
|
||||
## 更新 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
|
||||
## 修改系统时区
|
||||
@@ -38,7 +38,7 @@ $ timedatectl set-timezone Asia/Shanghai
|
||||
$ date -R
|
||||
|
||||
#### 系统时间示例输出
|
||||
Sun, 25 Jun 2023 12:12:12 +0800
|
||||
Wed, 27 Aug 2025 15:12:21 +0800
|
||||
```
|
||||
|
||||
Debian 系统常用 `systemd-timesyncd.service` 来同步时间,而 PVE 系统使用 `chrony.service` 来同步时间。
|
||||
@@ -47,7 +47,7 @@ Debian 系统常用 `systemd-timesyncd.service` 来同步时间,而 PVE 系统
|
||||
|
||||
```bash
|
||||
## 编辑 chrony 配置文件
|
||||
$ nano /etc/chrony/chrony.conf
|
||||
$ editor /etc/chrony/chrony.conf
|
||||
```
|
||||
|
||||
在编辑器对话框中,将 `pool 2.debian.pool.ntp.org iburst` “注释” 掉,并添加国内的 NTP 服务器。
|
||||
@@ -59,15 +59,16 @@ $ nano /etc/chrony/chrony.conf
|
||||
# pool 2.debian.pool.ntp.org iburst ## 在这行前面增加注释符 # 来注释
|
||||
|
||||
# Use Custom vendor zone.
|
||||
pool ntp.tencent.com iburst
|
||||
pool ntp.aliyun.com iburst
|
||||
pool ntp.tencent.com iburst
|
||||
pool cn.pool.ntp.org iburst
|
||||
|
||||
```
|
||||
|
||||
保存该配置文件后,需重启 `chrony.service` ,并再次检查系统 NTP 服务器地址。
|
||||
|
||||
```bash
|
||||
## 重启 chrony 服务
|
||||
## 重启 chrony.service
|
||||
$ systemctl restart chrony.service
|
||||
|
||||
## 检查系统 NTP 服务器
|
||||
@@ -76,8 +77,12 @@ $ chronyc sources -V
|
||||
#### 系统 NTP 服务器示例输出
|
||||
MS Name/IP address Stratum Poll Reach LastRx Last sample
|
||||
===============================================================================
|
||||
^+ 106.55.184.199 2 6 17 11 +752us[ +273us] +/- 40ms
|
||||
^* 203.107.6.88 2 6 17 11 -1868us[-2348us] +/- 17ms
|
||||
^* 203.107.6.88 2 6 17 0 -875us[-2496us] +/- 22ms
|
||||
^- 106.55.184.199 2 6 17 3 -1331us[-1331us] +/- 50ms
|
||||
^- time.neu.edu.cn 2 6 17 8 +935us[ +935us] +/- 23ms
|
||||
^- 119.28.206.193 2 6 65 5 +33us[ +33us] +/- 65ms
|
||||
^- electrode.felixc.at 2 6 17 11 -1320us[-1320us] +/- 126ms
|
||||
^- dns1.synet.edu.cn 1 6 17 13 -44us[ -44us] +/- 22ms
|
||||
```
|
||||
|
||||
## 2. CPU 调度器
|
||||
@@ -97,15 +102,15 @@ analyzing CPU 0:
|
||||
hardware limits: 800 MHz - 2.70 GHz
|
||||
available cpufreq governors: conservative ondemand userspace powersave performance schedutil
|
||||
current policy: frequency should be within 800 MHz and 2.70 GHz.
|
||||
The governor "ondemand" may decide which speed to use
|
||||
The governor "performance" may decide which speed to use
|
||||
within this range.
|
||||
current CPU frequency: Unable to call hardware
|
||||
current CPU frequency: 800 MHz (asserted by call to kernel)
|
||||
current CPU frequency: 2.60 GHz (asserted by call to kernel)
|
||||
boost state support:
|
||||
Supported: yes
|
||||
Active: yes
|
||||
|
||||
#### 设备 CPU - N6005 示例输出
|
||||
#### 设备 CPU - N100 示例输出
|
||||
analyzing CPU 0:
|
||||
driver: intel_pstate
|
||||
CPUs which run at the same hardware frequency: 0
|
||||
@@ -125,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 示例输出
|
||||
ondemand
|
||||
|
||||
#### 设备 CPU - N6005 示例输出
|
||||
performance
|
||||
```
|
||||
- `governor` :调频策略中使用的调度器,例如 `performance`
|
||||
|
||||
CPU 驱动一般不建议手动调整,而 `governor` 后面的参数表示 CPU 当前调度器设置。
|
||||
|
||||
@@ -153,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
|
||||
```
|
||||
|
||||
@@ -163,14 +155,14 @@ performance powersave
|
||||
|
||||
- CPU 驱动为 `intel_pstate` 时,推荐使用 `powersave` 调度器。
|
||||
|
||||
本文使用 `powersave` 调度器为演示,使用 `nano` 编辑器创建 `cpupower` 的配置文件。
|
||||
本文使用 `powersave` 调度器创建 `cpupower` 的配置文件。
|
||||
|
||||
```bash
|
||||
## 创建 cpupower 配置文件
|
||||
$ nano /etc/default/cpupower
|
||||
## 创建 cpupower 默认配置文件
|
||||
$ editor /etc/default/cpupower
|
||||
```
|
||||
|
||||
在配置文件中修改以下配置项,并保存。
|
||||
在配置文件中输入以下内容,并保存。
|
||||
|
||||
```bash
|
||||
# This configuration file is customized by fox,
|
||||
@@ -181,14 +173,14 @@ CPUPOWER_STOP_OPTS="frequency-set -g performance"
|
||||
|
||||
```
|
||||
|
||||
使用 `nano` 编辑器创建 `cpupower` 服务配置文件,以满足系统自动化设置需求。
|
||||
进一步创建 `cpupower` 服务配置文件,以满足系统自动化设置需求。
|
||||
|
||||
```bash
|
||||
## 创建 cpupower 服务配置文件
|
||||
$ nano /etc/systemd/system/cpupower.service
|
||||
## 创建 cpupower.service 配置文件
|
||||
$ editor /etc/systemd/system/cpupower.service
|
||||
```
|
||||
|
||||
在服务配置文件中修改以下配置项,并保存。
|
||||
在服务配置文件中输入以下内容,并保存。
|
||||
|
||||
```bash
|
||||
# This configuration file is customized by fox,
|
||||
@@ -251,7 +243,7 @@ $ crontab -l
|
||||
$ crontab -e
|
||||
```
|
||||
|
||||
在配置文件末尾,增加以下配置项。
|
||||
在配置文件末尾,增加以下内容。
|
||||
|
||||
```bash
|
||||
## 定时任务配置项
|
||||
@@ -274,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 Tue 2023-08-01 13:01:19 CST; 27min ago
|
||||
Trigger: Wed 2023-08-02 06:14:50 CST; 16h 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
|
||||
|
||||
Aug 01 13:01:19 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.配置更新策略
|
||||
@@ -292,10 +285,8 @@ Aug 01 13:01:19 node01 systemd[1]: Started apt-daily-upgrade.timer - Daily apt u
|
||||
## 配置自动更新策略
|
||||
$ dpkg-reconfigure -plow unattended-upgrades
|
||||
|
||||
## 选择 “是” (“YES”)
|
||||
|
||||
#### 系统自动更新示例输出
|
||||
Creating config file /etc/apt/apt.conf.d/20auto-upgrades with new version
|
||||
## 选择 “是”
|
||||
<Yes>
|
||||
```
|
||||
|
||||
进一步调整 `20auto-upgrades` 配置文件。
|
||||
@@ -305,10 +296,10 @@ Creating config file /etc/apt/apt.conf.d/20auto-upgrades with new version
|
||||
$ cd /etc/apt/apt.conf.d
|
||||
|
||||
## 编辑 20auto-upgrades 配置文件
|
||||
$ nano /etc/apt/apt.conf.d/20auto-upgrades
|
||||
$ editor /etc/apt/apt.conf.d/20auto-upgrades
|
||||
```
|
||||
|
||||
删除里面全部内容,添加以下配置项,并保存。
|
||||
清空当前全部配置项后,输入以下内容,并保存。
|
||||
|
||||
配置文件中,用来控制更新周期的参数为 `APT::Periodic::Unattended-Upgrade` ,`5` 表示更新周期为 `5` 天。
|
||||
|
||||
@@ -326,12 +317,12 @@ APT::Periodic::CleanInterval "1";
|
||||
|
||||
```bash
|
||||
## 编辑 50unattended-upgrades 配置文件
|
||||
$ nano /etc/apt/apt.conf.d/50unattended-upgrades
|
||||
$ editor /etc/apt/apt.conf.d/50unattended-upgrades
|
||||
```
|
||||
|
||||
配置文件中,被修改的参数解释如下:
|
||||
|
||||
- 启用了 Debian `bookworm-updates` 相关更新。
|
||||
- 启用了 Debian `trixie-updates` 相关更新。
|
||||
|
||||
- 增加并启用 PVE 自有仓库的更新。
|
||||
|
||||
@@ -362,9 +353,9 @@ $ nano /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";
|
||||
|
||||
@@ -391,7 +382,7 @@ Unattended-Upgrade::Automatic-Reboot-Time "02:30";
|
||||
$ systemctl edit apt-daily-upgrade.timer
|
||||
```
|
||||
|
||||
根据配置文件中的提示,在中间空白处填入以下配置项。
|
||||
根据配置文件中的提示,在中间空白处填入以下内容。
|
||||
|
||||
```bash
|
||||
## 定时器配置项
|
||||
@@ -414,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 Tue 2023-08-01 13:37:41 CST; 9s ago
|
||||
Trigger: Wed 2023-08-02 01:30:00 CST; 11h 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
|
||||
|
||||
Aug 01 13:37:41 node01 systemd[1]: Stopped apt-daily-upgrade.timer - Daily apt upgrade and clean activities.
|
||||
Aug 01 13:37:41 node01 systemd[1]: Stopping apt-daily-upgrade.timer - Daily apt upgrade and clean activities...
|
||||
Aug 01 13:37:41 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.硬件直通
|
||||
@@ -436,7 +427,7 @@ Aug 01 13:37:41 node01 systemd[1]: Started apt-daily-upgrade.timer - Daily apt u
|
||||
|
||||
```bash
|
||||
## 编辑 Grub 配置文件
|
||||
$ nano /etc/default/grub
|
||||
$ editor /etc/default/grub
|
||||
```
|
||||
|
||||
在编辑器对话框中修改 `GRUB_CMDLINE_LINUX_DEFAULT` 参数,注意命令中间的空格。
|
||||
@@ -466,17 +457,18 @@ $ update-grub
|
||||
|
||||
### 5.2.添加内核模块
|
||||
|
||||
修改系统 `/etc/modules` 配置文件,增加必要的系统模块。
|
||||
编辑 **内核模块** 配置文件,增加必要的系统模块,执行以下命令。
|
||||
|
||||
```bash
|
||||
## 编辑系统配置文件
|
||||
$ nano /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
|
||||
@@ -501,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` 分组,执行以下命令。
|
||||
@@ -539,33 +521,90 @@ $ 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.系统清理
|
||||
## 6. BTRFS 调整
|
||||
|
||||
**额外说明:**
|
||||
|
||||
1. 本节专为 `BTRFS` 单盘 `RAID0`(条带模式)安装的 PVE 系统设计,使用其他安装模式时,请跳过此节。
|
||||
|
||||
2. `BTRFS` 文件系统当前仍为技术预览状态,请谨慎操作。
|
||||
|
||||
3. 有关在 PVE 中使用 `BTRFS` 的详情,请参阅 [Proxmox VE - BTRFS](https://pve.proxmox.com/wiki/BTRFS) 。
|
||||
|
||||
安装 PVE 时,若使用了 `BTRFS` 单盘 `RAID0` 的安装模式,系统默认未启用 swap 和 zstd 压缩,需要手动开启。
|
||||
|
||||
通常情况下,内存与 swap 的 **推荐** 比例为 `1:1` 。本机具有 `16GB` 内存,因此设置 `16GB` swap 空间。
|
||||
|
||||
执行以下命令,在 `BTRFS` 文件系统中创建子卷,并配置激活 swapfile 。
|
||||
|
||||
```bash
|
||||
## 创建用于存放交换文件的子卷
|
||||
$ btrfs subvolume create /swap
|
||||
|
||||
## 在子卷中创建 16GB 的交换文件
|
||||
$ btrfs filesystem mkswapfile --size 16g --uuid clear /swap/swapfile
|
||||
|
||||
## 激活交换文件
|
||||
$ swapon /swap/swapfile
|
||||
```
|
||||
|
||||
此时还需进一步修改系统的 `fstab` 配置文件,以启用 `BTRFS` 的 zstd 压缩功能并确保 swap 在系统启动时自动激活。
|
||||
|
||||
```bash
|
||||
## 编辑 fstab 配置文件
|
||||
$ editor /etc/fstab
|
||||
```
|
||||
|
||||
`fstab` 为系统关键配置文件,直接影响系统启动,修改此文件时,请注意以下几点:
|
||||
|
||||
- 仅修改根目录 `/` 对应的挂载选项,添加 `compress=zstd` 参数。
|
||||
|
||||
- 在文件末尾新增一行,添加 swap 的自动挂载。
|
||||
|
||||
- 请 **不要** 修改其余配置参数,尤其是设备的唯一标识符( `UUID` ),切勿修改。
|
||||
|
||||
修改完成后,示例如下。
|
||||
|
||||
```bash
|
||||
#### 系统 fstab 示例配置
|
||||
|
||||
# <file system> <mount point> <type> <options> <dump> <pass>
|
||||
|
||||
UUID=<DO-NOT-EDIT-YOUR-UUID> / btrfs defaults,compress=zstd 0 1
|
||||
|
||||
UUID=<YOUR-UUID> /boot/efi vfat defaults 0 1
|
||||
proc /proc proc defaults 0 0
|
||||
|
||||
/swap/swapfile none swap defaults 0 0
|
||||
```
|
||||
|
||||
## 7.系统清理
|
||||
|
||||
PVE 系统配置完成后,可执行以下命令,对系统进行清理。
|
||||
|
||||
@@ -574,10 +613,10 @@ PVE 系统配置完成后,可执行以下命令,对系统进行清理。
|
||||
$ apt clean && apt autoclean && apt autoremove --purge
|
||||
|
||||
## 清理系统缓存
|
||||
$ rm -rvf /var/cache/apt/* /var/lib/apt/lists/* /tmp/*
|
||||
$ bash -c 'find /var/cache/apt/ /var/lib/apt/lists/ /tmp/ -type f -print -delete'
|
||||
|
||||
## 清理系统日志
|
||||
$ find /var/log/ -type f | xargs rm -rvf
|
||||
$ bash -c 'find /var/log/ -type f -print -delete'
|
||||
|
||||
## 清理命令历史记录文件
|
||||
$ rm -rvf ~/.bash_history && history -c
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
|
||||
该虚拟机模板主要用作内网 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` 云镜像以及对应的校验文件。
|
||||
|
||||

|
||||

|
||||
|
||||
## 1.创建虚拟机
|
||||
|
||||
@@ -30,13 +30,15 @@
|
||||
|
||||
SCSI 控制器保持默认 `VirtIO SCSI single` ,机型可选 `q35` ,并勾选 `Qemu代理` 选项。
|
||||
|
||||
固件可选 `OVMF (UEFI)` ,并勾选 `添加 TPM` 选项,存储路径需根据实际情况进行调整,演示为 `local-lvm` 。
|
||||
|
||||
`预注册密钥` 可启用,启用后将预装特定于发行版和 Microsoft 标准的安全启动密钥。
|
||||
|
||||

|
||||
|
||||
### 1.4.磁盘
|
||||
|
||||
一般情况下,如果该虚拟机仅为 Adguard Home 服务器,`20G` 磁盘空间足够使用。
|
||||
|
||||
由于使用 Debian 云镜像制作虚拟机模板,此处删除所有 `磁盘` 。
|
||||
因使用 Debian 云镜像制作虚拟机模板,此处需删除所有 `磁盘` 。
|
||||
|
||||

|
||||
|
||||
@@ -52,21 +54,19 @@ CPU `类别` 选择 `host` ,`插槽` 与 `核心` 数根据物理 CPU 核心
|
||||
|
||||
内存一般 `2G` 足够使用,取消勾选 `Ballooning设备` 。
|
||||
|
||||
对于 `Kernel Samepage Merging (KSM)` 内核同页合并功能,建议保留勾选状态。
|
||||
|
||||

|
||||
|
||||
### 1.7.网络
|
||||
|
||||
在 [02.PVE初始化配置](./02.PVE初始化配置.md) 中,曾创建了一个没有桥接任何物理网口的内部网桥。
|
||||
通常情况下,模板虚拟机的 `桥接` 参数设为 PVE 管理口所在虚拟网桥即可。
|
||||
|
||||
该内部网桥接口同属于主路由内部网桥成员接口。
|
||||
|
||||
因此,模板虚拟机的 `桥接` 参数可设置为该纯内部网桥。
|
||||
因在 [02.PVE初始化配置](./02.PVE初始化配置.md) 中曾创建未桥接物理网口的内部网桥,故可根据实际需求选择是否使用纯内部网桥作为该参数值。
|
||||
|
||||

|
||||
|
||||
由于演示环境中暂未安装主路由系统,因此选择其他网桥接口替代。
|
||||
|
||||
通常情况下无需使用 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,47 +116,76 @@ $ 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
|
||||
|
||||
#### 镜像导入示例输出
|
||||
Successfully imported disk as 'unused0:local-lvm:vm-1001-disk-0'
|
||||
unused0: successfully imported disk 'local-lvm:vm-1001-disk-2'
|
||||
```
|
||||
|
||||
磁盘导入成功后,虚拟机硬件列表中将显示一块未使用的磁盘设备,可鼠标 **双击** 该设备进行配置调整。
|
||||
|
||||

|
||||
|
||||
鼠标 **双击** 该未使用的磁盘,点击 `添加` 。
|
||||
当宿主机使用 SSD 作为物理存储设备,并且虚拟磁盘采用 Thin Provisioning (精简置备)模式时,可考虑开启以下选项:
|
||||
|
||||
- `Discard` ( `丢弃` ) 选项,有助于存储空间回收。
|
||||
|
||||
- `SSD Emulation` ( `SSD 仿真` ) 选项,让虚拟机将虚拟磁盘视为 SSD 存储设备。
|
||||
|
||||
在弹出的对话框中,确认 `IO thread` 选项为 **勾选** 状态,并点击 `添加` 。
|
||||
|
||||

|
||||
|
||||
导入的镜像只有 `2G` 磁盘空间,为了后续方便使用,需要对磁盘进行扩容。
|
||||
导入的镜像仅具备 `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.
|
||||
```
|
||||
|
||||
或鼠标 **单击** 选中该磁盘,选择页面顶部 `磁盘操作` 菜单的子菜单 `调整大小` 。
|
||||
|
||||

|
||||
|
||||
在弹出的对话框中,给该磁盘增加 `18G` 磁盘空间。
|
||||
在弹出的对话框中,给该磁盘增加 `21G` 磁盘空间。
|
||||
|
||||

|
||||

|
||||
|
||||
### 2.3.添加 CloudInit
|
||||
|
||||
为了能够正常使用 Cloud-Init 初始化系统,需要给模板虚拟机添加 `CloudInit设备` 。
|
||||
为确保 Cloud-Init 能正常初始化系统,需为模板虚拟机添加 `CloudInit 设备` 。
|
||||
|
||||
点击顶部 `添加` 菜单,选择 `CloudInit设备` 。
|
||||
点击顶部 `添加` 菜单,选择 `CloudInit 设备` 。
|
||||
|
||||

|
||||
|
||||
`总线/设备` 选择 `SCSI` ,编号为 `1` ,`存储` 选择 `local-lvm` 。
|
||||
`总线/设备` 选择 `SCSI` ,编号为 `1` ,存储路径需根据实际情况进行调整,演示为 `local-lvm` 。
|
||||
|
||||

|
||||
|
||||
### 2.4.添加 VirtIO RNG
|
||||
|
||||
为确保系统拥有充足的可用熵,需为模板虚拟机添加 `VirtIO RNG` 熵源。
|
||||
|
||||
点击顶部 `添加` 菜单,选择 `VirtIO RNG` 。
|
||||
|
||||

|
||||
|
||||
`熵源` 选择 `/dev/urandom` ,其余参数保持默认即可。
|
||||
|
||||

|
||||
|
||||
虚拟机硬件设备修改完成后,如下图所示。
|
||||
|
||||

|
||||
@@ -179,9 +208,7 @@ Successfully imported disk as 'unused0:local-lvm:vm-1001-disk-0'
|
||||
|
||||
鼠标 **双击** `引导顺序` 选项,进入编辑界面。
|
||||
|
||||
在 `scsi0` 设备处,勾选前面的 “已启用” 复选框,并使用行首的排序功能,将该设备拖拽到第一个。
|
||||
|
||||
然后点击 `OK` 按钮。
|
||||
在 `scsi0` 设备处勾选 “已启用” 复选框,并通过排序功能将其拖拽至首位,点击 `OK` 即可。
|
||||
|
||||

|
||||
|
||||
@@ -203,11 +230,11 @@ Successfully imported disk as 'unused0:local-lvm:vm-1001-disk-0'
|
||||
|--|--|--|
|
||||
|用户|`fox`|新系统的管理员账户|
|
||||
|密码|`********`|使用强密码|
|
||||
|DNS域|`fox.home.arpa`|内网域名(可选)|
|
||||
|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 设置|
|
||||
|
||||
**额外说明:**
|
||||
|
||||
@@ -219,7 +246,7 @@ Successfully imported disk as 'unused0:local-lvm:vm-1001-disk-0'
|
||||
|
||||

|
||||
|
||||
`Cloud-Init` 的 `IP配置` ,IPv4 使用静态地址,IPv6 使用 `SLAAC` 自动配置,如下图所示。
|
||||
`Cloud-Init` 的 `IP 配置` ,IPv4 使用 `静态` 地址,IPv6 使用 `SLAAC` 自动配置,如下图所示。
|
||||
|
||||

|
||||
|
||||
@@ -227,21 +254,21 @@ Successfully imported disk as 'unused0: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 配置` 参数调整如下。
|
||||
|
||||
|参数|值|说明|
|
||||
|--|--|--|
|
||||
|DNS域|`fox.home.arpa`|内网域名(可选)|
|
||||
|DNS域|`fox.internal`|内网域名(可选)|
|
||||
|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 地址。
|
||||
|
||||

|
||||
|
||||
`IP配置` 参数,IPv4 使用静态地址,IPv6 同样使用静态地址,如下图所示。
|
||||
`IP 配置` 参数,IPv4 使用 `静态` 地址,IPv6 同样使用 `静态` 地址,如下图所示。
|
||||
|
||||
IPv6 使用静态地址后,并不影响虚拟机通过主路由获取公网 GUA IPv6 地址。
|
||||
IPv6 使用 `静态` 地址后,并不影响虚拟机通过主路由获取 IPv6 GUA 公网地址。
|
||||
|
||||

|
||||
|
||||
@@ -252,7 +279,7 @@ IPv6 使用静态地址后,并不影响虚拟机通过主路由获取公网 GU
|
||||
```bash
|
||||
### 服务器信息
|
||||
|
||||
- 系统: Debian12
|
||||
- 系统: Debian 13
|
||||
|
||||
- 用途: 内网 DNS 服务器 ( 模板 )
|
||||
|
||||
|
||||
@@ -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` 服务意外修改软件源配置,需要添加文件保护,执行以下命令。
|
||||
@@ -142,7 +90,7 @@ $ lsattr /etc/apt/sources.list.d/debian.sources
|
||||
|
||||
```bash
|
||||
## 清理不必要的包
|
||||
$ sudo apt clean && sudo apt autoclean && sudo apt autoremove --purge
|
||||
$ sudo bash -c 'apt clean && apt autoclean && apt autoremove --purge'
|
||||
|
||||
## 更新软件源
|
||||
$ sudo apt update
|
||||
@@ -155,30 +103,79 @@ $ sudo apt full-upgrade
|
||||
|
||||
```bash
|
||||
## 安装系统软件
|
||||
$ sudo apt install qemu-guest-agent zsh git btop tmux cron nftables sshguard neovim
|
||||
$ 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 iperf iperf3 iftop lsof knot-dnsutils
|
||||
$ sudo apt install nftables sshguard lsof knot-dnsutils
|
||||
|
||||
## 安装网络检测工具(可选)
|
||||
$ sudo apt install iftop iperf3 iperf
|
||||
|
||||
## 刷新 systemd 日志分类索引
|
||||
$ sudo journalctl --update-catalog
|
||||
|
||||
## 写入磁盘
|
||||
$ sudo sync
|
||||
```
|
||||
|
||||
### 1.4.调整内核参数
|
||||
### 1.4.配置 ZSH
|
||||
|
||||
由于该 Debian 虚拟机模板将用于克隆内网 DNS 服务器,因此需要调整内核参数来简单优化性能。
|
||||
`Zsh` 是比 `Bash` 好用的 `Shell` 程序,使用 `oh-my-zsh` 进行配置。
|
||||
|
||||
使用 `neovim` 编辑器编辑 **内核参数** 配置文件,执行以下命令。
|
||||
```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
|
||||
|
||||
## 询问是否切换默认 shell,输入 Y
|
||||
|
||||
#### 示例输出
|
||||
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
|
||||
```
|
||||
|
||||
### 1.5.配置默认编辑器
|
||||
|
||||
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.调整内核参数
|
||||
|
||||
由于该虚拟机将作为内网 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,
|
||||
@@ -188,21 +185,24 @@ kernel.panic = 20
|
||||
kernel.panic_on_oops = 1
|
||||
|
||||
net.core.default_qdisc = fq_codel
|
||||
net.ipv4.tcp_congestion_control = bbr
|
||||
|
||||
# Other adjustable system parameters
|
||||
|
||||
net.core.netdev_budget = 600
|
||||
net.core.netdev_budget_usecs = 20000
|
||||
net.core.netdev_max_backlog = 4096
|
||||
|
||||
net.ipv4.conf.all.log_martians = 1
|
||||
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_syncookies = 1
|
||||
net.ipv4.tcp_keepalive_time = 600
|
||||
net.ipv4.tcp_max_syn_backlog = 4096
|
||||
net.ipv4.tcp_notsent_lowat = 131072
|
||||
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
|
||||
@@ -213,10 +213,10 @@ net.ipv6.conf.default.use_tempaddr = 0
|
||||
|
||||
```bash
|
||||
## 让内核参数生效
|
||||
$ sudo sysctl -f
|
||||
$ sudo sysctl --system
|
||||
```
|
||||
|
||||
### 1.5.调整系统时间
|
||||
### 1.7.调整系统时间
|
||||
|
||||
默认情况下 Debian 云镜像的系统时间需要调整,执行以下命令将系统时区设置为中国时区。
|
||||
|
||||
@@ -228,7 +228,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 服务器。
|
||||
@@ -236,28 +236,28 @@ Debian 云镜像默认使用 `systemd-timesyncd.service` 同步时间,且需
|
||||
调整 NTP 服务器参数,执行以下命令。
|
||||
|
||||
```bash
|
||||
## 创建 NTP 配置文件的目录
|
||||
## 创建 NTP 配置目录
|
||||
$ 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,
|
||||
# Optimize system NTP server.
|
||||
|
||||
[Time]
|
||||
NTP=ntp.tencent.com ntp.aliyun.com
|
||||
NTP=ntp.aliyun.com ntp.tencent.com cn.pool.ntp.org
|
||||
|
||||
```
|
||||
|
||||
保存该配置文件后,需重启 `systemd-timesyncd.service` 服务,并再次检查系统 NTP 服务器地址。
|
||||
|
||||
```bash
|
||||
## 重启 chrony 服务
|
||||
## 重启 systemd-timesyncd.service
|
||||
$ sudo systemctl restart systemd-timesyncd.service
|
||||
|
||||
## 检查系统 NTP 服务器
|
||||
@@ -269,24 +269,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 2023-06-26 16:16:00 CST; 16s 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: 18829 (systemd-timesyn)
|
||||
Status: "Contacted time server 106.55.184.199:123 (ntp.tencent.com)."
|
||||
Tasks: 2 (limit: 2355)
|
||||
Memory: 1.4M
|
||||
CPU: 37ms
|
||||
Main PID: 4540 (systemd-timesyn)
|
||||
Status: "Contacted time server 203.107.6.88:123 (ntp.aliyun.com)."
|
||||
Tasks: 2 (limit: 2317)
|
||||
Memory: 1.5M (peak: 2.2M)
|
||||
CPU: 261ms
|
||||
CGroup: /system.slice/systemd-timesyncd.service
|
||||
└─18829 /lib/systemd/systemd-timesyncd
|
||||
└─4540 /usr/lib/systemd/systemd-timesyncd
|
||||
|
||||
Jun 26 16:48:00 DNST01 systemd[1]: Starting systemd-timesyncd.service - Network Time Synchronization...
|
||||
Jun 26 16:48:00 DNST01 systemd[1]: Started systemd-timesyncd.service - Network Time Synchronization.
|
||||
Jun 26 16:48:00 DNST01 systemd-timesyncd[18829]: Contacted time server 106.55.184.199:123 (ntp.tencent.com).
|
||||
Jun 26 16:48:00 DNST01 systemd-timesyncd[18829]: Initial clock synchronization to Mon 2023-06-26 16:16:16.000000 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.6.配置自动更新
|
||||
### 1.8.配置自动更新
|
||||
|
||||
配置 Debian 云镜像的系统自动更新,与配置 PVE 系统自动更新方法基本一致,参阅 [03.PVE系统调整](./03.PVE系统调整.md) 。
|
||||
|
||||
@@ -303,20 +304,18 @@ $ sudo systemctl status apt-daily-upgrade.timer
|
||||
## 配置自动更新策略
|
||||
$ sudo dpkg-reconfigure -plow unattended-upgrades
|
||||
|
||||
## 选择 “是” (“YES”)
|
||||
|
||||
#### 系统自动更新示例输出
|
||||
Creating config file /etc/apt/apt.conf.d/20auto-upgrades with new version
|
||||
## 选择 “是”
|
||||
<Yes>
|
||||
```
|
||||
|
||||
进一步调整 `20auto-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` 天。
|
||||
|
||||
@@ -334,11 +333,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
|
||||
@@ -346,7 +343,7 @@ $ sudo nvim /etc/apt/apt.conf.d/50unattended-upgrades
|
||||
|
||||
"origin=Debian,codename=${distro_codename}-updates";
|
||||
|
||||
## 在配置文件末尾增加以下配置项,代表启用,并调整参数
|
||||
## 在配置文件末尾增加以下内容,代表启用,并调整参数
|
||||
|
||||
Unattended-Upgrade::AutoFixInterruptedDpkg "true";
|
||||
|
||||
@@ -362,14 +359,14 @@ Unattended-Upgrade::Automatic-Reboot-Time "03:00";
|
||||
|
||||
```
|
||||
|
||||
系统自动更新配置文件修改完成后,需要重设自动更新定时器,执行以下命令。
|
||||
系统自动更新配置文件修改完成后,需调整自动更新定时器,执行以下命令。
|
||||
|
||||
```bash
|
||||
## 配置系统定时器
|
||||
$ sudo systemctl edit apt-daily-upgrade.timer
|
||||
```
|
||||
|
||||
根据配置文件中的提示,在中间空白处填入以下配置项。
|
||||
根据配置文件中的提示,在中间空白处填入以下内容。
|
||||
|
||||
```bash
|
||||
## 定时器配置项
|
||||
@@ -393,7 +390,7 @@ $ sudo systemctl restart apt-daily-upgrade.timer
|
||||
$ sudo systemctl status apt-daily-upgrade.timer
|
||||
```
|
||||
|
||||
### 1.7.配置定时任务
|
||||
### 1.9.配置定时任务
|
||||
|
||||
本步骤为可选操作,主要设置系统定时重启。
|
||||
|
||||
@@ -405,7 +402,7 @@ $ sudo crontab -l
|
||||
$ sudo crontab -e
|
||||
```
|
||||
|
||||
在配置文件末尾,增加以下配置项。
|
||||
在配置文件末尾,增加以下内容。
|
||||
|
||||
```bash
|
||||
## 定时任务配置项
|
||||
@@ -414,40 +411,22 @@ $ sudo crontab -e
|
||||
|
||||
```
|
||||
|
||||
### 1.8.配置 ZSH
|
||||
|
||||
`Zsh` 是比 `Bash` 好用的 `Shell` 程序,使用 `oh-my-zsh` 进行配置。
|
||||
|
||||
```bash
|
||||
## 返回 home 目录
|
||||
$ cd
|
||||
|
||||
## 使用 curl 安装 oh-my-zsh
|
||||
$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
|
||||
|
||||
## 或者使用 wget 安装 oh-my-zsh
|
||||
$ sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
|
||||
|
||||
## 询问是否切换默认 shell,输入 Y
|
||||
|
||||
#### 示例输出
|
||||
Time to change your default shell to zsh:
|
||||
Do you want to change your default shell to zsh? [Y/n] y
|
||||
```
|
||||
|
||||
### 1.9.清理系统
|
||||
### 1.10.清理系统
|
||||
|
||||
Debian 模板虚拟机已经配置完成,在将其转换为模板前需要对系统进行清理。
|
||||
|
||||
```bash
|
||||
## 清理系统软件包
|
||||
$ sudo apt clean && sudo apt autoclean && sudo apt autoremove --purge
|
||||
$ sudo bash -c 'apt clean && apt autoclean && apt autoremove --purge'
|
||||
|
||||
## 清理系统缓存
|
||||
$ sudo rm -rvf /var/cache/apt/* /var/lib/apt/lists/* /tmp/*
|
||||
$ 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 find /var/log/ -type f | xargs sudo rm -rvf
|
||||
$ sudo bash -c 'find /var/log/ -type f -print -delete'
|
||||
|
||||
## 清理命令历史记录文件
|
||||
$ rm -rvf ~/.bash_history ~/.zsh_history ~/.zcompdump* && history -c
|
||||
@@ -458,13 +437,13 @@ $ sudo shutdown now
|
||||
|
||||
## 2.虚拟机转为模板
|
||||
|
||||
在 Debian 模板虚拟机关机后,进入 PVE 的 WEB 管理界面。
|
||||
在模板虚拟机关机后,进入 PVE 的 WEB 管理界面。
|
||||
|
||||
在左侧虚拟机列表中,鼠标 **右键单击** Debian 模板虚拟机,在弹出的菜单中选择 `转换成模板` 。
|
||||
在左侧虚拟机列表中,鼠标 **右键单击** 模板虚拟机,在弹出的菜单中选择 `转换成模板` 。
|
||||
|
||||
需要说明的是,虚拟机 `转换成模板` 的操作是不可逆的。
|
||||
需要说明的是,虚拟机 `转换成模板` 的操作具有不可逆性。
|
||||
|
||||
如果某些 Debian 系统的配置项有问题,只能在用该模板克隆出来的新虚拟机中进行修改,或者删除并重新制作模板。
|
||||
若系统配置存在问题,仅能在该模板克隆的新虚拟机中修改,或删除现有模板并重新制作。
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
在上一篇文章 [05.PVE制作虚拟机模板](./05.PVE制作虚拟机模板.md) 中,已经制作好了虚拟机模板。
|
||||
|
||||
接下来将使用该模板克隆出新的虚拟机,并安装 Adguard Home 作为内网的 DNS 服务器。
|
||||
接下来将基于该模板克隆新虚拟机,并通过安装 DNS 服务器软件,完成内网 DNS 服务器的搭建。
|
||||
|
||||
鼠标 **右键单击** 虚拟机模板,在弹出的菜单中选择 `克隆` 。
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
|
||||
`启动/关机顺序` 为 `2` ,表示该虚拟机第 `2` 个启动,倒数第 `2` 个关机。
|
||||
|
||||
`启动延时` 为 `10` ,表示该虚拟机在 PVE 启动后,延迟 `10` 秒后自动启动。
|
||||
`启动延时` 为 `15` ,表示该虚拟机启动后,延迟 `15` 秒再启动下一个虚拟机。
|
||||
|
||||

|
||||
|
||||
@@ -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,10 +216,10 @@ $ mkdir -p /tmp/SmartDNS
|
||||
$ cd /tmp/SmartDNS
|
||||
|
||||
## 下载 SmartDNS 安装包
|
||||
$ curl -LR -O https://github.com/pymumu/smartdns/releases/download/Release46/smartdns.1.2024.06.12-2222.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.1.2024.06.12-2222.x86_64-linux-all.tar.gz
|
||||
$ tar zxf smartdns.*.x86_64-linux-all.tar.gz
|
||||
|
||||
## 进入安装包目录
|
||||
$ cd smartdns
|
||||
@@ -231,6 +231,13 @@ $ chmod +x ./install
|
||||
$ sudo ./install -i
|
||||
```
|
||||
|
||||
后续 `SmartDNS` 推出新版本需原位升级时:先下载最新版本,再将以下命令替代原安装命令执行,升级后现有配置不会丢失。
|
||||
|
||||
```bash
|
||||
## 升级 SmartDNS
|
||||
$ sudo ./install -U
|
||||
```
|
||||
|
||||
修改 `SmartDNS` 配置之前,需检查 `smartdns.service` 服务状态,确保该服务开机自启。
|
||||
|
||||
```bash
|
||||
@@ -248,7 +255,7 @@ $ sudo systemctl enable smartdns.service
|
||||
若需使用 `SmartDNS` 屏蔽广告,则需下载广告规则配置文件。
|
||||
|
||||
```bash
|
||||
## 创建 SmartDNS 配置文件目录
|
||||
## 创建 SmartDNS 配置目录
|
||||
$ sudo mkdir -p /etc/smartdns.d
|
||||
|
||||
## 下载广告规则配置文件
|
||||
@@ -261,117 +268,19 @@ $ 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. SmartDNS 主配置
|
||||
|
||||
`SmartDNS` 配置较为复杂,可按需制定各类 DNS 请求规则,建议先查阅官方提供的 [配置指导](https://pymumu.github.io/smartdns/config/basic-config/) 和 [配置选项](https://pymumu.github.io/smartdns/configuration/) 。
|
||||
|
||||
修改 `SmartDNS` 主配置文件之前,建议关闭 `SmartDNS` 并清理 DNS 缓存文件。
|
||||
|
||||
```bash
|
||||
## 关闭 smartdns.service
|
||||
$ sudo systemctl stop smartdns.service
|
||||
|
||||
## 清理缓存
|
||||
$ sudo rm -rvf /var/cache/smartdns
|
||||
|
||||
## 清理进程标识文件
|
||||
$ sudo rm -rvf /var/run/smartdns.pid /run/smartdns.pid
|
||||
```
|
||||
|
||||
`SmartDNS` 的主配置文件一般位于 `/etc/smartdns` 目录下,修改配置文件之前,执行以下命令将其备份。
|
||||
|
||||
```bash
|
||||
## 备份 SmartDNS 主配置文件
|
||||
$ sudo mv /etc/smartdns/smartdns.conf /etc/smartdns/smartdns.conf.bak
|
||||
```
|
||||
|
||||
使用 `neovim` 编辑器创建 `SmartDNS` 主配置文件,执行以下命令。
|
||||
|
||||
```bash
|
||||
## 创建 SmartDNS 主配置文件
|
||||
$ sudo nvim /etc/smartdns/smartdns.conf
|
||||
```
|
||||
|
||||
在编辑器对话框中输入以下内容,并保存。
|
||||
|
||||
**额外说明:**
|
||||
|
||||
- 由于修改了缓存路径,`SmartDNS` 的缓存将在系统重启时自动删除,请根据实际情况进行调整
|
||||
|
||||
- `SmartDNS` 端口监听参数为 `6053@lo` ,请根据实际情况进行调整
|
||||
|
||||
- `edns-client-subnet` 为 EDNS 客户端子网,演示中 `202.103.24.68` 为湖北武汉市 DNS 服务器地址,请根据实际情况进行调整
|
||||
|
||||
- 检查配置文件中关于本地域名及其上游 DNS 服务器相关配置,请根据实际情况进行调整
|
||||
|
||||
```bash
|
||||
# This configuration file is customized by fox,
|
||||
# Optimize SmartDNS parameters for local DNS server.
|
||||
#
|
||||
# For use common DNS server as upstream DNS server,
|
||||
# please modify 'server' parameter according to
|
||||
# your network environment.
|
||||
#
|
||||
# eg:
|
||||
# server 119.29.29.29
|
||||
# server 223.5.5.5
|
||||
# server 114.114.114.114
|
||||
# server 2402:4e00::
|
||||
# server 2400:3200::1
|
||||
|
||||
conf-file /etc/smartdns.d/*.conf
|
||||
|
||||
cache-file /tmp/smartdns.cache
|
||||
|
||||
log-level notice
|
||||
|
||||
bind [::]:6053@lo
|
||||
bind-tcp [::]:6053@lo
|
||||
|
||||
serve-expired yes
|
||||
serve-expired-ttl 129600
|
||||
serve-expired-reply-ttl 30
|
||||
prefetch-domain yes
|
||||
serve-expired-prefetch-time 21600
|
||||
|
||||
force-qtype-SOA 65
|
||||
max-query-limit 1024
|
||||
edns-client-subnet 202.103.24.68
|
||||
|
||||
server-tcp 119.29.29.29 -group dnspod -exclude-default-group
|
||||
server-tcp 2402:4e00:: -group dnspod -exclude-default-group
|
||||
nameserver /doh.pub/dnspod
|
||||
nameserver /dot.pub/dnspod
|
||||
|
||||
server-tcp 223.5.5.5 -group alidns -exclude-default-group
|
||||
server-tcp 2400:3200::1 -group alidns -exclude-default-group
|
||||
nameserver /dns.alidns.com/alidns
|
||||
|
||||
server 172.16.1.1 -group intranet -exclude-default-group
|
||||
nameserver /fox.home.arpa/intranet
|
||||
domain-rules /fox.home.arpa/ -speed-check-mode none -no-cache
|
||||
|
||||
server-tls dot.pub
|
||||
server-tls dns.alidns.com
|
||||
|
||||
server-https https://doh.pub/dns-query
|
||||
server-https https://dns.alidns.com/dns-query
|
||||
|
||||
```
|
||||
|
||||
### 6.3.定时任务
|
||||
### 6.2.定时任务
|
||||
|
||||
本步骤为可选操作,主要用于设置 `SmartDNS` 定时更新附加配置文件和定时重启。
|
||||
|
||||
@@ -380,7 +289,7 @@ server-https https://dns.alidns.com/dns-query
|
||||
$ sudo crontab -e
|
||||
```
|
||||
|
||||
在配置文件末尾,增加以下配置项。
|
||||
在配置文件末尾,增加以下内容。
|
||||
|
||||
```bash
|
||||
## 定时任务配置项
|
||||
@@ -398,23 +307,126 @@ $ 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 主配置
|
||||
|
||||
`SmartDNS` 配置较为复杂,可按需制定各类 DNS 请求规则,建议先查阅官方提供的 [配置指导](https://pymumu.github.io/smartdns/config/basic-config/) 和 [配置选项](https://pymumu.github.io/smartdns/configuration/) 。
|
||||
|
||||
修改 `SmartDNS` 主配置文件之前,建议关闭 `SmartDNS` 并清理 DNS 缓存文件。
|
||||
|
||||
```bash
|
||||
## 关闭 smartdns.service
|
||||
$ sudo systemctl stop smartdns.service
|
||||
|
||||
## 清理进程标识文件
|
||||
$ sudo rm -rvf /var/run/smartdns.pid /run/smartdns.pid
|
||||
```
|
||||
|
||||
`SmartDNS` 的主配置文件一般位于 `/etc/smartdns` 目录下,修改配置文件之前,执行以下命令将其备份。
|
||||
|
||||
```bash
|
||||
## 备份 SmartDNS 主配置文件
|
||||
$ sudo mv /etc/smartdns/smartdns.conf /etc/smartdns/smartdns.conf.bak
|
||||
```
|
||||
|
||||
创建 `SmartDNS` 主配置文件,执行以下命令。
|
||||
|
||||
```bash
|
||||
## 创建 SmartDNS 主配置文件
|
||||
$ sudo editor /etc/smartdns/smartdns.conf
|
||||
```
|
||||
|
||||
在编辑器对话框中输入以下内容,并保存。
|
||||
|
||||
**额外说明:**
|
||||
|
||||
- `SmartDNS` 端口监听参数为 `6053@lo` ,WebUI 端口监听参数为 `5380` ,请根据实际情况进行调整
|
||||
|
||||
- WebUI 默认用户名密码为 `admin/password` ,若需公网访问建议将默认密码修改为强密码
|
||||
|
||||
```bash
|
||||
# This configuration file is customized by fox,
|
||||
# Optimize SmartDNS parameters for local DNS server.
|
||||
#
|
||||
# For use common DNS server as upstream DNS server,
|
||||
# please modify 'server' parameter according to
|
||||
# your network environment.
|
||||
#
|
||||
# eg:
|
||||
# server 223.5.5.5
|
||||
# server 180.184.1.1
|
||||
# server 119.29.29.29
|
||||
# server 114.114.114.114
|
||||
# server 2402:4e00::
|
||||
# server 2400:3200::1
|
||||
|
||||
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
|
||||
|
||||
cache-size 32768
|
||||
max-query-limit 1024
|
||||
max-reply-ip-num 16
|
||||
|
||||
prefetch-domain yes
|
||||
|
||||
serve-expired yes
|
||||
serve-expired-ttl 129600
|
||||
serve-expired-reply-ttl 30
|
||||
serve-expired-prefetch-time 28800
|
||||
|
||||
rr-ttl-min 60
|
||||
rr-ttl-max 28800
|
||||
rr-ttl-reply-max 14400
|
||||
|
||||
server-tcp 180.184.1.1 -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
|
||||
|
||||
```
|
||||
|
||||
### 6.4.配置 Dnsmasq
|
||||
|
||||
`Dnsmasq` 的主配置文件一般位于 `/etc` 目录下,修改配置文件之前,执行以下命令将其备份。
|
||||
`Dnsmasq` 的主配置文件一般位于 `/etc` 目录下,修改配置文件之前,执行以下命令。
|
||||
|
||||
```bash
|
||||
## 备份 Dnsmasq 主配置文件
|
||||
$ sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.bak
|
||||
## 创建 Dnsmasq 配置目录
|
||||
$ sudo mkdir -p /etc/dnsmasq.d
|
||||
```
|
||||
|
||||
使用 `neovim` 编辑器创建 `Dnsmasq` 主配置文件,执行以下命令。
|
||||
创建 `Dnsmasq` 主配置文件,执行以下命令。
|
||||
|
||||
```bash
|
||||
## 创建 Dnsmasq 主配置文件
|
||||
$ sudo nvim /etc/dnsmasq.conf
|
||||
$ sudo editor /etc/dnsmasq.d/10-server-dnsmasq.conf
|
||||
```
|
||||
|
||||
在编辑器对话框中输入以下内容,并保存。
|
||||
@@ -423,7 +435,9 @@ $ sudo nvim /etc/dnsmasq.conf
|
||||
|
||||
- 请根据系统内存使用情况,调整缓存参数 `cache-size`
|
||||
|
||||
- 配置文件中内网域名为 `fox.home.arpa` ,请根据实际情况进行调整
|
||||
- 配置文件中监听的网卡名为 `eth0` ,请根据实际情况进行调整
|
||||
|
||||
- 配置文件中内网域名为 `fox.internal` ,请根据实际情况进行调整
|
||||
|
||||
- `Dnsmasq` 有且仅有 `SmartDNS` 作为上游 DNS 服务器
|
||||
|
||||
@@ -440,16 +454,17 @@ log-facility=/var/log/dnsmasq.log
|
||||
log-async=20
|
||||
|
||||
cache-size=2048
|
||||
max-cache-ttl=10800
|
||||
max-cache-ttl=7200
|
||||
fast-dns-retry=1800
|
||||
edns-packet-max=1232
|
||||
rebind-domain-ok=/fox.home.arpa/
|
||||
|
||||
interface=eth0
|
||||
rebind-domain-ok=/fox.internal/
|
||||
|
||||
bind-dynamic
|
||||
bogus-priv
|
||||
domain-needed
|
||||
local-service
|
||||
no-hosts
|
||||
no-negcache
|
||||
no-resolv
|
||||
no-round-robin
|
||||
rebind-localhost-ok
|
||||
@@ -458,9 +473,10 @@ stop-dns-rebind
|
||||
# DNS Filter
|
||||
|
||||
server=/alt/
|
||||
server=/home.arpa/
|
||||
server=/example/
|
||||
server=/bind/
|
||||
server=/example/
|
||||
server=/home.arpa/
|
||||
server=/internal/
|
||||
server=/invalid/
|
||||
server=/lan/
|
||||
server=/local/
|
||||
@@ -470,10 +486,8 @@ server=/test/
|
||||
|
||||
# DNS Server
|
||||
|
||||
server=/fox.home.arpa/172.16.1.1
|
||||
|
||||
server=/fox.internal/172.16.1.1
|
||||
server=127.0.0.1#6053
|
||||
server=::1#6053
|
||||
|
||||
```
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|参数|值|说明|
|
||||
|--|--|--|
|
||||
|虚拟机名称|`SVR01`| TS 服务器 `主机名` |
|
||||
|DNS 域|`fox.home.arpa`| TS 服务器 `Cloud-Init` |
|
||||
|DNS 域|`fox.internal`| TS 服务器 `Cloud-Init` |
|
||||
|DNS 服务器|`172.16.1.1`| TS 服务器 `Cloud-Init` |
|
||||
|IPv4|`172.16.1.4/24`| TS 服务器 `Cloud-Init` |
|
||||
|IPv4 网关|`172.16.1.1`| TS 服务器 `Cloud-Init` |
|
||||
@@ -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,23 +87,13 @@ $ 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.安装软件
|
||||
|
||||
软件源设置完成后,需要更新系统,执行以下命令。
|
||||
|
||||
```bash
|
||||
## 清理不必要的包
|
||||
$ sudo apt clean && sudo apt autoclean && sudo apt autoremove --purge
|
||||
$ sudo bash -c 'apt clean && apt autoclean && apt autoremove --purge'
|
||||
|
||||
## 更新软件源
|
||||
$ sudo apt update
|
||||
@@ -126,31 +106,80 @@ $ sudo apt full-upgrade
|
||||
|
||||
```bash
|
||||
## 安装系统软件
|
||||
$ sudo apt install qemu-guest-agent zsh git btop tmux cron nftables sshguard neovim
|
||||
$ 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 iperf iperf3 iftop lsof knot-dnsutils dnsmasq conntrack
|
||||
$ 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
|
||||
```
|
||||
|
||||
### 1.4.调整内核模块
|
||||
### 1.4.配置 ZSH
|
||||
|
||||
使用 `neovim` 编辑器编辑 **内核模块** 配置文件,执行以下命令。
|
||||
`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
|
||||
|
||||
## 询问是否切换默认 shell,输入 Y
|
||||
|
||||
#### 示例输出
|
||||
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
|
||||
```
|
||||
|
||||
### 1.5.配置默认编辑器
|
||||
|
||||
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,
|
||||
@@ -160,16 +189,16 @@ nf_conntrack
|
||||
|
||||
```
|
||||
|
||||
### 1.5.调整内核参数
|
||||
### 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,
|
||||
@@ -178,7 +207,7 @@ $ sudo nvim /etc/sysctl.d/99-sysctl.conf
|
||||
kernel.panic = 20
|
||||
kernel.panic_on_oops = 1
|
||||
|
||||
net.core.default_qdisc = cake
|
||||
net.core.default_qdisc = fq_pie
|
||||
net.ipv4.tcp_congestion_control = bbr
|
||||
|
||||
net.ipv4.ip_forward = 1
|
||||
@@ -188,10 +217,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.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
|
||||
@@ -205,23 +237,18 @@ net.ipv4.conf.default.arp_ignore = 1
|
||||
net.ipv4.conf.all.rp_filter = 2
|
||||
net.ipv4.conf.default.rp_filter = 2
|
||||
|
||||
net.ipv4.conf.all.log_martians = 1
|
||||
net.ipv4.conf.all.send_redirects = 0
|
||||
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_challenge_ack_limit = 1000
|
||||
net.ipv4.tcp_fastopen = 3
|
||||
net.ipv4.tcp_fin_timeout = 30
|
||||
net.ipv4.tcp_keepalive_time = 120
|
||||
net.ipv4.tcp_syncookies = 1
|
||||
|
||||
net.ipv6.conf.all.accept_ra = 0
|
||||
net.ipv6.conf.default.accept_ra = 0
|
||||
net.ipv4.tcp_keepalive_time = 600
|
||||
net.ipv4.tcp_max_syn_backlog = 4096
|
||||
net.ipv4.tcp_notsent_lowat = 131072
|
||||
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
|
||||
@@ -233,7 +260,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
|
||||
|
||||
```
|
||||
@@ -242,10 +269,10 @@ net.netfilter.nf_conntrack_tcp_timeout_established = 7440
|
||||
|
||||
```bash
|
||||
## 让内核参数生效
|
||||
$ sudo sysctl -f
|
||||
$ sudo sysctl --system
|
||||
```
|
||||
|
||||
### 1.6.调整系统时间
|
||||
### 1.8.调整系统时间
|
||||
|
||||
默认情况下 Debian 云镜像的系统时间需要调整,执行以下命令将系统时区设置为中国时区。
|
||||
|
||||
@@ -262,35 +289,35 @@ Debian 云镜像默认使用 `systemd-timesyncd.service` 同步时间,且需
|
||||
调整 NTP 服务器参数,执行以下命令。
|
||||
|
||||
```bash
|
||||
## 创建 NTP 配置文件的目录
|
||||
## 创建 NTP 配置目录
|
||||
$ 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,
|
||||
# Optimize system NTP server.
|
||||
|
||||
[Time]
|
||||
NTP=ntp.tencent.com ntp.aliyun.com
|
||||
NTP=ntp.aliyun.com ntp.tencent.com cn.pool.ntp.org
|
||||
|
||||
```
|
||||
|
||||
保存该配置文件后,需重启 `systemd-timesyncd.service` 服务,并再次检查系统 NTP 服务器地址。
|
||||
|
||||
```bash
|
||||
## 重启 chrony 服务
|
||||
## 重启 systemd-timesyncd.service
|
||||
$ sudo systemctl restart systemd-timesyncd.service
|
||||
|
||||
## 检查系统 NTP 服务器
|
||||
$ sudo systemctl status systemd-timesyncd.service
|
||||
```
|
||||
|
||||
### 1.7.配置自动更新
|
||||
### 1.9.配置自动更新
|
||||
|
||||
配置系统自动更新策略,执行以下命令,使用键盘 `左右方向键` 进行选择,`回车键` 进行确认。
|
||||
|
||||
@@ -298,20 +325,18 @@ $ sudo systemctl status systemd-timesyncd.service
|
||||
## 配置自动更新策略
|
||||
$ sudo dpkg-reconfigure -plow unattended-upgrades
|
||||
|
||||
## 选择 “是” (“YES”)
|
||||
|
||||
#### 系统自动更新示例输出
|
||||
Creating config file /etc/apt/apt.conf.d/20auto-upgrades with new version
|
||||
## 选择 “是”
|
||||
<Yes>
|
||||
```
|
||||
|
||||
进一步调整 `20auto-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` 天。
|
||||
|
||||
@@ -329,11 +354,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
|
||||
@@ -345,7 +368,7 @@ $ sudo nvim /etc/apt/apt.conf.d/50unattended-upgrades
|
||||
|
||||
"origin=Tailscale,codename=${distro_codename},label=Tailscale";
|
||||
|
||||
## 在配置文件末尾增加以下配置项,代表启用,并调整参数
|
||||
## 在配置文件末尾增加以下内容,代表启用,并调整参数
|
||||
|
||||
Unattended-Upgrade::AutoFixInterruptedDpkg "true";
|
||||
|
||||
@@ -357,32 +380,32 @@ 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";
|
||||
|
||||
```
|
||||
|
||||
系统自动更新配置文件修改完成后,需要重设自动更新定时器,执行以下命令。
|
||||
系统自动更新配置文件修改完成后,需调整自动更新定时器,执行以下命令。
|
||||
|
||||
```bash
|
||||
## 配置系统定时器
|
||||
$ sudo systemctl edit apt-daily-upgrade.timer
|
||||
```
|
||||
|
||||
根据配置文件中的提示,在中间空白处填入以下配置项。
|
||||
根据配置文件中的提示,在中间空白处填入以下内容。
|
||||
|
||||
```bash
|
||||
## 定时器配置项
|
||||
|
||||
[Timer]
|
||||
OnCalendar=
|
||||
OnCalendar=02:00
|
||||
OnCalendar=12:00
|
||||
RandomizedDelaySec=0
|
||||
|
||||
```
|
||||
|
||||
设置完成后,重启自动更新定时器并检查其状态,执行以下命令。
|
||||
|
||||
在输出结果中,看到系统自动更新的触发时间为 `02:00` 则表示设置正确。
|
||||
在输出结果中,看到系统自动更新的触发时间为 `12:00` 则表示设置正确。
|
||||
|
||||
```bash
|
||||
## 重启触发器
|
||||
@@ -392,7 +415,7 @@ $ sudo systemctl restart apt-daily-upgrade.timer
|
||||
$ sudo systemctl status apt-daily-upgrade.timer
|
||||
```
|
||||
|
||||
### 1.8.配置防火墙
|
||||
### 1.10.配置防火墙
|
||||
|
||||
修改防火墙配置之前,需检查 `nftables.service` 服务状态,确保该服务开机自启。
|
||||
|
||||
@@ -404,14 +427,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) 进行复制。
|
||||
@@ -423,7 +446,7 @@ $ sudo nvim /etc/nftables.conf
|
||||
$ sudo systemctl restart nftables.service
|
||||
```
|
||||
|
||||
### 1.9.调整系统端口
|
||||
### 1.11.调整系统端口
|
||||
|
||||
为了正常使用 `53` 端口,需要对 `systemd-resolved.service` 进行配置,执行以下命令。
|
||||
|
||||
@@ -432,10 +455,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,
|
||||
@@ -462,7 +485,7 @@ $ sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
|
||||
$ sudo systemctl restart systemd-resolved.service
|
||||
```
|
||||
|
||||
### 1.10.配置 Dnsmasq
|
||||
### 1.12.配置 Dnsmasq
|
||||
|
||||
检查 `dnsmasq.service` 服务状态,确保该服务开机自启。
|
||||
|
||||
@@ -474,18 +497,18 @@ $ sudo systemctl status dnsmasq.service
|
||||
$ sudo systemctl enable dnsmasq.service
|
||||
```
|
||||
|
||||
`Dnsmasq` 的主配置文件一般位于 `/etc` 目录下,修改配置文件之前,执行以下命令将其备份。
|
||||
`Dnsmasq` 的主配置文件一般位于 `/etc` 目录下,修改配置文件之前,执行以下命令。
|
||||
|
||||
```bash
|
||||
## 备份 Dnsmasq 主配置文件
|
||||
$ sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.bak
|
||||
## 创建 Dnsmasq 配置目录
|
||||
$ sudo mkdir -p /etc/dnsmasq.d
|
||||
```
|
||||
|
||||
使用 `neovim` 编辑器创建 `Dnsmasq` 主配置文件,执行以下命令。
|
||||
创建 `Dnsmasq` 主配置文件,执行以下命令。
|
||||
|
||||
```bash
|
||||
## 创建 Dnsmasq 主配置文件
|
||||
$ sudo nvim /etc/dnsmasq.conf
|
||||
$ sudo editor /etc/dnsmasq.d/10-server-dnsmasq.conf
|
||||
```
|
||||
|
||||
在编辑器对话框中输入以下内容,并保存。
|
||||
@@ -494,11 +517,13 @@ $ sudo nvim /etc/dnsmasq.conf
|
||||
|
||||
- 请根据系统内存使用情况,调整缓存参数 `cache-size`
|
||||
|
||||
- 配置文件中内网域名为 `fox.home.arpa` ,请根据实际情况进行调整
|
||||
- 配置文件中监听的网卡名为 `eth0` 和 `tailscale0` ,请根据实际情况进行调整
|
||||
|
||||
- 配置文件中内网域名为 `fox.internal` ,请根据实际情况进行调整
|
||||
|
||||
- `Dnsmasq` 上游 DNS 服务器分为三类,请根据实际情况进行调整
|
||||
- `server=/ts.net/100.100.100.100` :TS 服务 `MagicDNS` 专用 DNS 服务器
|
||||
- `server=/fox.home.arpa/172.16.1.1` :内网域名解析 DNS 服务器,通常为主路由地址
|
||||
- `server=/fox.internal/172.16.1.1` :内网域名解析 DNS 服务器,通常为主路由地址
|
||||
- `server` 参数中的其他 DNS 服务器供 TS 服务器自身及其下游设备使用
|
||||
|
||||
```bash
|
||||
@@ -514,16 +539,18 @@ log-facility=/var/log/dnsmasq.log
|
||||
log-async=20
|
||||
|
||||
cache-size=2048
|
||||
max-cache-ttl=10800
|
||||
max-cache-ttl=7200
|
||||
fast-dns-retry=1800
|
||||
edns-packet-max=1232
|
||||
rebind-domain-ok=/fox.home.arpa/
|
||||
|
||||
interface=eth0,tailscale0
|
||||
rebind-domain-ok=/fox.internal/
|
||||
|
||||
bind-dynamic
|
||||
bogus-priv
|
||||
domain-needed
|
||||
local-service
|
||||
no-hosts
|
||||
no-negcache
|
||||
no-resolv
|
||||
no-round-robin
|
||||
rebind-localhost-ok
|
||||
stop-dns-rebind
|
||||
@@ -531,9 +558,10 @@ stop-dns-rebind
|
||||
# DNS Filter
|
||||
|
||||
server=/alt/
|
||||
server=/home.arpa/
|
||||
server=/example/
|
||||
server=/bind/
|
||||
server=/example/
|
||||
server=/home.arpa/
|
||||
server=/internal/
|
||||
server=/invalid/
|
||||
server=/lan/
|
||||
server=/local/
|
||||
@@ -544,9 +572,7 @@ server=/test/
|
||||
# DNS Server
|
||||
|
||||
server=/ts.net/100.100.100.100
|
||||
|
||||
server=/fox.home.arpa/172.16.1.1
|
||||
|
||||
server=/fox.internal/172.16.1.1
|
||||
server=172.16.1.1
|
||||
|
||||
```
|
||||
@@ -558,31 +584,111 @@ server=172.16.1.1
|
||||
$ sudo systemctl restart dnsmasq.service
|
||||
```
|
||||
|
||||
### 1.11.配置 ZSH
|
||||
|
||||
`Zsh` 是比 `Bash` 好用的 `Shell` 程序,使用 `oh-my-zsh` 进行配置。
|
||||
|
||||
```bash
|
||||
## 返回 home 目录
|
||||
$ cd
|
||||
|
||||
## 使用 curl 安装 oh-my-zsh
|
||||
$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
|
||||
|
||||
## 或者使用 wget 安装 oh-my-zsh
|
||||
$ sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
|
||||
|
||||
## 询问是否切换默认 shell,输入 Y
|
||||
|
||||
#### 示例输出
|
||||
Time to change your default shell to zsh:
|
||||
Do you want to change your default shell to zsh? [Y/n] y
|
||||
```
|
||||
|
||||
## 2.配置 Tailscale
|
||||
## 2. Tailscale
|
||||
|
||||
根据不同的启动参数,TS 服务将具有不同的业务能力。
|
||||
|
||||
### 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 组网功能,执行以下命令。
|
||||
|
||||
```bash
|
||||
@@ -613,6 +719,8 @@ $ sudo tailscale up --advertise-exit-node --accept-routes --advertise-routes=172
|
||||
|
||||
执行命令后,TS 将自动显示登录链接,只需根据链接进行登录操作即可。
|
||||
|
||||
### 2.3.自动更新
|
||||
|
||||
目前 TS 将跟随系统自动更新,若需额外开启 TS 的自动更新功能,执行以下命令。
|
||||
|
||||
```bash
|
||||
@@ -623,5 +731,23 @@ $ sudo tailscale set --auto-update
|
||||
$ sudo tailscale set --auto-update=false
|
||||
```
|
||||
|
||||
### 2.4.定时任务
|
||||
|
||||
本步骤为可选操作,主要用于设置 TS 定时重启。
|
||||
|
||||
```bash
|
||||
## 编辑系统定时任务,编辑器选择 nano
|
||||
$ sudo crontab -e
|
||||
```
|
||||
|
||||
在配置文件末尾,增加以下内容。
|
||||
|
||||
```bash
|
||||
## 定时任务配置项
|
||||
|
||||
30 10 * * * /usr/bin/systemctl restart tailscaled.service
|
||||
|
||||
```
|
||||
|
||||
至此,TS 服务器已配置完成。
|
||||
|
||||
|
||||
@@ -2,13 +2,11 @@
|
||||
|
||||
在所有虚拟机创建并配置完成后,可以使用 PVE 自带的备份功能周期性的将虚拟机备份。
|
||||
|
||||
点击 PVE 的 `数据中心` ,在右侧菜单中选择 `备份` 功能。
|
||||
|
||||
点击顶部 `添加` 按钮,添加一个 `备份作业` 。
|
||||
点击 PVE 的 `数据中心` ,在右侧菜单中选择 `备份` 功能,并点击顶部 `添加` 。
|
||||
|
||||

|
||||
|
||||
### 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 @@
|
||||
|
||||

|
||||
|
||||
### 1.2.保留选项
|
||||
### 1.2.通知
|
||||
|
||||
|参数|值|说明|
|
||||
|--|--|--|
|
||||
|通知模式|`使用全局通知设置`|执行备份时的通知模式,保持默认即可|
|
||||
|
||||

|
||||
|
||||
### 1.3.保留
|
||||
|
||||
该选项将控制备份文件的保留个数,选择保留最近 `3` 份备份文件。
|
||||
|
||||

|
||||
|
||||
### 1.3.备注模板
|
||||
### 1.4.备注模板
|
||||
|
||||
该选项将按照设置的内容,自动重命名备份文件。
|
||||
|
||||
在 `备份日志` 右侧文本框中输入 `{{vmid}}_{{guestname}}_Auto_Backup` 。
|
||||
|
||||
点击 `创建` 按钮,`备份作业` 创建完成。
|
||||
在 `备份日志` 右侧文本框中输入 `{{vmid}}-{{guestname}}-Autobackup` 。
|
||||
|
||||

|
||||
|
||||
### 1.4.高级选项
|
||||
### 1.5.高级
|
||||
|
||||
该选项提供 `备份作业` 进行时的高级可调参数,仅需勾选 `重复错过` 选项即可。
|
||||
该选项提供 `备份作业` 执行时的高级可调参数,仅需勾选 `重复错过` 选项即可。
|
||||
|
||||
点击 `创建` ,此 `备份作业` 即完成设置与创建。
|
||||
|
||||

|
||||
|
||||
@@ -68,7 +71,7 @@
|
||||
|
||||

|
||||
|
||||
`计划` 处将显示 `备份作业` 的执行时间参数,点击 `模拟` 按钮,在右侧将显示模拟的时间结果。
|
||||
`计划` 处将显示 `备份作业` 的执行时间参数,点击 `模拟` ,在右侧将显示模拟的时间结果。
|
||||
|
||||
确认 `备份作业` 的执行时间周期是否符合预期。
|
||||
|
||||
|
||||
@@ -3,13 +3,7 @@
|
||||
## 介绍
|
||||
PVE 虚拟化平台的安装以及折腾手记。
|
||||
|
||||
- PVE ISO 版本:8.2-1 (更新时间: 2024-04-24)
|
||||
|
||||
- 演示机:
|
||||
- CPU:英特尔奔腾 Silver N6005 处理器
|
||||
- 内存:16 GB
|
||||
- 网卡:英特尔以太网控制器 I226-V
|
||||
- 硬盘:500 GB NVMe 固态硬盘
|
||||
- PVE ISO 版本:9.1-1 (更新时间: 2025-11-19)
|
||||
|
||||
- PVE 网络:
|
||||
- IPv4 网络
|
||||
|
||||
|
Before Width: | Height: | Size: 209 KiB After Width: | Height: | Size: 227 KiB |
|
Before Width: | Height: | Size: 280 KiB After Width: | Height: | Size: 261 KiB |
|
Before Width: | Height: | Size: 144 KiB After Width: | Height: | Size: 117 KiB |
|
Before Width: | Height: | Size: 300 KiB After Width: | Height: | Size: 310 KiB |
|
Before Width: | Height: | Size: 147 KiB After Width: | Height: | Size: 218 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 292 KiB After Width: | Height: | Size: 152 KiB |
|
Before Width: | Height: | Size: 265 KiB After Width: | Height: | Size: 156 KiB |
|
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 273 KiB |
|
Before Width: | Height: | Size: 186 KiB After Width: | Height: | Size: 94 KiB |
|
Before Width: | Height: | Size: 294 KiB After Width: | Height: | Size: 307 KiB |
|
Before Width: | Height: | Size: 217 KiB |
|
Before Width: | Height: | Size: 111 KiB After Width: | Height: | Size: 266 KiB |
|
Before Width: | Height: | Size: 271 KiB After Width: | Height: | Size: 603 KiB |
|
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 136 KiB |
|
Before Width: | Height: | Size: 401 KiB After Width: | Height: | Size: 375 KiB |
|
Before Width: | Height: | Size: 133 KiB After Width: | Height: | Size: 403 KiB |
|
Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 404 KiB |
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 100 KiB |
|
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 196 KiB |
|
Before Width: | Height: | Size: 132 KiB After Width: | Height: | Size: 244 KiB |
|
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 100 KiB |
|
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 83 KiB |
|
Before Width: | Height: | Size: 141 KiB After Width: | Height: | Size: 230 KiB |
|
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 180 KiB |
|
Before Width: | Height: | Size: 165 KiB After Width: | Height: | Size: 248 KiB |
|
After Width: | Height: | Size: 495 KiB |
|
Before Width: | Height: | Size: 189 KiB |
|
After Width: | Height: | Size: 664 KiB |
|
Before Width: | Height: | Size: 579 KiB |
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 302 KiB |
|
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 222 KiB |
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 123 KiB |
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 125 KiB |
|
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 158 KiB |
|
Before Width: | Height: | Size: 107 KiB After Width: | Height: | Size: 168 KiB |
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 362 KiB |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 259 KiB |
|
Before Width: | Height: | Size: 124 KiB After Width: | Height: | Size: 447 KiB |
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 328 KiB |
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 168 KiB |
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 391 KiB |
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 114 KiB |
|
Before Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 343 KiB |
|
After Width: | Height: | Size: 219 KiB |
|
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 166 KiB |
|
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 126 KiB |
|
Before Width: | Height: | Size: 111 KiB After Width: | Height: | Size: 222 KiB |
|
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 187 KiB |
|
Before Width: | Height: | Size: 187 KiB After Width: | Height: | Size: 190 KiB |
|
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 161 KiB |
|
After Width: | Height: | Size: 385 KiB |
|
After Width: | Height: | Size: 240 KiB |
|
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 200 KiB |
|
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 275 KiB |
|
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 318 KiB |
|
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 127 KiB |
|
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 202 KiB |
|
Before Width: | Height: | Size: 157 KiB After Width: | Height: | Size: 252 KiB |
|
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 198 KiB |
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 129 KiB |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 133 KiB |
|
Before Width: | Height: | Size: 384 KiB After Width: | Height: | Size: 427 KiB |
|
After Width: | Height: | Size: 114 KiB |
|
Before Width: | Height: | Size: 127 KiB After Width: | Height: | Size: 119 KiB |
|
Before Width: | Height: | Size: 300 KiB After Width: | Height: | Size: 259 KiB |
|
Before Width: | Height: | Size: 151 KiB After Width: | Height: | Size: 157 KiB |
|
Before Width: | Height: | Size: 220 KiB After Width: | Height: | Size: 230 KiB |
|
Before Width: | Height: | Size: 201 KiB After Width: | Height: | Size: 141 KiB |
|
Before Width: | Height: | Size: 171 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";
|
||||
|
||||
|
||||
@@ -5,21 +5,24 @@ kernel.panic = 20
|
||||
kernel.panic_on_oops = 1
|
||||
|
||||
net.core.default_qdisc = fq_codel
|
||||
net.ipv4.tcp_congestion_control = bbr
|
||||
|
||||
# Other adjustable system parameters
|
||||
|
||||
net.core.netdev_budget = 600
|
||||
net.core.netdev_budget_usecs = 20000
|
||||
net.core.netdev_max_backlog = 4096
|
||||
|
||||
net.ipv4.conf.all.log_martians = 1
|
||||
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_syncookies = 1
|
||||
net.ipv4.tcp_keepalive_time = 600
|
||||
net.ipv4.tcp_max_syn_backlog = 4096
|
||||
net.ipv4.tcp_notsent_lowat = 131072
|
||||
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
|
||||
|
||||
@@ -10,16 +10,17 @@ log-facility=/var/log/dnsmasq.log
|
||||
log-async=20
|
||||
|
||||
cache-size=2048
|
||||
max-cache-ttl=10800
|
||||
max-cache-ttl=7200
|
||||
fast-dns-retry=1800
|
||||
edns-packet-max=1232
|
||||
rebind-domain-ok=/fox.home.arpa/
|
||||
|
||||
interface=eth0
|
||||
rebind-domain-ok=/fox.internal/
|
||||
|
||||
bind-dynamic
|
||||
bogus-priv
|
||||
domain-needed
|
||||
local-service
|
||||
no-hosts
|
||||
no-negcache
|
||||
no-resolv
|
||||
no-round-robin
|
||||
rebind-localhost-ok
|
||||
@@ -28,9 +29,10 @@ stop-dns-rebind
|
||||
# DNS Filter
|
||||
|
||||
server=/alt/
|
||||
server=/home.arpa/
|
||||
server=/example/
|
||||
server=/bind/
|
||||
server=/example/
|
||||
server=/home.arpa/
|
||||
server=/internal/
|
||||
server=/invalid/
|
||||
server=/lan/
|
||||
server=/local/
|
||||
@@ -40,8 +42,6 @@ server=/test/
|
||||
|
||||
# DNS Server
|
||||
|
||||
server=/fox.home.arpa/172.16.1.1
|
||||
|
||||
server=/fox.internal/172.16.1.1
|
||||
server=127.0.0.1#6053
|
||||
server=::1#6053
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -6,47 +6,59 @@
|
||||
# your network environment.
|
||||
#
|
||||
# eg:
|
||||
# server 119.29.29.29
|
||||
# server 223.5.5.5
|
||||
# server 180.184.1.1
|
||||
# server 119.29.29.29
|
||||
# server 114.114.114.114
|
||||
# server 2402:4e00::
|
||||
# server 2400:3200::1
|
||||
|
||||
conf-file /etc/smartdns.d/*.conf
|
||||
|
||||
cache-file /tmp/smartdns.cache
|
||||
|
||||
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
|
||||
|
||||
cache-size 32768
|
||||
max-query-limit 1024
|
||||
max-reply-ip-num 16
|
||||
|
||||
prefetch-domain yes
|
||||
|
||||
serve-expired yes
|
||||
serve-expired-ttl 129600
|
||||
serve-expired-reply-ttl 30
|
||||
prefetch-domain yes
|
||||
serve-expired-prefetch-time 21600
|
||||
serve-expired-prefetch-time 28800
|
||||
|
||||
force-qtype-SOA 65
|
||||
max-query-limit 1024
|
||||
edns-client-subnet 202.103.24.68
|
||||
rr-ttl-min 60
|
||||
rr-ttl-max 28800
|
||||
rr-ttl-reply-max 14400
|
||||
|
||||
server-tcp 119.29.29.29 -group dnspod -exclude-default-group
|
||||
server-tcp 2402:4e00:: -group dnspod -exclude-default-group
|
||||
nameserver /doh.pub/dnspod
|
||||
nameserver /dot.pub/dnspod
|
||||
server-tcp 180.184.1.1 -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-tcp 223.5.5.5 -group alidns -exclude-default-group
|
||||
server-tcp 2400:3200::1 -group alidns -exclude-default-group
|
||||
nameserver /dns.alidns.com/alidns
|
||||
|
||||
server 172.16.1.1 -group intranet -exclude-default-group
|
||||
nameserver /fox.home.arpa/intranet
|
||||
domain-rules /fox.home.arpa/ -speed-check-mode none -no-cache
|
||||
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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
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"
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
kernel.panic = 20
|
||||
kernel.panic_on_oops = 1
|
||||
|
||||
net.core.default_qdisc = cake
|
||||
net.core.default_qdisc = fq_pie
|
||||
net.ipv4.tcp_congestion_control = bbr
|
||||
|
||||
net.ipv4.ip_forward = 1
|
||||
@@ -14,10 +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.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
|
||||
@@ -31,23 +34,18 @@ net.ipv4.conf.default.arp_ignore = 1
|
||||
net.ipv4.conf.all.rp_filter = 2
|
||||
net.ipv4.conf.default.rp_filter = 2
|
||||
|
||||
net.ipv4.conf.all.log_martians = 1
|
||||
net.ipv4.conf.all.send_redirects = 0
|
||||
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_challenge_ack_limit = 1000
|
||||
net.ipv4.tcp_fastopen = 3
|
||||
net.ipv4.tcp_fin_timeout = 30
|
||||
net.ipv4.tcp_keepalive_time = 120
|
||||
net.ipv4.tcp_syncookies = 1
|
||||
|
||||
net.ipv6.conf.all.accept_ra = 0
|
||||
net.ipv6.conf.default.accept_ra = 0
|
||||
net.ipv4.tcp_keepalive_time = 600
|
||||
net.ipv4.tcp_max_syn_backlog = 4096
|
||||
net.ipv4.tcp_notsent_lowat = 131072
|
||||
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
|
||||
@@ -59,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
|
||||
|
||||
|
||||
@@ -10,16 +10,18 @@ log-facility=/var/log/dnsmasq.log
|
||||
log-async=20
|
||||
|
||||
cache-size=2048
|
||||
max-cache-ttl=10800
|
||||
max-cache-ttl=7200
|
||||
fast-dns-retry=1800
|
||||
edns-packet-max=1232
|
||||
rebind-domain-ok=/fox.home.arpa/
|
||||
|
||||
interface=eth0,tailscale0
|
||||
rebind-domain-ok=/fox.internal/
|
||||
|
||||
bind-dynamic
|
||||
bogus-priv
|
||||
domain-needed
|
||||
local-service
|
||||
no-hosts
|
||||
no-negcache
|
||||
no-resolv
|
||||
no-round-robin
|
||||
rebind-localhost-ok
|
||||
stop-dns-rebind
|
||||
@@ -27,9 +29,10 @@ stop-dns-rebind
|
||||
# DNS Filter
|
||||
|
||||
server=/alt/
|
||||
server=/home.arpa/
|
||||
server=/example/
|
||||
server=/bind/
|
||||
server=/example/
|
||||
server=/home.arpa/
|
||||
server=/internal/
|
||||
server=/invalid/
|
||||
server=/lan/
|
||||
server=/local/
|
||||
@@ -40,8 +43,6 @@ server=/test/
|
||||
# DNS Server
|
||||
|
||||
server=/ts.net/100.100.100.100
|
||||
|
||||
server=/fox.home.arpa/172.16.1.1
|
||||
|
||||
server=/fox.internal/172.16.1.1
|
||||
server=172.16.1.1
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ table inet router
|
||||
flush table inet router
|
||||
|
||||
table inet router {
|
||||
|
||||
#
|
||||
# Flowtable
|
||||
#
|
||||
@@ -26,17 +27,17 @@ table inet router {
|
||||
type filter hook input priority filter; policy drop;
|
||||
iif "lo" accept comment "defconf: accept traffic from loopback"
|
||||
ct state vmap { established : accept, related : accept } comment "defconf: handle inbound flows"
|
||||
tcp flags syn / fin,syn,rst,ack counter jump syn_flood comment "defconf: rate limit TCP-SYN packets"
|
||||
tcp flags & (fin | syn | rst | ack) == syn jump syn_flood comment "defconf: rate limit new TCP connections"
|
||||
iifname "eth0" jump input_lan comment "defconf: handle LAN IPv4 / IPv6 input traffic"
|
||||
iifname "tailscale0" counter jump input_tailscale comment "tsconf: handle TS IPv4 / IPv6 input traffic"
|
||||
iifname "tailscale0" jump input_tailscale comment "tsconf: handle TS IPv4 / IPv6 input traffic"
|
||||
}
|
||||
|
||||
chain forward {
|
||||
type filter hook forward priority filter; policy drop;
|
||||
ct state established,related flow add @ft comment "defconf: track forwarded flows"
|
||||
ct state established,related flow add @ft;
|
||||
ct state vmap { established : accept, related : accept } comment "defconf: handle forwarded flows"
|
||||
iifname "eth0" jump forward_lan comment "defconf: handle LAN IPv4 / IPv6 forward traffic"
|
||||
iifname "tailscale0" counter jump forward_tailscale comment "tsconf: handle TS IPv4 / IPv6 forward traffic"
|
||||
iifname "tailscale0" jump forward_tailscale comment "tsconf: handle TS IPv4 / IPv6 forward traffic"
|
||||
}
|
||||
|
||||
chain output {
|
||||
@@ -44,28 +45,22 @@ table inet router {
|
||||
oif "lo" accept comment "defconf: accept traffic towards loopback"
|
||||
ct state vmap { established : accept, related : accept } comment "defconf: handle outbound flows"
|
||||
oifname "eth0" jump output_lan comment "defconf: handle LAN IPv4 / IPv6 output traffic"
|
||||
oifname "tailscale0" counter jump output_tailscale comment "tsconf: handle TS IPv4 / IPv6 output traffic"
|
||||
}
|
||||
|
||||
chain prerouting {
|
||||
type filter hook prerouting priority filter; policy accept;
|
||||
iifname "eth0" jump helper_lan comment "defconf: handle LAN IPv4 / IPv6 helper assignment"
|
||||
iifname "tailscale0" jump helper_tailscale comment "tsconf: handle TS IPv4 / IPv6 helper assignment"
|
||||
oifname "tailscale0" jump output_tailscale comment "tsconf: handle TS IPv4 / IPv6 output traffic"
|
||||
}
|
||||
|
||||
chain syn_flood {
|
||||
limit rate 200/second burst 100 packets return comment "defconf: accept SYN packets below rate-limit"
|
||||
counter drop comment "defconf: drop excess packets"
|
||||
limit rate 50/second burst 100 packets return comment "defconf: accept new TCP connections below rate-limit"
|
||||
counter drop comment "defconf: drop excess new TCP connections"
|
||||
}
|
||||
|
||||
chain input_lan {
|
||||
ct status dnat counter accept comment "lanconf: accept port redirect"
|
||||
ct status dnat accept comment "lanconf: accept port redirect"
|
||||
jump accept_from_lan
|
||||
}
|
||||
|
||||
chain forward_lan {
|
||||
jump accept_to_tailscale comment "tsconf: accept LAN to TS forward"
|
||||
ct status dnat counter accept comment "lanconf: accept port forward"
|
||||
jump accept_to_tailscale comment "tsconf: accept LAN to TS forwarding"
|
||||
ct status dnat accept comment "lanconf: accept port forwards"
|
||||
jump accept_to_lan
|
||||
}
|
||||
|
||||
@@ -73,17 +68,13 @@ table inet router {
|
||||
jump accept_to_lan
|
||||
}
|
||||
|
||||
chain helper_lan {
|
||||
}
|
||||
|
||||
chain accept_from_lan {
|
||||
iifname "eth0" counter accept comment "defconf: accept LAN IPv4 / IPv6 traffic"
|
||||
iifname "eth0" accept comment "defconf: accept LAN IPv4 / IPv6 traffic"
|
||||
}
|
||||
|
||||
chain accept_to_lan {
|
||||
meta nfproto ipv4 oifname "eth0" ct state invalid counter drop comment "defconf: prevent NATv4 leakage"
|
||||
meta nfproto ipv6 oifname "eth0" ct state invalid counter drop comment "defconf: prevent NATv6 leakage"
|
||||
oifname "eth0" counter accept comment "defconf: accept LAN IPv4 / IPv6 traffic"
|
||||
meta nfproto ipv4 oifname "eth0" ct state invalid counter drop comment "defconf: prevent LAN NATv4 leakage"
|
||||
oifname "eth0" accept comment "defconf: accept LAN IPv4 / IPv6 traffic"
|
||||
}
|
||||
|
||||
chain input_tailscale {
|
||||
@@ -91,23 +82,22 @@ table inet router {
|
||||
}
|
||||
|
||||
chain forward_tailscale {
|
||||
counter jump accept_to_lan comment "tsconf: accept TS to LAN forward"
|
||||
counter jump accept_to_tailscale
|
||||
jump accept_to_lan comment "tsconf: accept TS to LAN forwarding"
|
||||
jump accept_to_tailscale
|
||||
}
|
||||
|
||||
chain output_tailscale {
|
||||
counter jump accept_to_tailscale
|
||||
}
|
||||
|
||||
chain helper_tailscale {
|
||||
jump accept_to_tailscale
|
||||
}
|
||||
|
||||
chain accept_from_tailscale {
|
||||
iifname "tailscale0" counter accept comment "tsconf: accept TS IPv4 / IPv6 traffic"
|
||||
meta nfproto ipv4 iifname "tailscale0" counter accept comment "tsconf: accept TS IPv4 traffic"
|
||||
meta nfproto ipv6 iifname "tailscale0" counter accept comment "tsconf: accept TS IPv6 traffic"
|
||||
}
|
||||
|
||||
chain accept_to_tailscale {
|
||||
oifname "tailscale0" counter accept comment "tsconf: accept TS IPv4 / IPv6 traffic"
|
||||
meta nfproto ipv4 oifname "tailscale0" counter accept comment "tsconf: accept TS IPv4 traffic"
|
||||
meta nfproto ipv6 oifname "tailscale0" counter accept comment "tsconf: accept TS IPv6 traffic"
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +107,7 @@ table inet router {
|
||||
|
||||
chain dstnat {
|
||||
type nat hook prerouting priority dstnat; policy accept;
|
||||
iifname "eth0" meta l4proto { tcp, udp } th dport domain jump dstnat_lan comment "defconf: handle LAN IPv4 / IPv6 dstnat traffic"
|
||||
iifname { "eth0", "tailscale0" } meta l4proto { tcp, udp } th dport domain jump dstnat_lan comment "defconf: handle LAN IPv4 / IPv6 dstnat traffic"
|
||||
}
|
||||
|
||||
chain srcnat {
|
||||
@@ -131,21 +121,7 @@ table inet router {
|
||||
}
|
||||
|
||||
chain srcnat_lan {
|
||||
meta nfproto ipv4 counter masquerade comment "defconf: masquerade IPv4 LAN traffic"
|
||||
meta nfproto ipv6 counter masquerade comment "defconf: masquerade IPv6 LAN traffic"
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Raw rules (notrack)
|
||||
#
|
||||
|
||||
chain raw_prerouting {
|
||||
type filter hook prerouting priority raw; policy accept;
|
||||
}
|
||||
|
||||
chain raw_output {
|
||||
type filter hook output priority raw; policy accept;
|
||||
meta nfproto ipv4 counter masquerade comment "defconf: masquerade LAN IPv4 traffic"
|
||||
}
|
||||
|
||||
|
||||
@@ -153,24 +129,14 @@ table inet router {
|
||||
# Mangle rules
|
||||
#
|
||||
|
||||
chain mangle_prerouting {
|
||||
type filter hook prerouting priority mangle; policy accept;
|
||||
}
|
||||
|
||||
chain mangle_postrouting {
|
||||
type filter hook postrouting priority mangle; policy accept;
|
||||
}
|
||||
|
||||
chain mangle_input {
|
||||
type filter hook input priority mangle; policy accept;
|
||||
}
|
||||
|
||||
chain mangle_output {
|
||||
type route hook output priority mangle; policy accept;
|
||||
oifname "eth0" tcp flags syn / fin,syn,rst tcp option maxseg size set rt mtu comment "defconf: zone LAN IPv4 / IPv6 egress MTU fixing"
|
||||
}
|
||||
|
||||
chain mangle_forward {
|
||||
type filter hook forward priority mangle; policy accept;
|
||||
iifname "eth0" tcp flags syn / fin,syn,rst tcp option maxseg size set rt mtu comment "defconf: zone LAN IPv4 / IPv6 ingress MTU fixing"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
# This configuration file is customized by fox,
|
||||
# Optimize netfilter related modules at system boot.
|
||||
|
||||
nf_conntrack
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||