什麼是net-speeder
簡單來說就是為解決網路掉封包的問題,最簡單粗暴的方法就是雙倍發送封包,即同一份資料包發送兩份。直接優點是降低丟包率,直接缺點是耗費雙倍流量,一定程度也能提高網絡速度。 https://github.com/snooda/net-speeder


 
 
 
 
可以把以下腳本複製成net_speed.sh
然後用root 執行net_speed.sh即可安裝

#!/bin/sh
 
# Set Linux PATH Environment Variables
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
 
# Check If You Are Root
if [ $(id -u) != "0" ]; then
clear
echo -e "\033[31m Error: You must be root to run this script! \033[0m"
exit 1
fi
 
if [ $(arch) == x86_64 ]; then
OSB=x86_64
elif [ $(arch) == i686 ]; then
OSB=i386
else
echo "\033[31m Error: Unable to Determine OS Bit. \033[0m"
exit 1
fi
if egrep -q "5.*" /etc/issue; then
OST=5
wget http://dl.fedoraproject.org/pub/epel/5/${OSB}/epel-release-5-4.noarch.rpm
elif egrep -q "6.*" /etc/issue; then
OST=6
wget http://dl.fedoraproject.org/pub/epel/6/${OSB}/epel-release-6-8.noarch.rpm
else
echo "\033[31m Error: Unable to Determine OS Version. \033[0m"
exit 1
fi
 
rpm -Uvh epel-release*rpm
yum install -y libnet libnet-devel libpcap libpcap-devel gcc
wget -c http://eric0703.pentaxfans.net/software/net_speeder.tar.gz && tar xf net_speeder.tar.gz
cd net_speeder
if [ -f /proc/user_beancounters ] || [ -d /proc/bc ]; then
sh build.sh -DCOOKED
INTERFACE=venet0
else
sh build.sh
INTERFACE=eth0
fi

NS_PATH=/usr/local/netspeeder
mkdir -p $NS_PATH
cp -Rf net_speeder $NS_PATH/net_speeder

echo "#!/bin/bash
#chkconfig: 345 85 15
#description: netspeeder start script.
### BEGIN INIT INFO
# Provides: LZH
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: The NetSpeeder
### END INIT INFO

start() {
nohup ${NS_PATH}/net_speeder $INTERFACE \"ip\" >/dev/null 2>&1 &
echo 'NetSpeeder Started!';
}

stop() {
sync;
for PID in \`ps aux|grep -E 'net_speeder'|grep -v grep|awk '{print \$2}'\`; do
kill -s 9 \$PID >/dev/null;
done;
echo 'NetSpeeder Stoped!';
}

case \"\$1\" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo \$\"Usage: \$prog {start|stop|restart}\"
exit 1
esac">/etc/rc.d/init.d/netspeederd
chmod 775 /etc/rc.d/init.d/netspeederd

chkconfig netspeederd on;

cd ..
rm -rf epel-release-5-4.noarch.rpm epel-release-6-8.noarch.rpm epel-release-5-4.noarch.rpm net_speeder

service netspeederd start
echo -e "\033[36m net_speeder installed. \033[0m"

 

VPS屬於OpenVZ架構,使用以下指令啟動net_speeder
/usr/bin/net_speeder venet0 "ip"
VPS屬於Xen,KVM架構,使用以下指令啟動net_speeder
/usr/bin/net_speeder eth0 "ip"
 
加到開機起動
vi /etc/rc.local
/usr/bin/net_speeder venet0 "ip"

/usr/bin/net_speeder eth0 "ip"

8051993228_e5654db8ba_o

Tags: , ,