A. 實現sudo apt update
加速
在 Debian 12 上運行 sudo apt update
很慢的常見原因包括:
🔍 一、常見原因分析
-
使用了國外的軟件源
默認 Debian 安裝源多數是國際服務器,國內訪問會非常慢。 -
DNS 解析慢或失敗
軟件源地址解析時間長,影響整體更新速度。 -
網絡帶寬或延遲問題
你的網絡連接到源服務器不穩定,或出口帶寬有限。 -
IPv6 網絡問題
部分環境下 IPv6 地址連接慢甚至失敗。
? 二、解決方案(建議按順序嘗試)
1. 🇨🇳 更換為國內鏡像源
修改 /etc/apt/sources.list
文件為國內源,如清華源:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo nano /etc/apt/sources.list
將內容替換為(以清華源為例):
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
保存后,運行:
sudo apt update
其他可選國內源:
- 阿里云:https://developer.aliyun.com/mirror/debian
- 中科大:https://mirrors.ustc.edu.cn/debian/
- 華為云:https://mirrors.huaweicloud.com/debian/
2. 🛠 禁用 IPv6(如網絡環境不支持)
sudo nano /etc/sysctl.conf
添加以下內容:
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
然后運行:
sudo sysctl -p
3. 🧠 配置 DNS 為更快的公共解析器
將 /etc/resolv.conf
中的 DNS 改為:
nameserver 223.5.5.5 # 阿里
nameserver 114.114.114.114 # 114DNS
若該文件由 NetworkManager 或 systemd 管理,請使用以下方式:
sudo systemd-resolve --status
或通過修改 Netplan
或 NetworkManager
配置。
4. 🧪 進行速度測試(可選)
apt install netselect-apt
sudo netselect-apt -n stable
這個工具會幫你自動選擇最快的源。
B. 配置RDP
? 一、在 Debian 12 上安裝并啟用 RDP 服務(xrdp)
請按以下步驟操作:
1. 安裝 xrdp
和桌面環境(如 XFCE):
sudo apt update
sudo apt install xrdp xfce4 xfce4-goodies -y
2. 配置 xrdp
使用 XFCE:
編輯或創建文件:
echo "startxfce4" > ~/.xsession
3. 啟動并設置 xrdp 自啟動:
sudo systemctl enable --now xrdp
4. 檢查 xrdp 服務是否運行正常:
sudo systemctl status xrdp
你應該看到狀態為 active (running)
。
? 二、確認本地 3389 端口監聽狀態
確保有服務監聽 3389 端口(frpc.toml
中 rdp-nas
使用的本地端口):
sudo ss -tnlp | grep :3389
你應該看到像這樣一行輸出:
LISTEN 0 50 0.0.0.0:3389 ... users:(("xrdp",pid=xxxx,...))
? 三、從客戶端進行遠程連接測試
?? 前提是你的公網服務器已開放 5901 端口
在 Windows 客戶端 使用:
-
打開
mstsc
-
輸入:
123.45.678.90:5901
-
連接后會提示用戶名和密碼,填寫 Debian 上的登錄憑據(如:用戶名
lgk
,密碼為登錄密碼)
?常見問題排查
問題 | 排查建議 |
---|---|
黑屏或連接后立刻斷開 | 沒有正確配置 .xsession 或沒有安裝桌面環境 |
連接報錯 | 云服務器安全組/防火墻未放行 5901 或未運行 xrdp |
frpc 沒有正常轉發 | 檢查日志是否成功連接并綁定遠程端口 |
如果你已完成上述步驟但仍然失敗,請提供以下信息以便進一步排查:
sudo systemctl status xrdp
的輸出sudo ss -tnlp | grep 3389
的結果frpc
運行時日志中關于[rdp-nas]
的部分
C. 將終端FRP服務設置成開機啟動項
假設:
frpc
路徑:/home/lgk/Remote/frp_0.63.0_linux_amd64/frpc
frpc.toml
路徑:/home/lgk/Remote/frp_0.63.0_linux_amd64/frpc.toml
- 用戶名為:
lgk
下面是完整配置方法:
? 步驟 1:創建 frpc
的 systemd 啟動服務
sudo nano /etc/systemd/system/frpc.service
粘貼以下內容:
[Unit]
Description=FRP Client Service
After=network.target[Service]
Type=simple
User=liuguokai
WorkingDirectory=/home/lgk/Remote/frp_0.63.0_linux_amd64
ExecStart=/home/lgk/Remote/frp_0.63.0_linux_amd64/frpc -c /home/liuguokai/Remote/frp_0.63.0_linux_amd64/frpc.toml
Restart=on-failure[Install]
WantedBy=multi-user.target
按下 Ctrl+O
保存,Ctrl+X
退出。
? 步驟 2:刷新并啟用服務
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enable frpc.service
sudo systemctl start frpc.service
? 步驟 3:驗證是否運行成功
sudo systemctl status frpc.service
你應該看到 Active: active (running)
狀態。
? 步驟 4:查看日志(可選)
journalctl -u frpc -e
這樣設置后,每次開機都會自動以用戶 lgk
的身份運行 frpc -c frpc.toml
,無需手動啟動。
D. 解決瀏覽器無法打開的問題
sudo apt update
sudo apt install firefox-esr