diff --git a/05.PVE制作虚拟机模板.md b/05.PVE制作虚拟机模板.md index 1ff4ca1..57c08bc 100644 --- a/05.PVE制作虚拟机模板.md +++ b/05.PVE制作虚拟机模板.md @@ -167,7 +167,32 @@ $ sudo apt install iperf iperf3 iftop lsof knot-dnsutils $ sudo sync ``` -### 1.4.调整内核参数 +### 1.4.配置 ZSH + +`Zsh` 是比 `Bash` 好用的 `Shell` 程序,使用 `oh-my-zsh` 进行配置。 + +```bash +## 返回 home 目录 +$ cd + +## 使用清华大学镜像站安装 oh-my-zsh +$ git clone 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 .bash_history .zsh_history .shell.pre-oh-my-zsh ohmyzsh +``` + +### 1.5.调整内核参数 由于该 Debian 虚拟机模板将用于克隆内网 DNS 服务器,因此需要调整内核参数来简单优化性能。 @@ -222,7 +247,7 @@ net.ipv6.conf.default.use_tempaddr = 0 $ sudo sysctl -f ``` -### 1.5.调整系统时间 +### 1.6.调整系统时间 默认情况下 Debian 云镜像的系统时间需要调整,执行以下命令将系统时区设置为中国时区。 @@ -292,7 +317,7 @@ Oct 07 18:06:29 DNS01 systemd-timesyncd[1706]: Contacted time server 203.107.6.8 Oct 07 18:06:29 DNS01 systemd-timesyncd[1706]: Initial clock synchronization to Mon 2024-10-07 18:06:29.499548 CST. ``` -### 1.6.配置自动更新 +### 1.7.配置自动更新 配置 Debian 云镜像的系统自动更新,与配置 PVE 系统自动更新方法基本一致,参阅 [03.PVE系统调整](./03.PVE系统调整.md) 。 @@ -397,7 +422,7 @@ $ sudo systemctl restart apt-daily-upgrade.timer $ sudo systemctl status apt-daily-upgrade.timer ``` -### 1.7.配置定时任务 +### 1.8.配置定时任务 本步骤为可选操作,主要设置系统定时重启。 @@ -418,27 +443,6 @@ $ 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.清理系统 Debian 模板虚拟机已经配置完成,在将其转换为模板前需要对系统进行清理。 diff --git a/06.PVE制作DNS服务器.md b/06.PVE制作DNS服务器.md index a7822f2..3fe7e80 100644 --- a/06.PVE制作DNS服务器.md +++ b/06.PVE制作DNS服务器.md @@ -273,7 +273,37 @@ $ sudo chattr +i /opt/smartdns-plugin.sh $ sudo bash /opt/smartdns-plugin.sh ``` -### 6.2. SmartDNS 主配置 +### 6.2.定时任务 + +本步骤为可选操作,主要用于设置 `SmartDNS` 定时更新附加配置文件和定时重启。 + +```bash +## 编辑系统定时任务,编辑器选择 nano +$ sudo crontab -e +``` + +在配置文件末尾,增加以下配置项。 + +```bash +## 定时任务配置项 + +20 9 * * * /usr/bin/curl --retry-connrefused --retry 5 --retry-delay 5 --retry-max-time 60 -fsSLR -o /etc/smartdns.d/neodevhost.smartdns.conf https://neodev.team/lite_smartdns.conf + +30 9 * * * /usr/bin/systemctl restart smartdns.service + +``` + +若使用了 `SmartDNS` 加速规则的安装脚本,由于脚本自带服务重启功能,因此定时任务可修改如下。 + +```bash +## 定时任务配置项 + +20 9 * * * /usr/bin/curl --retry-connrefused --retry 5 --retry-delay 5 --retry-max-time 60 -fsSLR -o /etc/smartdns.d/neodevhost.smartdns.conf https://neodev.team/lite_smartdns.conf + +30 9 * * * /usr/bin/bash /opt/smartdns-plugin.sh +``` + +### 6.3. SmartDNS 主配置 `SmartDNS` 配置较为复杂,可按需制定各类 DNS 请求规则,建议先查阅官方提供的 [配置指导](https://pymumu.github.io/smartdns/config/basic-config/) 和 [配置选项](https://pymumu.github.io/smartdns/configuration/) 。 @@ -367,36 +397,6 @@ server-https https://dns.alidns.com/dns-query ``` -### 6.3.定时任务 - -本步骤为可选操作,主要用于设置 `SmartDNS` 定时更新附加配置文件和定时重启。 - -```bash -## 编辑系统定时任务,编辑器选择 nano -$ sudo crontab -e -``` - -在配置文件末尾,增加以下配置项。 - -```bash -## 定时任务配置项 - -20 9 * * * /usr/bin/curl --retry-connrefused --retry 5 --retry-delay 5 --retry-max-time 60 -fsSLR -o /etc/smartdns.d/neodevhost.smartdns.conf https://neodev.team/lite_smartdns.conf - -30 9 * * * /usr/bin/systemctl restart smartdns.service - -``` - -若使用了 `SmartDNS` 加速规则的安装脚本,由于脚本自带服务重启功能,因此定时任务可修改如下。 - -```bash -## 定时任务配置项 - -20 9 * * * /usr/bin/curl --retry-connrefused --retry 5 --retry-delay 5 --retry-max-time 60 -fsSLR -o /etc/smartdns.d/neodevhost.smartdns.conf https://neodev.team/lite_smartdns.conf - -30 9 * * * /usr/bin/bash /opt/smartdns-plugin.sh -``` - ### 6.4.配置 Dnsmasq `Dnsmasq` 的主配置文件一般位于 `/etc` 目录下,修改配置文件之前,执行以下命令将其备份。 diff --git a/07.PVE制作TS服务器.md b/07.PVE制作TS服务器.md index 5bc956a..94dcddf 100644 --- a/07.PVE制作TS服务器.md +++ b/07.PVE制作TS服务器.md @@ -141,7 +141,32 @@ $ sudo apt install tailscale $ sudo sync ``` -### 1.4.调整内核模块 +### 1.4.配置 ZSH + +`Zsh` 是比 `Bash` 好用的 `Shell` 程序,使用 `oh-my-zsh` 进行配置。 + +```bash +## 返回 home 目录 +$ cd + +## 使用清华大学镜像站安装 oh-my-zsh +$ git clone 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 .bash_history .zsh_history .shell.pre-oh-my-zsh ohmyzsh +``` + +### 1.5.调整内核模块 使用 `neovim` 编辑器编辑 **内核模块** 配置文件,执行以下命令。 @@ -160,7 +185,7 @@ nf_conntrack ``` -### 1.5.调整内核参数 +### 1.6.调整内核参数 使用 `neovim` 编辑器编辑 **内核参数** 配置文件,执行以下命令。 @@ -250,7 +275,7 @@ net.netfilter.nf_conntrack_tcp_timeout_established = 7440 $ sudo sysctl -f ``` -### 1.6.调整系统时间 +### 1.7.调整系统时间 默认情况下 Debian 云镜像的系统时间需要调整,执行以下命令将系统时区设置为中国时区。 @@ -295,7 +320,7 @@ $ sudo systemctl restart systemd-timesyncd.service $ sudo systemctl status systemd-timesyncd.service ``` -### 1.7.配置自动更新 +### 1.8.配置自动更新 配置系统自动更新策略,执行以下命令,使用键盘 `左右方向键` 进行选择,`回车键` 进行确认。 @@ -395,7 +420,7 @@ $ sudo systemctl restart apt-daily-upgrade.timer $ sudo systemctl status apt-daily-upgrade.timer ``` -### 1.8.配置防火墙 +### 1.9.配置防火墙 修改防火墙配置之前,需检查 `nftables.service` 服务状态,确保该服务开机自启。 @@ -426,7 +451,7 @@ $ sudo nvim /etc/nftables.conf $ sudo systemctl restart nftables.service ``` -### 1.9.调整系统端口 +### 1.10.调整系统端口 为了正常使用 `53` 端口,需要对 `systemd-resolved.service` 进行配置,执行以下命令。 @@ -465,7 +490,7 @@ $ sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf $ sudo systemctl restart systemd-resolved.service ``` -### 1.10.配置 Dnsmasq +### 1.11.配置 Dnsmasq 检查 `dnsmasq.service` 服务状态,确保该服务开机自启。 @@ -563,27 +588,6 @@ 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 根据不同的启动参数,TS 服务将具有不同的业务能力。