Skip to content

Instantly share code, notes, and snippets.

@rocka
Last active August 22, 2017 06:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rocka/d9c35e9457abb11d643b0871704c12bc to your computer and use it in GitHub Desktop.
Save rocka/d9c35e9457abb11d643b0871704c12bc to your computer and use it in GitHub Desktop.
enable bbr in OpenVZ VPS
#!/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
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