Compare commits

..
11 Commits
Author SHA1 Message Date
CallMeR 12b5a4aec4 更新脚本名称 & 备注信息 2026-08-11 22:37:07 +08:00
CallMeR a41bd56bc3 更新截图 2026-08-10 11:53:24 +08:00
CallMeR f8cc6a7689 更新文案描述 2026-08-10 11:39:07 +08:00
CallMeR 966660a77f 更新文案描述 2026-08-10 11:38:49 +08:00
CallMeR 7ebf3c80c8 更新截图 2026-08-10 01:01:59 +08:00
CallMeR fbd1e44d11 更新截图 2026-08-10 00:16:31 +08:00
CallMeR f991ec8525 更新文案描述 2026-08-09 02:47:40 +08:00
CallMeR 996959f740 更新系统配置 2026-08-07 17:33:47 +08:00
CallMeR ed7f9c5fc9 精简 TS 防火墙配置 2026-08-04 17:31:19 +08:00
CallMeR 730225be93 更新 SmartDNS 配置 2026-07-31 00:56:53 +08:00
CallMeR e29dc62978 修订 SmartDNS 更新命令 2026-07-27 01:08:26 +08:00
54 changed files with 191 additions and 156 deletions
+11 -11
View File
@@ -114,23 +114,23 @@ Microsoft 官方终端工具,可以在 Github 平台或 Microsoft 应用商店
使用 `方向键` 选择第一项 `Install Proxmox VE (Graphical)` 图形化安装界面,按键盘 `Enter` 进入下一步骤。 使用 `方向键` 选择第一项 `Install Proxmox VE (Graphical)` 图形化安装界面,按键盘 `Enter` 进入下一步骤。
![PVE安装选项](img/p01/pve_option.jpeg) ![PVE安装选项](img/p01/pve_option.jpg)
设备将继续跑码,直到出现最终用户许可协议 EULA ,按键盘组合键 `ALT + N ` 进入下一步骤。 设备将继续跑码,直到出现最终用户许可协议 EULA ,按键盘组合键 `ALT + N ` 进入下一步骤。
![PVE用户协议](img/p01/pve_eula.jpeg) ![PVE用户协议](img/p01/pve_eula.jpg)
### 1.3. PVE 硬盘选项 ### 1.3. PVE 硬盘选项
此时会出现 `Target Harddisk` 选项,会显示出设备中存在的硬盘列表,可通过下拉框选择安装 PVE 的目标硬盘。 此时会出现 `Target Harddisk` 选项,会显示出设备中存在的硬盘列表,可通过下拉框选择安装 PVE 的目标硬盘。
![PVE选择安装硬盘](img/p01/pve_hd_choose.jpeg) ![PVE选择安装硬盘](img/p01/pve_hd_choose.jpg)
点击硬盘列表右侧的 `Options` ,对 PVE 的硬盘安装参数进行一些调整。 点击硬盘列表右侧的 `Options` ,对 PVE 的硬盘安装参数进行一些调整。
推荐将 `Filesystem` 也就是硬盘的文件系统,设置成 `xfs` 推荐将 `Filesystem` 也就是硬盘的文件系统,设置成 `xfs`
![PVE文件系统](img/p01/pve_hd_fs.jpeg) ![PVE文件系统](img/p01/pve_hd_fs.jpg)
### 1.4. PVE 时区选项 ### 1.4. PVE 时区选项
@@ -138,7 +138,7 @@ Microsoft 官方终端工具,可以在 Github 平台或 Microsoft 应用商店
`Contry` 处手动输入 `China` ,下方的 `Time zone` 将自动变更为 `Asia/Shanghai` `Contry` 处手动输入 `China` ,下方的 `Time zone` 将自动变更为 `Asia/Shanghai`
![PVE时区](img/p01/pve_timezone.jpeg) ![PVE时区](img/p01/pve_timezone.jpg)
### 1.5. PVE 账户与邮箱 ### 1.5. PVE 账户与邮箱
@@ -146,7 +146,7 @@ PVE 为最关键的虚拟化层,建议使用强密码,包含大小写字母
`Email` 必须为一个 “合法” 的邮箱地址,不然系统会判定邮箱地址不合法并拒绝继续安装。 `Email` 必须为一个 “合法” 的邮箱地址,不然系统会判定邮箱地址不合法并拒绝继续安装。
![PVE邮箱设置](img/p01/pve_email.jpeg) ![PVE邮箱设置](img/p01/pve_email.jpg)
### 1.6. PVE 网络设置 ### 1.6. PVE 网络设置
@@ -154,7 +154,7 @@ PVE 为最关键的虚拟化层,建议使用强密码,包含大小写字母
而某些设备,其物理网口顺序与该页面显示的网口顺序 **不一致** ,因此保持默认设置即可。 而某些设备,其物理网口顺序与该页面显示的网口顺序 **不一致** ,因此保持默认设置即可。
![PVE管理网口设置](img/p01/pve_eth.jpeg) ![PVE管理网口设置](img/p01/pve_eth.jpg)
FQDN 为 PVE 的域,PVE 将使用 FQDN 中的二级域名作为其主机名。 FQDN 为 PVE 的域,PVE 将使用 FQDN 中的二级域名作为其主机名。
@@ -173,17 +173,17 @@ PVE 安装完成后,可通过其提供的 Web 管理界面,进一步调整
|Gateway|`172.16.1.1`|设置 PVE IPv4 网关| |Gateway|`172.16.1.1`|设置 PVE IPv4 网关|
|DNS Server|`172.16.1.1`|设置 PVE IPv4 DNS | |DNS Server|`172.16.1.1`|设置 PVE IPv4 DNS |
![PVE管理IP地址](img/p01/pve_ip.jpeg) ![PVE管理IP地址](img/p01/pve_ip.jpg)
### 1.7. PVE 参数确认 ### 1.7. PVE 参数确认
该页面会显示当前 PVE 的安装配置总览,确认无误后即可开始安装。 该页面会显示当前 PVE 的安装配置总览,确认无误后即可开始安装。
![PVE安装确认](img/p01/pve_install_confirm.jpeg) ![PVE安装确认](img/p01/pve_install_confirm.jpg)
安装完成后,PVE 会告知用户登录的 `IP 地址``端口` 安装完成后,PVE 会告知用户登录的 `IP 地址``端口`
![PVE安装完成](img/p01/pve_install_finish.jpeg) ![PVE安装完成](img/p01/pve_install_finish.jpg)
## 2. PVE 安装后检查 ## 2. PVE 安装后检查
@@ -209,7 +209,7 @@ $ cat /etc/os-release
此处显示出 PVE 底层使用的是 Debian 的系统,代号为 `trixie` ,该代号后续会使用到。 此处显示出 PVE 底层使用的是 Debian 的系统,代号为 `trixie` ,该代号后续会使用到。
![PVE系统信息](img/p01/pve_sys_info.jpeg) ![PVE系统信息](img/p01/pve_sys_info.jpg)
至此 PVE 的安装步骤已经完成。 至此 PVE 的安装步骤已经完成。
+6 -9
View File
@@ -2,7 +2,7 @@
在上一篇文章 [01.PVE系统安装](./01.PVE系统安装.md) 中,从刚装好的 PVE 系统中获取了系统的一些参数。 在上一篇文章 [01.PVE系统安装](./01.PVE系统安装.md) 中,从刚装好的 PVE 系统中获取了系统的一些参数。
![PVE系统信息](img/p01/pve_sys_info.jpeg) ![PVE系统信息](img/p01/pve_sys_info.jpg)
此处显示出 PVE 底层使用的是 Debian 的系统,代号为 `trixie` 此处显示出 PVE 底层使用的是 Debian 的系统,代号为 `trixie`
@@ -32,11 +32,10 @@ Components: main contrib non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
``` ```
这里将使用 [中国科技大(USTC](http://mirrors.ustc.edu.cn/help/proxmox.html) 的镜像仓库进行替换,使用如下命令。 这里将使用 [中国科技大(USTC](http://mirrors.ustc.edu.cn/help/proxmox.html) 的镜像仓库进行替换,执行以下命令。
```bash ```bash
## 配置 PVE 系统默认软件源脚本 ## 配置 PVE 系统默认软件源脚本
$ cat > /etc/apt/sources.list.d/debian.sources <<EOF $ cat > /etc/apt/sources.list.d/debian.sources <<EOF
Types: deb Types: deb
URIs: https://mirrors.ustc.edu.cn/debian URIs: https://mirrors.ustc.edu.cn/debian
@@ -62,7 +61,6 @@ EOF
```bash ```bash
## 配置 PVE 系统免订阅软件源脚本 ## 配置 PVE 系统免订阅软件源脚本
$ cat > /etc/apt/sources.list.d/pve-no-subscription.sources <<EOF $ cat > /etc/apt/sources.list.d/pve-no-subscription.sources <<EOF
Types: deb Types: deb
URIs: https://mirrors.ustc.edu.cn/proxmox/debian/pve URIs: https://mirrors.ustc.edu.cn/proxmox/debian/pve
@@ -80,7 +78,6 @@ EOF
```bash ```bash
## 配置 PVE Ceph 免订阅软件源脚本 ## 配置 PVE Ceph 免订阅软件源脚本
$ if [ -f /etc/apt/sources.list.d/ceph.sources ]; then $ if [ -f /etc/apt/sources.list.d/ceph.sources ]; then
CEPH_CODENAME=`ceph -v | grep ceph | awk '{print $(NF-1)}'` CEPH_CODENAME=`ceph -v | grep ceph | awk '{print $(NF-1)}'`
source /etc/os-release source /etc/os-release
@@ -161,7 +158,7 @@ $ apt full-upgrade
$ apt update $ apt update
## 安装系统软件 ## 安装系统软件
$ apt install btop lm-sensors curl tmux neovim unzip unattended-upgrades powermgmt-base sshguard knot-dnsutils $ apt install btop lm-sensors curl tmux neovim unattended-upgrades powermgmt-base sshguard knot-dnsutils
## 安装 CPU 调度调整工具 ## 安装 CPU 调度调整工具
$ apt install linux-cpupower $ apt install linux-cpupower
@@ -216,7 +213,7 @@ $ journalctl --update-catalog
接下来将修改 PVE 网络配置,在修改完成前, **请不要点击 “应用配置”** ,否则会导致 PVE 无法访问。 接下来将修改 PVE 网络配置,在修改完成前, **请不要点击 “应用配置”** ,否则会导致 PVE 无法访问。
![PVE默认网桥](img/p02/pve_net_default.jpeg) ![PVE默认网桥](img/p02/pve_net_default.jpg)
### 3.1.修改 vmbr0 ### 3.1.修改 vmbr0
@@ -232,7 +229,7 @@ $ journalctl --update-catalog
点击左上角的 `创建` 选项,选择 `Linux Bridge` 点击左上角的 `创建` 选项,选择 `Linux Bridge`
![创建物理接口网桥](img/p02/pve_br_create.jpeg) ![创建物理接口网桥](img/p02/pve_br_create.jpg)
桥接端口填写顺序的第二个网卡名称,演示中为 `nic1` ,在备注处填写 `lan1` ,并点击 `创建` 桥接端口填写顺序的第二个网卡名称,演示中为 `nic1` ,在备注处填写 `lan1` ,并点击 `创建`
@@ -274,7 +271,7 @@ $ journalctl --update-catalog
在 PVE 内部网络设置完成后,将如图所示。 在 PVE 内部网络设置完成后,将如图所示。
![PVE网桥最终设置显示](img/p02/pve_net_preview.jpeg) ![PVE网桥最终设置显示](img/p02/pve_net_preview.jpg)
## 4.配置 PVE DNS ## 4.配置 PVE DNS
+31 -21
View File
@@ -24,6 +24,20 @@ 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 update-alternatives: using /usr/bin/nvim to provide /usr/bin/editor (editor) in manual mode
``` ```
若需完全禁用 `neovim` 鼠标功能;即关闭所有鼠标交互,右键行为完全交给终端 / 控制台处理,需执行以下命令。
```bash
## 创建 nvim 配置目录
$ mkdir -p /etc/xdg/nvim
## 配置 nvim 鼠标交互行为脚本
$ tee /etc/xdg/nvim/sysinit.vim << 'EOF'
set mouse=
EOF
```
## 1.系统时区 ## 1.系统时区
如果在安装 PVE 系统时选错了时区,导致系统时间和北京时间不一致,可以执行以下命令修正。 如果在安装 PVE 系统时选错了时区,导致系统时间和北京时间不一致,可以执行以下命令修正。
@@ -210,15 +224,13 @@ WantedBy=multi-user.target
$ systemctl daemon-reload $ systemctl daemon-reload
``` ```
执行以下命令让 `cpupower` 服务开机自启 执行以下命令让 `cpupower` 服务立即启动并置为开机自启状态
```bash ```bash
## 设置 cpupower 服务开机自启 ## 设置 cpupower 服务开机自启
$ systemctl enable cpupower.service $ systemctl enable --now cpupower.service
``` ```
修改完成后,需重启 PVE 服务器,并再次查看 CPU 调度器,检验配置文件是否生效。
这里提供两个额外命令,方便实时查看 CPU 当前频率和温度状况。 这里提供两个额外命令,方便实时查看 CPU 当前频率和温度状况。
```bash ```bash
@@ -248,7 +260,7 @@ $ crontab -e
```bash ```bash
## 定时任务配置项 ## 定时任务配置项
30 2 1,16 * * /usr/sbin/reboot 30 2 1,16 * * /usr/sbin/shutdown --reboot now
``` ```
@@ -258,7 +270,7 @@ $ crontab -e
配置系统自动更新之前,需检查系统当前定时器状态。 配置系统自动更新之前,需检查系统当前定时器状态。
后续将手动调整该定时器的时间,使其每 `5` 天的 `01:30` 进行触发。 后续将手动调整该定时器的时间,使其每 `10` 天的 `01:30` 进行触发。
```bash ```bash
## 检查系统定时器 ## 检查系统定时器
@@ -267,12 +279,12 @@ $ systemctl status apt-daily-upgrade.timer
#### 系统定时器示例输出 #### 系统定时器示例输出
● apt-daily-upgrade.timer - Daily apt upgrade and clean activities ● apt-daily-upgrade.timer - Daily apt upgrade and clean activities
Loaded: loaded (/usr/lib/systemd/system/apt-daily-upgrade.timer; enabled; preset: enabled) 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 Active: active (waiting) since Mon 2026-08-10 09:51:05 CST; 27min ago
Invocation: 26ebb62a4f6545998522fff8c4104b3e Invocation: edb5962fda4c4a8395cb2c04c736db45
Trigger: Thu 2025-08-28 06:14:37 CST; 14h left Trigger: Tue 2026-08-11 06:21:38 CST; 20h left
Triggers: ● apt-daily-upgrade.service Triggers: ● apt-daily-upgrade.service
Aug 27 13:41:10 node01 systemd[1]: Started apt-daily-upgrade.timer - Daily apt upgrade and clean activities. Aug 10 09:51:05 node01 systemd[1]: Started apt-daily-upgrade.timer - Daily apt upgrade and clean activities.
``` ```
### 4.2.配置更新策略 ### 4.2.配置更新策略
@@ -289,25 +301,22 @@ $ dpkg-reconfigure -plow unattended-upgrades
<Yes> <Yes>
``` ```
进一步调整 `20auto-upgrades` 配置文件。 开始调整 `20auto-upgrades` 配置文件。
```bash ```bash
## 进入 apt 的配置目录
$ cd /etc/apt/apt.conf.d
## 编辑 20auto-upgrades 配置文件 ## 编辑 20auto-upgrades 配置文件
$ editor /etc/apt/apt.conf.d/20auto-upgrades $ editor /etc/apt/apt.conf.d/20auto-upgrades
``` ```
清空当前全部配置项后,输入以下内容,并保存。 清空当前全部配置项后,输入以下内容,并保存。
配置文件中,用来控制更新周期的参数为 `APT::Periodic::Unattended-Upgrade` `5` 表示更新周期为 `5` 天。 配置文件中,用来控制更新周期的参数为 `APT::Periodic::Unattended-Upgrade` `10` 表示更新周期为 `10` 天。
```bash ```bash
## 系统更新周期配置项 ## 系统更新周期配置项
APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "5"; APT::Periodic::Unattended-Upgrade "10";
APT::Periodic::AutocleanInterval "1"; APT::Periodic::AutocleanInterval "1";
APT::Periodic::CleanInterval "1"; APT::Periodic::CleanInterval "1";
@@ -408,13 +417,14 @@ $ systemctl status apt-daily-upgrade.timer
Loaded: loaded (/usr/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 Drop-In: /etc/systemd/system/apt-daily-upgrade.timer.d
└─override.conf └─override.conf
Active: active (waiting) since Wed 2025-08-27 15:23:29 CST; 8s ago Active: active (waiting) since Mon 2026-08-10 10:35:09 CST; 5s ago
Invocation: e38354f06d284894b084a52e1f19af73 Invocation: e73c9dd167cc4814836a1da4dab015db
Trigger: Thu 2025-08-28 01:30:00 CST; 10h left Trigger: Tue 2026-08-11 01:30:00 CST; 14h left
Triggers: ● apt-daily-upgrade.service Triggers: ● apt-daily-upgrade.service
Aug 27 15:23:29 node01 systemd[1]: Stopping apt-daily-upgrade.timer - Daily apt upgrade and clean activities... Aug 10 10:35:09 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. Aug 10 10:35:09 node01 systemd[1]: Stopped apt-daily-upgrade.timer - Daily apt upgrade and clean activities.
Aug 10 10:35:09 node01 systemd[1]: Started apt-daily-upgrade.timer - Daily apt upgrade and clean activities.
``` ```
## 5.硬件直通 ## 5.硬件直通
+1 -1
View File
@@ -293,7 +293,7 @@ IPv6 使用 `静态` 地址后,并不影响虚拟机通过主路由获取 IPv6
- 系统: Debian 13 - 系统: Debian 13
- 用途: 内网 DNS 服务器 ( 模板 ) - 用途: 内网服务器 ( 模板 )
- 自启: 否 - 自启: 否
+34 -27
View File
@@ -8,7 +8,7 @@
因为 Debian 的云镜像默认使用 SSH 秘钥登录,因此切换到左侧菜单的 `控制台` 进行登录。 因为 Debian 的云镜像默认使用 SSH 秘钥登录,因此切换到左侧菜单的 `控制台` 进行登录。
![登录Debian操作系统](img/p05/os_login.jpeg) ![登录Debian操作系统](img/p05/os_login.jpg)
在虚拟机的命令行界面,使用 `vim` 编辑器编辑 `sshd` 服务的配置文件,执行以下命令。 在虚拟机的命令行界面,使用 `vim` 编辑器编辑 `sshd` 服务的配置文件,执行以下命令。
@@ -53,7 +53,6 @@ $ sudo systemctl restart ssh.service
```bash ```bash
## 配置 Debian 系统默认软件源脚本 ## 配置 Debian 系统默认软件源脚本
$ sudo bash -c 'cat > /etc/apt/sources.list.d/debian.sources <<EOF $ sudo bash -c 'cat > /etc/apt/sources.list.d/debian.sources <<EOF
Types: deb Types: deb
URIs: https://mirrors.ustc.edu.cn/debian URIs: https://mirrors.ustc.edu.cn/debian
@@ -162,6 +161,20 @@ 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 update-alternatives: using /usr/bin/nvim to provide /usr/bin/editor (editor) in manual mode
``` ```
若需完全禁用 `neovim` 鼠标功能;即关闭所有鼠标交互,右键行为完全交给终端 / 控制台处理,需执行以下命令。
```bash
## 创建 nvim 配置目录
$ sudo mkdir -p /etc/xdg/nvim
## 配置 nvim 鼠标交互行为脚本
$ sudo tee /etc/xdg/nvim/sysinit.vim << 'EOF'
set mouse=
EOF
```
### 1.6.调整内核参数 ### 1.6.调整内核参数
由于该虚拟机将作为内网 DNS 服务器的克隆模板,需调整内核参数以优化性能。 由于该虚拟机将作为内网 DNS 服务器的克隆模板,需调整内核参数以优化性能。
@@ -177,7 +190,7 @@ $ sudo editor /etc/sysctl.d/99-sysctl.conf
```bash ```bash
# This configuration file is customized by fox, # This configuration file is customized by fox,
# Optimize sysctl parameters for local DNS server. # Optimize sysctl parameters for local TPL server.
kernel.panic = 20 kernel.panic = 20
kernel.panic_on_oops = 1 kernel.panic_on_oops = 1
@@ -226,7 +239,7 @@ $ sudo timedatectl set-timezone Asia/Shanghai
$ date -R $ date -R
#### 系统时间示例输出 #### 系统时间示例输出
Wed, 27 Aug 2025 17:02:17 +0800 Mon, 10 Aug 2026 11:23:56 +0800
``` ```
Debian 云镜像默认使用 `systemd-timesyncd.service` 同步时间,且需要调整为使用国内 NTP 服务器。 Debian 云镜像默认使用 `systemd-timesyncd.service` 同步时间,且需要调整为使用国内 NTP 服务器。
@@ -268,21 +281,21 @@ $ sudo systemctl status systemd-timesyncd.service
#### NTP 服务示例输出 #### NTP 服务示例输出
● systemd-timesyncd.service - Network Time Synchronization ● systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/usr/lib/systemd/system/systemd-timesyncd.service; enabled; preset: enabled) 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 Active: active (running) since Mon 2026-08-10 11:24:43 CST; 5s ago
Invocation: 7dcb974725ac43638a4ae3df51644f84 Invocation: 95cd4555913e45d8a7235347cf3d571a
Docs: man:systemd-timesyncd.service(8) Docs: man:systemd-timesyncd.service(8)
Main PID: 4540 (systemd-timesyn) Main PID: 6516 (systemd-timesyn)
Status: "Contacted time server 203.107.6.88:123 (ntp.aliyun.com)." Status: "Contacted time server 203.107.6.88:123 (ntp.aliyun.com)."
Tasks: 2 (limit: 2317) Tasks: 2 (limit: 2189)
Memory: 1.5M (peak: 2.2M) Memory: 1.6M (peak: 2.3M)
CPU: 261ms CPU: 136ms
CGroup: /system.slice/systemd-timesyncd.service CGroup: /system.slice/systemd-timesyncd.service
└─4540 /usr/lib/systemd/systemd-timesyncd └─6516 /usr/lib/systemd/systemd-timesyncd
Aug 27 17:03:12 DNST01 systemd[1]: Starting systemd-timesyncd.service - Network Time Synchronization... Aug 10 11:24:43 TPL01 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 10 11:24:43 TPL01 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 10 11:24:43 TPL01 systemd-timesyncd[6516]: 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. Aug 10 11:24:43 TPL01 systemd-timesyncd[6516]: Initial clock synchronization to Mon 2026-08-10 11:24:43.569158 CST.
``` ```
### 1.8.配置自动更新 ### 1.8.配置自动更新
@@ -306,7 +319,7 @@ $ sudo dpkg-reconfigure -plow unattended-upgrades
<Yes> <Yes>
``` ```
进一步调整 `20auto-upgrades` 配置文件。 开始调整 `20auto-upgrades` 配置文件。
```bash ```bash
## 编辑 20auto-upgrades 配置文件 ## 编辑 20auto-upgrades 配置文件
@@ -334,7 +347,7 @@ APT::Periodic::CleanInterval "1";
$ sudo editor /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) 以便对比。 因为该配置文件很长,完整的配置文件可查看 [debian_tpl_50unattended_upgrades.conf](./src/debian/debian_tpl_50unattended_upgrades.conf) 以便对比。
```bash ```bash
## 删除以下行前面的注释符 // ,代表启用 ## 删除以下行前面的注释符 // ,代表启用
@@ -405,7 +418,7 @@ $ sudo crontab -e
```bash ```bash
## 定时任务配置项 ## 定时任务配置项
30 4 8,24 * * /usr/sbin/reboot 30 4 8,24 * * /usr/sbin/shutdown --reboot now
``` ```
@@ -420,20 +433,14 @@ $ sudo bash -c 'apt clean && apt autoclean && apt autoremove --purge'
## 清理系统缓存 ## 清理系统缓存
$ sudo bash -c 'find /var/cache/apt/ /var/lib/apt/lists/ /tmp/ -type f -print -delete' $ sudo bash -c 'find /var/cache/apt/ /var/lib/apt/lists/ /tmp/ -type f -print -delete'
## 清理 SmartDNS 缓存(按需)
$ sudo bash -c 'find /var/cache/smartdns/ /var/lib/smartdns/ -type f -print -delete'
## 重置机器标识符 ## 重置机器标识符
$ sudo truncate -s 0 /etc/machine-id /var/lib/dbus/machine-id $ sudo truncate -s 0 /etc/machine-id /var/lib/dbus/machine-id
## 清理系统日志 ## 清理系统日志
$ sudo bash -c 'find /var/log/ -type f -print -delete' $ sudo bash -c 'find /var/log/ -type f -print -delete'
## 清理命令历史记录文件 ## 清理命令历史记录文件并关闭系统
$ rm -rvf ~/.bash_history ~/.zsh_history ~/.zcompdump* && history -c $ rm -rvf ~/.bash_history ~/.zsh_history ~/.zcompdump* && history -c && sudo shutdown now
## 关闭系统
$ sudo shutdown now
``` ```
## 2.虚拟机转为模板 ## 2.虚拟机转为模板
@@ -446,7 +453,7 @@ $ sudo shutdown now
若系统配置存在问题,仅能在该模板克隆的新虚拟机中修改,或删除现有模板并重新制作。 若系统配置存在问题,仅能在该模板克隆的新虚拟机中修改,或删除现有模板并重新制作。
![虚拟机转模板](img/p05/vm_to_template.jpeg) ![虚拟机转模板](img/p05/vm_to_template.jpg)
至此 Debian 虚拟机模板制作完成。 至此 Debian 虚拟机模板制作完成。
+29 -10
View File
@@ -6,7 +6,7 @@
鼠标 **右键单击** 虚拟机模板,在弹出的菜单中选择 `克隆` 鼠标 **右键单击** 虚拟机模板,在弹出的菜单中选择 `克隆`
![克隆虚拟机](img/p06/vm_clone.jpeg) ![克隆虚拟机](img/p06/vm_clone.jpg)
在弹出的虚拟机克隆对话框中,根据实际情况及下方表格内容,修改虚拟机参数。 在弹出的虚拟机克隆对话框中,根据实际情况及下方表格内容,修改虚拟机参数。
@@ -210,7 +210,7 @@ $ sudo systemctl stop dnsmasq.service
```bash ```bash
## 下载 SmartDNS 安装包 ## 下载 SmartDNS 安装包
$ curl -LR https://github.com/pymumu/smartdns/releases/download/Release48.2/smartdns.1.2026.06.28-1614.x86_64-linux-all.tar.gz | tar -xz -C /tmp $ curl -LR https://github.com/pymumu/smartdns/releases/download/Release48.4/smartdns.1.2026.08.05-0921.x86_64-linux-all.tar.gz | tar -xz -C /tmp
## 安装 SmartDNS ## 安装 SmartDNS
$ sudo /tmp/smartdns/install -i $ sudo /tmp/smartdns/install -i
@@ -220,7 +220,7 @@ $ sudo /tmp/smartdns/install -i
```bash ```bash
## 升级 SmartDNS ## 升级 SmartDNS
$ sudo ./install -U $ sudo /tmp/smartdns/install -U
``` ```
修改 `SmartDNS` 配置之前,需检查 `smartdns.service` 服务状态,确保该服务开机自启。 修改 `SmartDNS` 配置之前,需检查 `smartdns.service` 服务状态,确保该服务开机自启。
@@ -253,16 +253,16 @@ $ sudo curl -LR -o /etc/smartdns.d/anti-ad.smartdns.conf https://anti-ad.net/ant
```bash ```bash
## 下载加速规则安装脚本 ## 下载加速规则安装脚本
$ sudo curl -LR -o /usr/local/bin/smartdns-plugin.sh https://gitee.com/callmer/smartdns_china_list_installer/raw/main/smartdns_plugin.sh $ sudo curl -LR -o /usr/local/bin/smartdns-cnlist https://gitee.com/callmer/smartdns_china_list_installer/raw/main/smartdns-china-list-installer.sh
## 设置脚本可执行权限 ## 设置脚本可执行权限
$ sudo chmod +x /usr/local/bin/smartdns-plugin.sh $ sudo chmod +x /usr/local/bin/smartdns-cnlist
## 设置脚本文件防篡改 ## 设置脚本文件防篡改
$ sudo chattr +i /usr/local/bin/smartdns-plugin.sh $ sudo chattr +i /usr/local/bin/smartdns-cnlist
## 执行脚本 ## 执行脚本
$ sudo /usr/local/bin/smartdns-plugin.sh $ sudo /usr/local/bin/smartdns-cnlist
``` ```
### 6.2.定时任务 ### 6.2.定时任务
@@ -292,7 +292,7 @@ $ sudo crontab -e
20 9 * * * /usr/bin/curl --retry-connrefused --retry 5 --retry-delay 5 --retry-max-time 60 -fsSLR -o /etc/smartdns.d/anti-ad.smartdns.conf https://anti-ad.net/anti-ad-for-smartdns.conf 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/local/bin/smartdns-plugin.sh 30 9 * * * /usr/local/bin/smartdns-cnlist
``` ```
### 6.3. SmartDNS 主配置 ### 6.3. SmartDNS 主配置
@@ -392,7 +392,7 @@ server-tls dns.alidns.com
server-https https://doh.pub/dns-query server-https https://doh.pub/dns-query
server-https https://dns.alidns.com/dns-query server-https https://dns.alidns.com/dns-query
server-quic dns.alidns.com -fallback server-h3 h3://dns.alidns.com/dns-query -fallback
server-https https://doh.360.cn/dns-query -fallback server-https https://doh.360.cn/dns-query -fallback
``` ```
@@ -482,5 +482,24 @@ server=127.0.0.1#6053
``` ```
至此,新虚拟机已配置完成,重启后即可作为内网 DNS 服务器使用。 ## 7.清理系统
内网 DNS 服务器已部署配置完毕,正式投产前,可按需对系统进行清理优化。
```bash
## 清理系统软件包
$ sudo bash -c 'apt clean && apt autoclean && apt autoremove --purge'
## 清理系统缓存
$ sudo bash -c 'find /var/cache/apt/ /var/lib/apt/lists/ /tmp/ -type f -print -delete'
## 清理 SmartDNS 缓存、持久化数据文件(WebUI 自定义密码存储于此文件)
$ sudo bash -c 'find /var/cache/smartdns/ /var/lib/smartdns/ -type f -print -delete'
## 清理系统日志
$ sudo bash -c 'find /var/log/ -type f -print -delete'
## 清理命令历史记录文件并关闭系统
$ rm -rvf ~/.bash_history ~/.zsh_history ~/.zcompdump* && history -c && sudo shutdown now
```
+29 -17
View File
@@ -56,7 +56,6 @@ $ sudo systemctl restart ssh.service
```bash ```bash
## 配置 Debian 系统默认软件源脚本 ## 配置 Debian 系统默认软件源脚本
$ sudo bash -c 'cat > /etc/apt/sources.list.d/debian.sources <<EOF $ sudo bash -c 'cat > /etc/apt/sources.list.d/debian.sources <<EOF
Types: deb Types: deb
URIs: https://mirrors.ustc.edu.cn/debian URIs: https://mirrors.ustc.edu.cn/debian
@@ -112,7 +111,7 @@ $ sudo apt install qemu-guest-agent btop curl tmux logrotate cron neovim zsh git
$ sudo apt install unattended-upgrades powermgmt-base $ sudo apt install unattended-upgrades powermgmt-base
## 安装网络工具 ## 安装网络工具
$ sudo apt install ethtool dnsmasq conntrack nftables sshguard lsof knot-dnsutils $ sudo apt install nftables sshguard lsof knot-dnsutils ethtool dnsmasq conntrack
## 安装 TS ## 安装 TS
$ curl -fsSL https://tailscale.com/install.sh | sh $ curl -fsSL https://tailscale.com/install.sh | sh
@@ -168,6 +167,20 @@ 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 update-alternatives: using /usr/bin/nvim to provide /usr/bin/editor (editor) in manual mode
``` ```
若需完全禁用 `neovim` 鼠标功能;即关闭所有鼠标交互,右键行为完全交给终端 / 控制台处理,需执行以下命令。
```bash
## 创建 nvim 配置目录
$ sudo mkdir -p /etc/xdg/nvim
## 配置 nvim 鼠标交互行为脚本
$ sudo tee /etc/xdg/nvim/sysinit.vim << 'EOF'
set mouse=
EOF
```
### 1.6.调整内核模块 ### 1.6.调整内核模块
编辑 **内核模块** 配置文件,执行以下命令。 编辑 **内核模块** 配置文件,执行以下命令。
@@ -327,7 +340,7 @@ $ sudo dpkg-reconfigure -plow unattended-upgrades
<Yes> <Yes>
``` ```
进一步调整 `20auto-upgrades` 配置文件。 开始调整 `20auto-upgrades` 配置文件。
```bash ```bash
## 编辑 20auto-upgrades 配置文件 ## 编辑 20auto-upgrades 配置文件
@@ -336,13 +349,13 @@ $ sudo editor /etc/apt/apt.conf.d/20auto-upgrades
清空当前全部配置项后,输入以下内容,并保存。 清空当前全部配置项后,输入以下内容,并保存。
配置文件中,用来控制更新周期的参数为 `APT::Periodic::Unattended-Upgrade` `7` 表示更新周期为 `7` 天。 配置文件中,用来控制更新周期的参数为 `APT::Periodic::Unattended-Upgrade` `5` 表示更新周期为 `5` 天。
```bash ```bash
## 系统更新周期配置项 ## 系统更新周期配置项
APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "7"; APT::Periodic::Unattended-Upgrade "5";
APT::Periodic::AutocleanInterval "1"; APT::Periodic::AutocleanInterval "1";
APT::Periodic::CleanInterval "1"; APT::Periodic::CleanInterval "1";
@@ -425,18 +438,13 @@ $ sudo systemctl status nftables.service
$ sudo systemctl enable nftables.service $ sudo systemctl enable nftables.service
``` ```
修改 `nftables` 配置文件,执行以下命令 由于防火墙规则内容较多,请打开文件 [debian_ts_nftables.conf](./src/debian/debian_ts_nftables.conf) ,复制全文内容,完整替换 `nftables` 配置文件中的现有配置
```bash ```bash
## 备份 nftables 配置文件 ## 编辑 nftables 配置文件
$ sudo mv /etc/nftables.conf /etc/nftables.conf.bak
## 创建新的 nftables 配置文件
$ sudo editor /etc/nftables.conf $ sudo editor /etc/nftables.conf
``` ```
由于防火墙配置文件很长,因此请查阅文件 [debian_ts_nftables.conf](./src/debian/debian_ts_nftables.conf) 进行复制。
配置完成后,需重启 `nftables.service` 服务。 配置完成后,需重启 `nftables.service` 服务。
```bash ```bash
@@ -594,13 +602,17 @@ $ sudo systemctl restart dnsmasq.service
```bash ```bash
## 创建 tailscale-nic-optim 优化脚本 ## 创建 tailscale-nic-optim 优化脚本
$ sudo editor /usr/local/bin/tailscale-nic-optim.sh $ sudo editor /usr/local/bin/tailscale-nic-optim
``` ```
在脚本文件中输入以下内容,并保存。 在脚本文件中输入以下内容,并保存。
```bash ```bash
#!/bin/sh #!/bin/sh
#
# This script is customized by fox,
# Optimize NIC offload parameters for local TS server.
#
ETHTOOL_PATH=$(command -v ethtool) ETHTOOL_PATH=$(command -v ethtool)
@@ -634,10 +646,10 @@ fi
```bash ```bash
## 设置脚本可执行权限 ## 设置脚本可执行权限
$ sudo chmod +x /usr/local/bin/tailscale-nic-optim.sh $ sudo chmod +x /usr/local/bin/tailscale-nic-optim
## 设置脚本文件防篡改 ## 设置脚本文件防篡改
$ sudo chattr +i /usr/local/bin/tailscale-nic-optim.sh $ sudo chattr +i /usr/local/bin/tailscale-nic-optim
``` ```
进一步创建 `tailscale-nic-optim` 服务配置文件,以满足系统自动化设置需求。 进一步创建 `tailscale-nic-optim` 服务配置文件,以满足系统自动化设置需求。
@@ -662,7 +674,7 @@ Before=tailscaled.service
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=/usr/local/bin/tailscale-nic-optim.sh ExecStart=/usr/local/bin/tailscale-nic-optim
RemainAfterExit=yes RemainAfterExit=yes
StandardOutput=journal StandardOutput=journal
@@ -678,7 +690,7 @@ WantedBy=multi-user.target
$ sudo systemctl daemon-reload $ sudo systemctl daemon-reload
``` ```
执行以下命令让 `tailscale-nic-optim` 服务开机自启 执行以下命令让 `tailscale-nic-optim` 服务立即启动并置为开机自启状态
```bash ```bash
## 设置 tailscale-nic-optim 服务开机自启 ## 设置 tailscale-nic-optim 服务开机自启
Binary file not shown.

Before

Width:  |  Height:  |  Size: 261 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 544 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 310 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 828 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 588 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 156 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 273 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 307 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 580 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 266 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 603 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 586 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 470 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 199 KiB

After

Width:  |  Height:  |  Size: 199 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 KiB

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

+1 -1
View File
@@ -58,6 +58,6 @@ server-tls dns.alidns.com
server-https https://doh.pub/dns-query server-https https://doh.pub/dns-query
server-https https://dns.alidns.com/dns-query server-https https://dns.alidns.com/dns-query
server-quic dns.alidns.com -fallback server-h3 h3://dns.alidns.com/dns-query -fallback
server-https https://doh.360.cn/dns-query -fallback server-https https://doh.360.cn/dns-query -fallback
+1 -1
View File
@@ -10,5 +10,5 @@
20 9 * * * /usr/bin/curl --retry-connrefused --retry 5 --retry-delay 5 --retry-max-time 60 -fsSLR -o /etc/smartdns.d/anti-ad.smartdns.conf https://anti-ad.net/anti-ad-for-smartdns.conf 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/local/bin/smartdns-plugin.sh 30 9 * * * /usr/local/bin/smartdns-cnlist
@@ -1,4 +1,9 @@
#!/bin/sh #!/bin/sh
#
# SmartDNS China List Installer
# Install and update China domain rules for SmartDNS.
#
set -e set -e
WORKDIR="$(mktemp -d)" WORKDIR="$(mktemp -d)"
@@ -1,5 +1,5 @@
# This configuration file is customized by fox, # This configuration file is customized by fox,
# Optimize sysctl parameters for local DNS server. # Optimize sysctl parameters for local TPL server.
kernel.panic = 20 kernel.panic = 20
kernel.panic_on_oops = 1 kernel.panic_on_oops = 1
+1 -1
View File
@@ -1,5 +1,5 @@
APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "7"; APT::Periodic::Unattended-Upgrade "5";
APT::Periodic::AutocleanInterval "1"; APT::Periodic::AutocleanInterval "1";
APT::Periodic::CleanInterval "1"; APT::Periodic::CleanInterval "1";
+29 -54
View File
@@ -1,7 +1,8 @@
#!/usr/sbin/nft -f #!/usr/sbin/nft -f
#
# This configuration file is customized by fox, # This configuration file is customized by fox,
# Optimize nftables rules for local TS server. # Optimize nftables rules for local TS server.
#
table inet router table inet router
flush table inet router flush table inet router
@@ -26,26 +27,25 @@ table inet router {
chain input { chain input {
type filter hook input priority filter; policy drop; type filter hook input priority filter; policy drop;
iif "lo" accept comment "defconf: accept traffic from loopback" iif "lo" accept comment "defconf: accept traffic from loopback"
ct state vmap { established : accept, related : accept } comment "defconf: handle inbound flows" ct state established,related accept comment "defconf: handle inbound flows"
tcp flags & (fin | syn | rst | ack) == syn jump syn_flood comment "defconf: rate limit new TCP connections" 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 "eth0" accept comment "defconf: accept LAN IPv4 / IPv6 input traffic"
iifname "tailscale0" jump input_tailscale comment "tsconf: handle TS IPv4 / IPv6 input traffic" iifname "tailscale0" goto accept_from_tailscale comment "tsconf: handle TS IPv4 / IPv6 input traffic"
} }
chain forward { chain forward {
type filter hook forward priority filter; policy drop; type filter hook forward priority filter; policy drop;
ct state established,related flow add @ft; ct state established,related flow add @ft accept comment "defconf: offload and accept forwarded flows"
ct state vmap { established : accept, related : accept } comment "defconf: handle forwarded flows" iifname "eth0" goto forward_lan comment "defconf: handle LAN IPv4 / IPv6 forward traffic"
iifname "eth0" jump forward_lan comment "defconf: handle LAN IPv4 / IPv6 forward traffic" iifname "tailscale0" goto 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 { chain output {
type filter hook output priority filter; policy accept; type filter hook output priority filter; policy accept;
oif "lo" accept comment "defconf: accept traffic towards loopback" oif "lo" accept comment "defconf: accept traffic towards loopback"
ct state vmap { established : accept, related : accept } comment "defconf: handle outbound flows" ct state established,related accept comment "defconf: handle outbound flows"
oifname "eth0" jump output_lan comment "defconf: handle LAN IPv4 / IPv6 output traffic" oifname "eth0" goto accept_to_lan comment "defconf: handle LAN IPv4 / IPv6 output traffic"
oifname "tailscale0" jump output_tailscale comment "tsconf: handle TS IPv4 / IPv6 output traffic" oifname "tailscale0" goto accept_to_tailscale comment "tsconf: handle TS IPv4 / IPv6 output traffic"
} }
chain syn_flood { chain syn_flood {
@@ -53,51 +53,30 @@ table inet router {
counter drop comment "defconf: drop excess new TCP connections" counter drop comment "defconf: drop excess new TCP connections"
} }
chain input_lan {
ct status dnat accept comment "lanconf: accept port redirect"
jump accept_from_lan
}
chain forward_lan { chain forward_lan {
jump accept_to_tailscale comment "tsconf: accept LAN to TS forwarding" oifname "tailscale0" goto accept_to_tailscale comment "tsconf: accept LAN to TS forwarding"
ct status dnat accept comment "lanconf: accept port forwards" ct status dnat accept comment "lanconf: accept port forwards"
jump accept_to_lan oifname "eth0" goto accept_to_lan
}
chain output_lan {
jump accept_to_lan
}
chain accept_from_lan {
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 LAN NATv4 leakage"
oifname "eth0" accept comment "defconf: accept LAN IPv4 / IPv6 traffic"
}
chain input_tailscale {
jump accept_from_tailscale
} }
chain forward_tailscale { chain forward_tailscale {
jump accept_to_lan comment "tsconf: accept TS to LAN forwarding" oifname "eth0" goto accept_to_lan comment "tsconf: accept TS to LAN forwarding"
jump accept_to_tailscale oifname "tailscale0" goto accept_to_tailscale
} }
chain output_tailscale { chain accept_to_lan {
jump accept_to_tailscale meta nfproto ipv4 ct state invalid counter drop comment "defconf: prevent LAN NATv4 leakage"
accept comment "defconf: accept LAN IPv4 / IPv6 traffic"
} }
chain accept_from_tailscale { chain accept_from_tailscale {
meta nfproto ipv4 iifname "tailscale0" counter accept comment "tsconf: accept TS IPv4 traffic" meta nfproto ipv4 counter accept comment "tsconf: accept TS IPv4 traffic"
meta nfproto ipv6 iifname "tailscale0" counter accept comment "tsconf: accept TS IPv6 traffic" meta nfproto ipv6 counter accept comment "tsconf: accept TS IPv6 traffic"
} }
chain accept_to_tailscale { chain accept_to_tailscale {
meta nfproto ipv4 oifname "tailscale0" counter accept comment "tsconf: accept TS IPv4 traffic" meta nfproto ipv4 counter accept comment "tsconf: accept TS IPv4 traffic"
meta nfproto ipv6 oifname "tailscale0" counter accept comment "tsconf: accept TS IPv6 traffic" meta nfproto ipv6 counter accept comment "tsconf: accept TS IPv6 traffic"
} }
@@ -107,21 +86,17 @@ table inet router {
chain dstnat { chain dstnat {
type nat hook prerouting priority dstnat; policy accept; type nat hook prerouting priority dstnat; policy accept;
iifname { "eth0", "tailscale0" } 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 goto redirect_dns comment "defconf: handle LAN IPv4 / IPv6 dstnat traffic"
} }
chain srcnat { chain srcnat {
type nat hook postrouting priority srcnat; policy accept; type nat hook postrouting priority srcnat; policy accept;
oifname "eth0" jump srcnat_lan comment "defconf: handle LAN IPv4 / IPv6 srcnat traffic" oifname "eth0" meta nfproto ipv4 counter masquerade comment "defconf: masquerade LAN IPv4 traffic"
} }
chain dstnat_lan { chain redirect_dns {
meta nfproto ipv4 meta l4proto { tcp, udp } th dport domain counter redirect to domain comment "lanconf: LAN IPv4 DNS redirect" meta nfproto ipv4 counter redirect comment "lanconf: LAN IPv4 DNS redirect"
meta nfproto ipv6 meta l4proto { tcp, udp } th dport domain counter redirect to domain comment "lanconf: LAN IPv6 DNS redirect" meta nfproto ipv6 counter redirect comment "lanconf: LAN IPv6 DNS redirect"
}
chain srcnat_lan {
meta nfproto ipv4 counter masquerade comment "defconf: masquerade LAN IPv4 traffic"
} }
@@ -131,12 +106,12 @@ table inet router {
chain mangle_postrouting { chain mangle_postrouting {
type filter hook postrouting priority mangle; policy accept; type filter hook postrouting 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" oifname "eth0" tcp flags & (fin | syn | rst) == syn tcp option maxseg size set rt mtu comment "defconf: zone LAN IPv4 / IPv6 egress MTU fixing"
} }
chain mangle_forward { chain mangle_forward {
type filter hook forward priority mangle; policy accept; 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" iifname "eth0" tcp flags & (fin | syn | rst) == syn tcp option maxseg size set rt mtu comment "defconf: zone LAN IPv4 / IPv6 ingress MTU fixing"
} }
} }
+4
View File
@@ -1,4 +1,8 @@
#!/bin/sh #!/bin/sh
#
# This script is customized by fox,
# Optimize NIC offload parameters for local TS server.
#
ETHTOOL_PATH=$(command -v ethtool) ETHTOOL_PATH=$(command -v ethtool)
+1 -1
View File
@@ -10,7 +10,7 @@ Before=tailscaled.service
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=/usr/local/bin/tailscale-nic-optim.sh ExecStart=/usr/local/bin/tailscale-nic-optim
RemainAfterExit=yes RemainAfterExit=yes
StandardOutput=journal StandardOutput=journal
+1 -1
View File
@@ -1,5 +1,5 @@
APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "5"; APT::Periodic::Unattended-Upgrade "10";
APT::Periodic::AutocleanInterval "1"; APT::Periodic::AutocleanInterval "1";
APT::Periodic::CleanInterval "1"; APT::Periodic::CleanInterval "1";
+6
View File
@@ -0,0 +1,6 @@
# This configuration file is customized by fox,
# Optimize for X550-T1: advertise 100M / 1G / 2.5G / 5G / 10G.
iface nic1 inet manual
pre-up /usr/sbin/ethtool -s nic1 autoneg on advertise 0x1800000001028 || true