Last active
August 22, 2017 06:58
-
-
Save rocka/d9c35e9457abb11d643b0871704c12bc to your computer and use it in GitHub Desktop.
enable bbr in OpenVZ VPS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
fuser -k /dev/net/tun | |
# delete tap0 | |
ip tuntap del dev tap0 mode tap | |
# add tap0 | |
ip tuntap add dev tap0 mode tap | |
ip link set dev tap0 up | |
ip addr add dev tap0 10.0.0.1/24 | |
sysctl -w net.ipv4.ip_forward=1 | |
iptables -P FORWARD ACCEPT | |
# delete old iptables rules | |
#iptables -t nat -D POSTROUTING -o venet0 -j MASQUERADE | |
iptables -t nat -D PREROUTING -i venet0 -p tcp --dport 11840 -j DNAT --to-destination 10.0.0.2 | |
# add iptables rules | |
#iptables -t nat -A POSTROUTING -o venet0 -j MASQUERADE | |
iptables -t nat -A PREROUTING -i venet0 -p tcp --dport 11840 -j DNAT --to-destination 10.0.0.2 | |
LD_PRELOAD=/root/haproxy/liblkl-hijack.so \ | |
LKL_HIJACK_NET_QDISC="root|fq" \ | |
LKL_HIJACK_SYSCTL="net.ipv4.tcp_congestion_control=bbr;net.ipv4.tcp_wmem=4096 65536 67108864" \ | |
LKL_HIJACK_NET_IFTYPE="tap" \ | |
LKL_HIJACK_NET_IFPARAMS="tap0" \ | |
LKL_HIJACK_NET_IP="10.0.0.2" \ | |
LKL_HIJACK_NET_NETMASK_LEN="24" \ | |
LKL_HIJACK_NET_GATEWAY="10.0.0.1" \ | |
LKL_HIJACK_OFFLOAD="0x8883" \ | |
haproxy -f /root/haproxy/haproxy.cfg & | |
exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global | |
user haproxy | |
group haproxy | |
defaults | |
mode tcp | |
timeout connect 5s | |
timeout client 60s | |
timeout server 60s | |
listen shadowsocks | |
bind 10.0.0.2:11840 | |
server server1 10.0.0.1:1184 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment