VPS常用脚本
玩vps的过程中,为了省事,经常会用到一些脚本,这边整理的就是常用的一些脚本。持续更新!
Linux通用换源和Docker安装
1 | bash <(curl -sSL https://linuxmirrors.cn/main.sh) |
https://github.com/SuperManito/LinuxMirrors
适合国内主机
流媒体测试脚本
流媒体1
github项目地址 https://github.com/lmc999/RegionRestrictionCheck
脚本:
1 | bash <(curl -L -s https://git.io/JRw8R) |
或者这个:
1 | bash <(curl -L -s check.unlock.media) |
运行的时候会让你选择需要测流媒体的地区,其实选哪里都能测奈飞和迪士尼等等,选不同的地区会测一些该地区独有的流媒体。支持ipv4+ipv6测试。
tiktok解锁测试脚本:
1 | curl -fsL -o ./t.sh.x https://github.com/lmc999/TikTokCheck/raw/main/t.sh.x && chmod +x ./t.sh.x && ./t.sh.x && rm ./t.sh.x |
另一个流媒体测试脚本
这个脚本作者不经常更新,不如上一个脚本更新比较快,这个脚本不会让你选择地区,它会把所有地区流媒体都测一遍,有的时候上面那个脚本显示奈飞解锁,这个脚本会显示奈飞只有自制剧,这个需要自己测试了。也是支持ipv4+ipv6测试。
github项目地址:https://github.com/LovelyHaochi/StreamUnlockTest
解锁奈飞
- 判断vps是否解锁奈飞,项目地址
1 | wget -O nf https://github.com/sjlleo/netflix-verify/releases/download/v3.1.0/nf_linux_amd64 && chmod +x nf && ./nf |
- Warp解锁奈飞,项目地址
1 | wget -N https://raw.githubusercontent.com/fscarmen/warp/main/menu.sh && bash menu.sh [option] [lisence] |
- 奈飞解锁方式大全(源自不良林)
博客地址:链接
启用BBR
- 查询当前使用的TCP拥塞控制算法
1 | sysctl net.ipv4.tcp_congestion_control |
- 查询当前Liux版本
1 | uname -r |
linux内核大于4.9
- 一键启用BBR TCP拥塞控制算法(linux版本>4.9),逐条复制,最后一条命令用来检测当前的tcp拥塞算法
1 | echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf |
升级debian系统内核
内核低于4.9,可以升级后再启用。
添加源
1 | echo "deb http://deb.debian.org/debian buster-backports main" > /etc/apt/sources.list.d/backports.list |
安装最新内核和头文件
1 | apt update |
重新启动服务器
1 | shutdown -r now |
卸载旧内核
请确保使用中的内核不要卸载
1 | dpkg --list | grep linux-image |
命令 dpkg --list | grep linux-image
用于列出基于Debian的系统上已安装的Linux内核镜像。下面是对该命令各部分的解释:
dpkg
: 它是一个命令行软件包管理工具,在基于Debian的系统中使用,包括Ubuntu。--list
: 这个选项用来列出已安装的软件包。|
: 它是一个管道符号,将前一个命令的输出重定向到下一个命令。grep
: 这是一个用于模式匹配和搜索文本的命令。linux-image
: 这是我们在已安装软件包的列表中寻找的搜索模式或关键词。
当你运行 dpkg --list | grep linux-image
命令时,它将显示一个包含linux-image
短语的已安装软件包的过滤列表。在这种情况下,它可能会显示你系统上已安装的Linux内核镜像包。这些软件包负责提供操作系统的核心功能。
删除旧头文件
1 | dpkg --list | grep linux-headers |
命令 dpkg --list | grep linux-headers
用于列出基于Debian的系统上已安装的Linux头文件包。下面是对该命令各部分的解释:
dpkg
: 它是一个命令行软件包管理工具,在基于Debian的系统中使用,包括Ubuntu。--list
: 这个选项用来列出已安装的软件包。|
: 它是一个管道符号,将前一个命令的输出重定向到下一个命令。grep
: 这是一个用于模式匹配和搜索文本的命令。linux-headers
: 这是我们在已安装软件包的列表中寻找的搜索模式或关键词。
当你运行dpkg --list | grep linux-headers
命令时,它将显示一个包含inux-headers
短语的已安装软件包的过滤列表。Linux头文件包包括构建外部内核模块或编译与内核交互的软件所需的必要头文件和元数据。这些头文件包通常与你系统上安装的Linux内核版本相匹配。
如果使用中的内核缺失头文件,可以使用如下命令安装
1 | apt install linux-headers-$(uname -r) |
命令 apt install linux-headers-$(uname -r)
是用来安装Linux内核头文件的,它与基于Debian的系统上当前运行的内核版本相对应。下面是对该命令各部分的解释:
apt
: 它是一个命令行软件包管理工具,在基于Debian的系统中使用,包括Ubuntu。install
: 这是用来安装软件包的命令。linux-headers-$(uname -r
: 这是一个由 linux-headers
组成的软件包名称,后面是uname -r
命令的输出。uname -r
命令返回当前运行的内核版本。通过在软件包名称中使用$(uname -r)
,该命令动态地将当前的内核版本插入软件包名称中。
当你运行 apt install linux-headers-$(uname -r)
命令时,它将安装符合你系统上当前运行的内核版本的Linux内核头文件。这些头文件对于构建和编译外部内核模块或与内核交互的软件是必要的。安装匹配的内核头文件可以确保与你系统上的内核版本兼容。
保持内核最新
把下面命令添加到 /etc/apt/preferences.d/pinning.pref
文件中(如果没有,可创建)
1 | Package: linux-image-amd64 linux-headers-amd64 |
使用BBR脚本
BBT2
1 | wget --no-check-certificate -q -O bbr2.sh "https://github.com/yeyingorg/bbr2.sh/raw/master/bbr2.sh" && chmod +x bbr2.sh && bash bbr2.sh auto |
BBRPLUS
1 | wget -N --no-check-certificate "https://raw.githubusercontent.com/chiakge/Linux-NetSpeed/master/tcp.sh" && chmod +x tcp.sh && ./tcp.sh |
这里再放一个bbr优化脚本,聊胜于无,对于中转机或者是配置比较差的机器可能会有点用
1 | bash <(curl -Ls https://github.com/lanziii/bbr-/releases/download/123/tools.sh) |
查看BBR开启状态
1 | sysctl -p |
或者
1 | lsmod | grep bbr |
VPS基础性能测试脚本
检测vps硬件信息
superbench
1 | wget -qO- --no-check-certificate https://raw.githubusercontent.com/oooldking/script/master/superbench.sh | bash |
这个脚本还会输入结果页面,可以直接分享网址别人,不过最近这个页面托管商需要登陆才能查看,不如直接复制了。以及speed测速也有分享网页的链接。具体看下面的结果。
yabs
这个脚本和上面那个superbench比,IO测试比较完全,还能测试cpu分数。但是没有网速测试,所以我通常这两个脚本都使用。
1 | curl -sL yabs.sh | bash -s -- -i |
回程路由测试脚本
这里放的都是回程路由测试脚本,去程的自己ping或者去ipip.net自己测,工具很多,回程的脚本测试我找到两个比较好用的脚本。
回程路由测试脚本简洁版
说个好玩的,有人做了个这个脚本的魔改版本,1秒钟输出结果,全部显示是gia回程,有点意思。下面这个脚本是原版,测试结果不如详细回程路由里面自己判断准确,有些gia回程这个脚本会判断成cn2 gt。这是因为有些地区的gia回程难免出现202.97,这个脚本就会把gia线路判断成cn2 gt,不过总体来将这个脚本还是比较准确的。提示一下,电信回程没有优化的普通线路是163,联通普通回程时4837,移动普通回程是cmi。
脚本:
1 | curl https://raw.githubusercontent.com/zhucaidan/mtr_trace/main/mtr_trace.sh|bash |
1 | wget -q route.f2k.pub -O route && bash route |
回程测试脚本详细版
脚本:
1 | wget -qO- git.io/besttrace | bash |
1 | wget https://raw.githubusercontent.com/nanqinlang-script/testrace/master/testrace.sh |
三网测速脚本
其实最上面的那个superbenth脚本也能测速度,但是这个脚本是superbenth脚本的修复版,能测的节点比较多,但是只有国内节点测速。
脚本:
1 | bash <(curl -Lso- https://git.io/superspeed_uxh) |
其实测速最好的还是在vps上面自建一个speedtest测速,这个脚本比较复杂,有docker版本和普通脚本,普通的脚本容易报错,还是建议用docker自建一个测速
这里可以看这两篇文章:https://www.duangvps.com/archives/777
以及:https://www.duangvps.com/archives/491
常用测试配置和到国内三网速度:
1 | wget -qO- git.io/superbench.sh | bash |
国内外各区域速度测速:
1 | wget https://raw.githubusercontent.com/FunctionClub/ZBench/master/ZBench.sh && bash ZBench.sh |
融合怪脚本
这个脚本非常不错,虽然是个融合脚本但是有很多别的脚本测不了的东西,有网络信息,IP信息,解锁信息,常用端口开放信息,硬件信息等。关于IP质量问题除了这个以外,IP信息还可以去这里查询,结果非常详细:https://ipinfo.io/
github项目地址:https://github.com/spiritLHLS/ecs
脚本:
1 | bash <(wget -qO- --no-check-certificate https://gitlab.com/spiritysdx/za/-/raw/main/ecs.sh) |
或者是这个:
1 | bash <(wget -qO- --no-check-certificate https://github.com/spiritLHLS/ecs/raw/main/ecs.sh) |
unixbench性能测试
1 | wget --no-check-certificate https://github.com/teddysun/across/raw/master/unixbench.sh && chmod +x unixbench.sh && ./unixbench.sh |
然后等待程序进行测试即可,这个过程可能比较漫长,请耐心等待,最后跑完将会有一个分数在底部出现,通常情况下1000分以上的VPS是性能较好的。
https://blog.51cto.com/u_15060467/3822694
宝塔面板
- Centos
1 | curl -sSO https://raw.githubusercontent.com/zhucaidan/btpanel-v7.7.0/main/install/install_panel.sh && bash install_panel.sh |
- 屏蔽宝塔面板强制绑定手机号
1 | sed -i "s|bind_user == 'True'|bind_user == 'XXXX'|" /www/server/panel/BTPanel/static/js/index.js |
- 直接删除宝塔强制绑定手机JS文件
1 | rm -f /www/server/panel/data/bind.pl |
- 宝塔面板登录地址及账号查看命令
1 | bt default |
IP质量/解锁
IP 质量检测:
1 | bash <(curl -Ls IP.Check.Place) |
或
1 | bash <(wget -qO- bash.spiritlhl.net/ecs-ipcheck) |
流媒体解锁:
1 | bash <(curl -L -s media.ispvps.com) |
或
1 | bash <(curl -L -s check.unlock.media) |
或
1 | bash <(curl -Ls unlock.icmp.ing/scripts/test.sh) |
OpenAI 解锁检测:
1 | bash <(curl -Ls https://github.com/ludashi2020/OpenAI-Checker/raw/main/openai.sh) |
带宽测试
Hyperspeed 三网测速:
1 | bash <(curl -Lso- https://bench.im/hyperspeed) |
综合测速脚本 nws.sh:
1 | curl -sL nws.sh | bash |
多功能 自更新 测速脚本: 三网,含多线程,单线程等测速
1 | bash <(curl -sL bash.icu/speedtest) |
DD 磁盘测试 生成 5G 文件,顺序
1 | dd if=/dev/zero of=5gb bs=1M count=5120 |
生成 5G 文件,随机
1 | dd if=/dev/urandom of=5gb bs=1M count=5120 |
HTTP 单线程下载测试
服务端
启动简易 http 服务
1 | python3 -m http.server |
客户端
直接用浏览器下载或其他工具下载
建议用 edge 等浏览器
也可以试试 IDM 下载
替换下方 yourip 为你的 ip 地址
1 | wget http://yourip:8000/5gb |
删除测试文件
服务端删除文件:
1 | rm 5gb |
路由追踪
AutoTrace 回程路由 :
1 | wget -N --no-check-certificate https://raw.githubusercontent.com/Chennhaoo/Shell_Bash/master/AutoTrace.sh && chmod +x AutoTrace.sh && bash AutoTrace.sh |
BestTrace 回程路由:
进入后一键测试,北上广三网
1 | wget -qO- git.io/besttrace | bash |
BackTrace 回程路由:
1 | curl https://raw.githubusercontent.com/zhanghanyun/backtrace/main/install.sh -sSf | sh |
NextTrace 回程路由:
1 | curl nxtrace.org/nt |bash |
OpenTrace 回程路由:
OpenTrace 是 NextTrace 的跨平台 GUI 界面,带来您熟悉但更强大的用户体验。
https://github.com/Archeb/opentrace
Pingsx MTR 回程路由:
https://ping.sx/mtr
去程路由:
https://www.itdog.cn/traceroute/
https://tools.ipip.net/traceroute.php
延迟/丢包测试
Google/Facebook/X/Youtube/Netflix/Chatgpt/Github 延迟
1 | bash <(curl -sL https://nodebench.mereith.com/scripts/curltime.sh) |
Ping.pe
全球延迟,丢包
https://ping.pe
Pingsx Ping
在线 Ping,Port,DNS,MTR 等测试
https://ping.sx
Itdog Ping
https://www.itdog.cn/ping/
DD 重装脚本
系统默认为 debian12
leitbogioro 大佬的脚本(推荐) :
1 | 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 大佬的脚本 :
1 | bash <(wget --no-check-certificate -qO- 'https://raw.githubusercontent.com/MoeClub/Note/master/InstallNET.sh') -d 12 -v 64 -p 密码 -port 端口 -a -firmware |
beta.gs:
1 | wget --no-check-certificate -O NewReinstall.sh https://raw.githubusercontent.com/fcurrk/reinstall/master/NewReinstall.sh && chmod a+x NewReinstall.sh && bash NewReinstall.sh |
Nekoneko - DD 一键脚本:
1 | bash <(curl -Lso- http://sh.nekoneko.cloud/DD/AutoReinstall.sh) |