适配 trixie 版本

This commit is contained in:
CallMeR
2025-08-12 02:40:53 +08:00
parent c1446daf89
commit b0ede429fc
4 changed files with 110 additions and 48 deletions
+43 -21
View File
@@ -63,7 +63,7 @@ $ sudo systemctl restart ssh.service
```bash
## 配置 Debian 系统默认软件源脚本
$ sudo cat > /etc/apt/sources.list.d/debian.sources <<EOF
$ sudo bash -c 'cat > /etc/apt/sources.list.d/debian.sources <<EOF
Types: deb
URIs: https://mirrors.ustc.edu.cn/debian
Suites: trixie trixie-updates
@@ -76,7 +76,7 @@ Suites: trixie-security
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
EOF
EOF'
```
@@ -163,13 +163,35 @@ Do you want to change your default shell to zsh? [Y/n] y
$ cd && rm -rvf ohmyzsh .bash_history .zsh_history .shell.pre-oh-my-zsh
```
### 1.5.调整内核模块
### 1.5.配置默认编辑器
使用 `neovim` 编辑器编辑 **内核模块** 配置文件,执行以下命令。
Debian 系统默认编辑器为 `nano` ,推荐将默认编辑器更换为 `neovim` ,执行以下命令。
```bash
## 修改系统默认编辑器(选择 nvim 所在条目,即可将 neovim 设为默认编辑器)
$ sudo update-alternatives --config editor
#### 系统默认编辑器示例输出
There are 3 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.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
```
在配置文件中添加以下配置项,并保存。
@@ -182,13 +204,13 @@ nf_conntrack
```
### 1.6.调整内核参数
### 1.7.调整内核参数
使用 `neovim` 编辑器编辑 **内核参数** 配置文件,执行以下命令。
编辑 **内核参数** 配置文件,执行以下命令。
```bash
## 编辑 内核参数 配置文件
$ sudo nvim /etc/sysctl.d/99-sysctl.conf
$ sudo editor /etc/sysctl.d/99-sysctl.conf
```
在配置文件中添加以下配置项,注意配置中间的空格。
@@ -273,7 +295,7 @@ net.netfilter.nf_conntrack_tcp_timeout_established = 7440
$ sudo sysctl --system
```
### 1.7.调整系统时间
### 1.8.调整系统时间
默认情况下 Debian 云镜像的系统时间需要调整,执行以下命令将系统时区设置为中国时区。
@@ -294,7 +316,7 @@ Debian 云镜像默认使用 `systemd-timesyncd.service` 同步时间,且需
$ sudo mkdir -p /etc/systemd/timesyncd.conf.d
## 创建 NTP 配置文件
$ sudo nvim /etc/systemd/timesyncd.conf.d/10-server-ntp.conf
$ sudo editor /etc/systemd/timesyncd.conf.d/10-server-ntp.conf
```
在配置文件中添加以下配置项,并保存。
@@ -318,7 +340,7 @@ $ sudo systemctl restart systemd-timesyncd.service
$ sudo systemctl status systemd-timesyncd.service
```
### 1.8.配置自动更新
### 1.9.配置自动更新
配置系统自动更新策略,执行以下命令,使用键盘 `左右方向键` 进行选择,`回车键` 进行确认。
@@ -334,7 +356,7 @@ $ sudo dpkg-reconfigure -plow unattended-upgrades
```bash
## 编辑 20auto-upgrades 配置文件
$ sudo nvim /etc/apt/apt.conf.d/20auto-upgrades
$ sudo editor /etc/apt/apt.conf.d/20auto-upgrades
```
删除里面全部内容,添加以下配置项,并保存。
@@ -355,7 +377,7 @@ 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
```
根据 “注释” 中相关说明,调整配置文件。
@@ -418,7 +440,7 @@ $ sudo systemctl restart apt-daily-upgrade.timer
$ sudo systemctl status apt-daily-upgrade.timer
```
### 1.9.配置防火墙
### 1.10.配置防火墙
修改防火墙配置之前,需检查 `nftables.service` 服务状态,确保该服务开机自启。
@@ -430,14 +452,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) 进行复制。
@@ -449,7 +471,7 @@ $ sudo nvim /etc/nftables.conf
$ sudo systemctl restart nftables.service
```
### 1.10.调整系统端口
### 1.11.调整系统端口
为了正常使用 `53` 端口,需要对 `systemd-resolved.service` 进行配置,执行以下命令。
@@ -458,7 +480,7 @@ $ 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
```
在配置文件中添加以下配置项,并保存。
@@ -488,7 +510,7 @@ $ sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
$ sudo systemctl restart systemd-resolved.service
```
### 1.11.配置 Dnsmasq
### 1.12.配置 Dnsmasq
检查 `dnsmasq.service` 服务状态,确保该服务开机自启。
@@ -507,11 +529,11 @@ $ sudo systemctl enable dnsmasq.service
$ sudo mkdir -p /etc/dnsmasq.d
```
使用 `neovim` 编辑器创建 `Dnsmasq` 主配置文件,执行以下命令。
创建 `Dnsmasq` 主配置文件,执行以下命令。
```bash
## 创建 Dnsmasq 主配置文件
$ sudo nvim /etc/dnsmasq.d/10-server-dnsmasq.conf
$ sudo editor /etc/dnsmasq.d/10-server-dnsmasq.conf
```
在编辑器对话框中输入以下内容,并保存。