Net-Speeder是一个“暴力”解决丢包的工具。他的工作原理是把数据包按照双倍的量去发送。既然你丢嘛,那我每个包多发点不就好了。
Net-Speeder还有一个好处就是支持OpenVZ (OVZ) 虚拟化架构,很多超便宜的小服务器就可以跑起来了。
提示:因为Net-Speeder是通过多倍发包实现低丢包高且可用性的网络,可能会违反部分服务商(IDC)的服务条款(TOS),请慎重。
需要消耗双倍或者更多的流量,现在很多的服务商都是单向流量,对于流量小的,也谨慎使用。
原版net-speeder需要自己编辑,这个脚本应该是脚本作者自己编辑好的,如果存在什么问题,可以自己手动编译。
github:https://github.com/snooda/net-speeder
原文:https://www.mengclaw.com/2020/03/03/598/
wget -O net_speeder.sh --no-check-certificate https://soft.mengclaw.com/Bash/net_speeder.sh
# 下载脚本
bash net_speeder.sh
# 运行脚本
脚本内容:
#!/bin/bash
# 判断系统版本
check_system_os(){
if [[ -f /etc/redhat-release ]];then
release="CentOS"
# -q 执行本条语句的时候不输出,-i 不区分大小写
elif cat /etc/issue | grep -q -i "debian";then
release="Debian"
elif cat /etc/issue | grep -q -i "ubuntu";then
release="Ubuntu"
else
release="Unknown"
echo -e "\n 系统不受支持,安装失败 \n"
exit 1
fi
}
# 检查是否是root账户
check_root(){
if [[ $EUID != 0 ]];then
echo -e " 当前非ROOT账号,无法继续操作。\n 请更换ROOT账号登录服务器。 "
exit 1
else
echo " 管理员权限检查通过 "
fi
}
# 安装系统依赖
dependent_install(){
if [[ $release == "CentOS" ]];then
yum -y makecache
yum -y install epel-release
yum -y install libnet libpcap libnet-devel libpcap-devel gcc unzip virt-what
elif [[ $release == "Debian" ]] || [[ $release == "Ubuntu" ]];then
apt-get -y update
apt-get -y install libnet1-dev libpcap0.8-dev gcc unzip virt-what
else
echo -e " 系统不受支持,安装失败 \n"
exit 1
fi
}
# 下载主程序
program_download(){
rm -rf net-speeder* Net_Speeder*
wget -O Net_Speeder.zip --no-check-certificate https://soft.mengclaw.com/Application/Net-Speeder/net-speeder-master.zip
}
# 解压缩
program_unzip(){
unzip Net_Speeder.zip
}
# 检查虚拟化
virt_check(){
if [[ -e '/tmp/net-speeder-install/virt.conf' ]];then
virt-what > /tmp/net-speeder-install/virt.conf
else
rm -rf /tmp/net-speeder-install
mkdir /tmp/net-speeder-install
touch /tmp/net-speeder-install/virt.conf
virt-what > /tmp/net-speeder-install/virt.conf
fi
}
# 检查网卡名称
nic_name_check(){
if [[ -e '/tmp/net-speeder-install/nic.conf' ]];then
if [[ `cat /tmp/net-speeder-install/virt.conf` == "openvz" ]];then
echo "venet0" > /tmp/net-speeder-install/nic.conf
else
ip add|grep "state UP"|egrep "eth[0-9]|net[0-9]|ens[0-9]"|awk -F ": " '{print $2}' > /tmp/net-speeder-install/nic.conf
fi
else
touch /tmp/net-speeder-install/nic.conf
if [[ `cat /tmp/net-speeder-install/virt.conf` == "openvz" ]];then
echo "venet0" > /tmp/net-speeder-install/nic.conf
else
ip add|grep "state UP"|egrep "eth[0-9]|net[0-9]|ens[0-9]"|awk -F ": " '{print $2}' > /tmp/net-speeder-install/nic.conf
fi
fi
}
# 编译
program_compile(){
if [[ `cat /tmp/net-speeder-install/virt.conf` == "openvz" ]];then
sh net-speeder-master/build.sh -DCOOKED
rm -rf /usr/local/bin/net_speeder
cp net-speeder-master/net_speeder /usr/local/bin
else
sh net-speeder-master/build.sh
rm -rf /usr/local/bin/net_speeder
cp net-speeder-master/net_speeder /usr/local/bin
fi
}
# 运行
program_run(){
nic_name=`cat /tmp/net-speeder-install/nic.conf|head -1`
net_speeder $nic_name "ip" >/dev/null 2>&1 &
}
# 清理安装过程中产生的文件
after_installl(){
rm -rf Net_Speeder.zip net-speeder-master
}
# 卸载
uninstall(){
rm -rf /usr/local/bin/net_speeder
rm -rf Net_Speeder.zip net-speeder-master
}
# 运行状态检查
program_run_status(){
if [[ `ps -ef |grep -v grep|grep -v bash|grep net_speeder|grep -c 'net_speeder'` -ge 1 ]];then
echo -e "\n 程序已运行,进程信息:\n"
ps -ef |grep -v grep|grep -v bash|grep net_speeder
echo -e "\n 考虑到稳定性问题,程序开机不会自启动。如果下次开机需要运行本程序,请重新运行本脚本。\n 运行方式:\n\nbash net_speeder.sh\n"
else
echo -e "\n 程序未运行 \n"
sleep 1
exit 1
fi
}
# 检查PID
check_pid(){
pid=`ps -ef |grep -v grep|grep net_speeder|awk '{print $2}'`
}
############################################################
# 安装
program_install(){
if [[ -s /usr/local/bin/net_speeder ]];then
echo " 程序已安装 "
exit 1
else
check_root
sleep 1
check_system_os
echo -e "\n 当前系统:"$release
sleep 1
echo -e "\n 开始安装依赖环境\n "
sleep 1
dependent_install
sleep 1
echo -e "\n 依赖环境安装结束,开始下载Net-Speeder程序\n "
sleep 1
program_download
sleep 1
echo -e "\n 下载完成,开始解压\n "
sleep 1
program_unzip
sleep 1
echo -e "\n 解压完成,开始检查虚拟化 "
sleep 1
virt_check
sleep 1
echo -e "\n 检查虚拟化完成,开始检查网卡名称 "
sleep 1
nic_name_check
sleep 1
echo -e "\n 检查网卡名称完成,开始编译程序 "
sleep 1
program_compile
sleep 1
echo -e "\n 编译程序完成,开始启动程序 "
sleep 1
program_run
echo -e "\n 启动程序完成,开始判断是否正常运行 "
sleep 1
program_run_status
after_installl
fi
}
# 卸载
program_uninstall(){
if [[ -s /usr/local/bin/net_speeder ]];then
check_pid
uninstall
echo " 卸载完成!"
kill -9 $pid >/dev/null 2>&1 &
else
echo " 程序未安装 "
exit 1
fi
}
# 运行(多次运行效果叠加)
program_start(){
virt_check
nic_name_check
program_run
program_run_status
}
# 停止
program_stop(){
check_pid
kill -9 $pid
}
############################################################
echo -e " -------------------------"
echo -e " 一键安装Net-Speeder程序"
echo -e " 版本:2.0"
echo -e " 作者:WolfSkylake "
echo -e " -------------------------"
echo -e "\n 部署操作:"
echo -e " 1、安装Net-Speeder"
echo -e " 2、卸载Net-Speeder"
echo -e "\n 管理操作:"
echo -e " 3、运行Net-Speeder"
echo -e " 4、停止Net-Speeder"
echo -e " 5、检查运行状态\n"
echo -e " -------------------------"
read -p " 请输入数字 [1-5]:" num
case "$num" in
1)
program_install
;;
2)
program_uninstall
;;
3)
program_start
;;
4)
program_stop
;;
5)
program_run_status
;;
esac
############################################################
上一篇:
命令行中实时查询当前全球最新的疫情报告下一篇:
使用mosh代替ssh优化链接