VPS搭建WireGuard VPN教程:最快速的现代VPN方案

前言 WireGuard是新一代VPN协议,相比传统的OpenVPN和IPSec,WireGuard代码量极少(仅约4000行)、速度更快、延迟更低、配置更简单,已经被正式合入Linux内核主线。在VPS上搭建WireGuard,可以获得比传统方案更好的网络体验。本文教你从零开始在VPS上搭建WireGuard VPN。 一、WireGuard的优势 对比项 WireGuard OpenVPN IPSec/L2TP 代码量 ~4000行 ~100000行 非常庞大 速度 极快 较慢 中等 延迟 极低 较高 中等 配置难度 简单 复杂 复杂 内核支持 Linux 5.6+原生 用户态 内核态 漫游支持 优秀 一般 一般 电池消耗 低(移动端友好) 高 中等 二、安装WireGuard Debian/Ubuntu # 更新系统 sudo apt update && sudo apt upgrade -y # 安装WireGuard sudo apt install -y wireguard wireguard-tools CentOS/AlmaLinux/Rocky # 安装WireGuard sudo dnf install -y epel-release sudo dnf install -y wireguard-tools 检查安装 # 查看内核模块 lsmod | grep wireguard # 或手动加载 modprobe wireguard # 查看版本 wg version 三、生成密钥对 WireGuard使用公钥/私钥方式进行认证,服务端和客户端各需要一对密钥。 ...

2026年6月3日

VPS开启BBR加速教程:一键提升网络速度

前言 很多用户购买了便宜VPS后发现网络速度不理想,尤其是连接海外服务器时延迟高、丢包严重。其实很多时候并不是VPS本身的问题,而是TCP拥塞控制算法没有优化。BBR是Google开发的TCP拥塞控制算法,开启后可以显著提升VPS的网络传输速度,是VPS必备的优化操作之一。本文教你如何在VPS上一键开启BBR加速。 一、什么是BBR BBR(Bottleneck Bandwidth and Round-trip propagation time)是Google在2016年发布的TCP拥塞控制算法。传统的TCP算法(如Cubic)在检测到丢包时会大幅降低传输速度,而BBR通过主动测量带宽和延迟来决定发送速率,在有丢包的网络环境下依然能保持较高的传输速度。 对于连接海外VPS的用户来说,开启BBR后下载速度和连接稳定性通常会有明显提升,部分场景下速度可以提升数倍。 BBR版本说明 BBR v1:Linux内核4.9及以上自带,目前最常用 BBR v2:仍在开发中,部分内核可手动编译使用 BBRv3:最新实验版本,需要特殊内核支持 普通用户使用BBR v1即可满足需求。 二、检查当前拥塞控制算法 在开启BBR之前,先检查一下VPS当前使用的拥塞控制算法: # 查看当前使用的拥塞控制算法 sysctl net.ipv4.tcp_congestion_control # 查看系统支持的拥塞控制算法 sysctl net.ipv4.tcp_available_congestion_control 如果输出显示 cubic 或 reno,说明还没有开启BBR,需要按照下面的步骤操作。如果已经显示 bbr,则说明已经开启了。 三、一键开启BBR 方法一:手动开启(推荐) 适用于Linux内核4.9及以上的系统(Debian 9+、Ubuntu 16.04+、CentOS 7+等)。 # 添加BBR配置到sysctl echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf # 应用配置 sysctl -p 方法二:使用一键脚本 如果需要安装更新的内核或BBR Plus版本,可以使用一键脚本: wget -O tcpx.sh "https://github.com/ylx2016/Linux-NetSpeed/raw/master/tcpx.sh" && chmod +x tcpx.sh && ./tcpx.sh 注意:安装新内核后需要重启VPS才能生效。重启前请确保你有SSH连接方式(如VNC控制台),以防新内核不兼容导致无法连接。 四、验证BBR是否生效 # 查看当前拥塞控制算法 sysctl net.ipv4.tcp_congestion_control # 输出应为:net.ipv4.tcp_congestion_control = bbr # 确认BBR模块已加载 lsmod | grep bbr # 输出应包含:tcp_bbr # 查看内核版本(使用BBR脚本安装新内核的情况) uname -r 五、进阶优化:配合内核参数调优 开启BBR后,还可以进一步优化内核网络参数以获得更好的效果。编辑 /etc/sysctl.conf,添加以下配置: ...

2026年6月3日

VPS性能测试完全指南:CPU、内存、硬盘、网络一键跑分

前言 买了VPS之后,第一件事就是测试一下性能到底怎么样。CPU是不是超售?硬盘IO速度如何?网络到国内快不快?这些都可以通过跑分工具来量化。本文介绍几款最常用的VPS性能测试工具,一键跑完CPU、内存、硬盘、带宽、网络延迟等全部指标,帮你全面了解VPS的真实性能。 一、YABS:一键综合跑分 YABS(Yet Another Benchmark Script)是目前最流行的一站式VPS跑分脚本,一次运行可以测试CPU、内存、硬盘IO、网络速度等,并输出标准化的跑分结果。 curl -sL yabs.sh | bash 如果网络不好下载失败,可以用备用地址: wget -qO- https://raw.githubusercontent.com/masonr/yet-another-bench-script/master/yabs.sh | bash YABS测试结果解读 YABS会输出以下几项测试结果: 1. CPU Geekbench 6 跑分 等级 单核分数 说明 入门级 <400 OpenVZ或严重超售 普通 400-800 大部分便宜VPS的水平 良好 800-1200 性价比较高的VPS 优秀 >1200 AMD Ryzen或高频CPU 2. 磁盘IO速度 等级 速度 说明 HDD <200 MB/s 机械硬盘 SSD 200-500 MB/s 普通SSD NVMe 500-3000 MB/s 高速NVMe固态 优秀 >3000 MB/s 高端NVMe RAID阵列 3. 网络速度 测试到全球多个节点的上传和下载速度,重点看亚洲节点(如新加坡、东京)的速度,这反映了到国内的实际体验。 二、LemonBench:国内用户首选 LemonBench是国内开发者编写的跑分脚本,对国内网络环境测试更全面,包含三网回程路由测试。 wget -qO- https://raw.githubusercontent.com/LemonBench/LemonBench/main/LemonBench.sh | bash -s -- --fast LemonBench特色功能 三网(电信/联通/联通)回程路由检测 国内节点下载速度测试 TCP回程路由追踪 流媒体解锁检测 三、Superbench:网络与流媒体测试 Superbench专门针对国内用户优化,可以测试到国内三网的速度以及流媒体解锁情况。 ...

2026年6月3日

国内用户一键安装Docker并配置镜像源

Debian/Ubuntu从软件源一键安装 安装Docker apt install -y docker.io docker-compose 自启动Docker systemctl enable --now docker Docker官方一键安装脚本 使用官方源安装(国内直接访问较慢) curl -fsSL https://get.docker.com | bash 使用阿里源安装 curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun 使用中国区Azure源安装 curl -fsSL https://get.docker.com | bash -s docker --mirror AzureChinaCloud 自启动Docker systemctl enable --now docker 一键安装最新版Docker Compose: COMPOSE_VERSION=`git ls-remote https://github.com/docker/compose | grep refs/tags | grep -oP "[0-9]+\.[0-9][0-9]+\.[0-9]+$" | sort --version-sort | tail -n 1` sh -c "curl -L https://github.com/docker/compose/releases/download/v${COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose" chmod +x /usr/local/bin/docker-compose 配置国内镜像源 mkdir -p /etc/docker tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": [ "https://dockerproxy.com", "https://docker.m.daocloud.io", "https://ypzju6vq.mirror.aliyuncs.com" ] } EOF systemctl daemon-reload systemctl restart docker

2024年6月21日

VPS常用脚本大全

DD网络重装脚本:系统默认为debian12 moeclub大佬的脚本 bash <(wget --no-check-certificate -qO- 'https://raw.githubusercontent.com/MoeClub/Note/master/InstallNET.sh') -d 12 -v 64 -p 密码 -port 端口 -a -firmware leitbogioro大佬的脚本(推荐) https://hostloc.com/thread-1159839-1-1.html wget --no-check-certificate -qO InstallNET.sh 'https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/InstallNET.sh' && chmod a+x InstallNET.sh && bash InstallNET.sh -debian 12 -pwd '密码' beta.gs大佬的脚本 wget --no-check-certificate -O NewReinstall.sh https://raw.githubusercontent.com/fcurrk/reinstall/master/NewReinstall.sh && chmod a+x NewReinstall.sh && bash NewReinstall.sh 5k哥的脚本 风险警告:此人在loc等论坛口碑不良,多次骂人。 https://soclearn.org/1keydd/ 服务器综合测试脚本(融合怪)(推荐) curl -L https://gitlab.com/spiritysdx/za/-/raw/main/ecs.sh -o ecs.sh && chmod +x ecs.sh && bash ecs.sh 性能测试脚本 YABS(推荐) wget -qO- yabs.sh | bash 流量稀缺的服务器(不测试iperf网络) curl -sL yabs.sh | bash -s -- -i 我更喜欢geekbench5(不测试geekbench6) curl -sL yabs.sh | bash -s -- -5 我喜欢geekbench5,但服务器流量稀缺(不测试geekbench6、不测试iperf网络) curl -sL yabs.sh | bash -s -- -5 -i Geekbench 5 专测脚本 NS论坛大佬@google 开发 bash <(curl -sL gb5.top) LemonBench wget -qO- https://raw.githubusercontent.com/LemonBench/LemonBench/main/LemonBench.sh | bash -s -- --fast UnixBench.sh wget --no-check-certificate https://github.com/teddysun/across/raw/master/unixbench.sh chmod +x unixbench.sh ./unixbench.sh 网络测试脚本 hyperspeed 三网测速(推荐)(未开源) bash <(curl -Lso- https://bench.im/hyperspeed) AutoTrace 三网回程线路显示(推荐) wget -N --no-check-certificate https://raw.githubusercontent.com/Chennhaoo/Shell_Bash/master/AutoTrace.sh && chmod +x AutoTrace.sh && bash AutoTrace.sh backtrace 三网回程线路直接显示(小白用这个) curl https://raw.githubusercontent.com/zhanghanyun/backtrace/main/install.sh -sSf | sh Bench 网络带宽及硬盘读写速率(国外部分+国内部分节点) wget -qO- bench.sh | bash SuperBench.sh 网络带宽及硬盘读写速率(国内三网+speedtest+fast) wget -qO- --no-check-certificate https://raw.githubusercontent.com/oooldking/script/master/superbench.sh | bash 超售测试脚本 wget --no-check-certificate -O memoryCheck.sh https://raw.githubusercontent.com/uselibrary/memoryCheck/main/memoryCheck.sh && chmod +x memoryCheck.sh && bash memoryCheck.sh 移除virtio_balloon模块 rmmod virtio_balloon 内存填充测试 apt-get update apt-get install wget build-essential -y wget https://raw.githubusercontent.com/FunctionClub/Memtester/master/memtester.cpp gcc -l stdc++ memtester.cpp ./a.out 流媒体测试脚本 RegionRestrictionCheck(推荐) bash <(curl -L -s check.unlock.media) openai解锁检测 bash <(curl -Ls https://github.com/ludashi2020/OpenAI-Checker/raw/main/openai.sh) BBR脚本 一键开启BBR(适用于较新的Debian、Ubuntu) echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf sysctl -p sysctl net.ipv4.tcp_available_congestion_control lsmod | grep bbr Linux-NetSpeed(锐速/bbrplus/bbr魔改版) wget -N --no-check-certificate "https://raw.githubusercontent.com/chiakge/Linux-NetSpeed/master/tcp.sh" chmod +x tcp.sh ./tcp.sh ylx大佬的锐速/BBRPLUS/BBR2 wget -O tcpx.sh "https://github.com/ylx2016/Linux-NetSpeed/raw/master/tcpx.sh" && chmod +x tcpx.sh && ./tcpx.sh moerats大佬的添加swap脚本 wget https://www.moerats.com/usr/shell/swap.sh && bash swap.sh spiritlhl大佬的zram内存压缩脚本 curl -L https://raw.githubusercontent.com/spiritLHLS/addzram/main/addzram.sh -o addzram.sh && chmod +x addzram.sh && bash addzram.sh cloudflare warp脚本 添加IPv4/IPv6网络(2023.12.10更新) wget -N https://gitlab.com/fscarmen/warp/-/raw/main/menu.sh && bash menu.sh [option] [lisence/url/token] fail2ban服务器ssh防爆破 wget https://raw.githubusercontent.com/FunctionClub/Fail2ban/master/fail2ban.sh && bash fail2ban.sh 2>&1 | tee fail2ban.log 独立服务器硬盘时间 wget -q https://github.com/Aniverse/A/raw/i/a && bash a 常用软件脚本 Docker curl -sSL https://get.docker.com/ | sh Aria2一键安装脚本 wget -N git.io/aria2.sh && chmod +x aria2.sh && bash aria2.sh XUI bash <(curl -Ls https://raw.githubusercontent.com/FranzKafkaYu/x-ui/master/install.sh) qbittorrent 4.3.9 https://hostloc.com/thread-1024684-1-1.html ...

2024年5月28日