diff --git a/05.PVE制作虚拟机模板.md b/05.PVE制作虚拟机模板.md index b6df576..ba17879 100644 --- a/05.PVE制作虚拟机模板.md +++ b/05.PVE制作虚拟机模板.md @@ -207,6 +207,7 @@ net.ipv4.tcp_syncookies = 1 net.ipv6.conf.all.use_tempaddr = 0 net.ipv6.conf.default.use_tempaddr = 0 + ``` 保存该配置文件后,重启系统或者执行以下命令让配置生效。 diff --git a/07.PVE制作TS服务器.md b/07.PVE制作TS服务器.md index 3a91e68..d8016ed 100644 --- a/07.PVE制作TS服务器.md +++ b/07.PVE制作TS服务器.md @@ -133,4 +133,156 @@ $ sudo apt install tailscale ## 写入磁盘 $ sudo sync -``` \ No newline at end of file +``` + +### 1.4.调整内核模块 + +使用 `neovim` 编辑器编辑 **内核模块** 配置文件,执行以下命令。 + +```bash +## 创建 内核模块 配置文件 +$ sudo nvim /etc/modules-load.d/server_modules.conf +``` + +在配置文件中添加以下配置项,并保存。 + +```bash +# This configuration file is customized by fox, +# Optimize netfilter related modules at system boot. + +nf_conntrack + +``` + +### 1.5.调整内核参数 + +使用 `neovim` 编辑器编辑 **内核参数** 配置文件,执行以下命令。 + +```bash +## 编辑 内核参数 配置文件 +$ sudo nvim /etc/sysctl.d/99-sysctl.conf +``` + +在配置文件末尾输入以下配置项,注意配置中间的空格。 + +```bash +# This configuration file is customized by fox, +# Optimize sysctl parameters for local TS server. + +kernel.panic = 20 +kernel.panic_on_oops = 1 + +net.core.default_qdisc = fq_codel +net.ipv4.tcp_congestion_control = bbr + +net.ipv4.ip_forward = 1 + +net.ipv6.conf.all.forwarding = 1 +net.ipv6.conf.default.forwarding = 1 + +# Other adjustable system parameters + +net.core.netdev_budget = 600 +net.core.netdev_budget_usecs = 20000 + +net.core.rps_sock_flow_entries = 32768 + +net.ipv4.conf.all.accept_redirects = 0 +net.ipv4.conf.default.accept_redirects = 0 + +net.ipv4.conf.all.accept_source_route = 0 +net.ipv4.conf.default.accept_source_route = 0 + +net.ipv4.conf.all.arp_ignore = 1 +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.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_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.ipv6.conf.all.accept_redirects = 0 +net.ipv6.conf.default.accept_redirects = 0 + +net.ipv6.conf.all.accept_source_route = 0 +net.ipv6.conf.default.accept_source_route = 0 + +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_tcp_timeout_established = 7440 + +``` + +保存该配置文件后,重启系统或者执行以下命令让配置生效。 + +```bash +## 让内核参数生效 +$ sudo sysctl -f +``` + +### 1.6.调整系统时间 + +默认情况下 Debian 云镜像的系统时间需要调整,执行以下命令将系统时区设置为中国时区。 + +```bash +## 设置系统时区 +$ sudo timedatectl set-timezone Asia/Shanghai + +## 检查系统时间 +$ date -R + +#### 系统时间示例输出 +Mon, 26 Jun 2023 16:16:16 +0800 +``` + +Debian 云镜像默认使用 `systemd-timesyncd.service` 同步时间,且需要调整为使用国内 NTP 服务器。 + +调整 NTP 服务器参数,执行以下命令。 + +```bash +## 创建 NTP 配置文件的文件夹 +$ sudo mkdir -p /etc/systemd/timesyncd.conf.d + +## 创建 NTP 配置文件 +$ sudo nvim /etc/systemd/timesyncd.conf.d/server_ntp.conf +``` + +在配置文件中添加以下配置项,并保存。 + +```bash +## NTP 配置项 + +[Time] +NTP=ntp.tencent.com ntp.aliyun.com + +``` + +保存该配置文件后,需重启 `systemd-timesyncd.service` 服务,并再次检查系统 NTP 服务器地址。 + +```bash +## 重启 chrony 服务 +$ sudo systemctl restart systemd-timesyncd.service + +## 检查系统 NTP 服务器 +$ sudo systemctl status systemd-timesyncd.service +``` +