-
Notifications
You must be signed in to change notification settings - Fork 388
/
BBR.sh
64 lines (52 loc) · 7.14 KB
/
BBR.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
FORCE="$1"
REBOOT="${2:-1}"
echo 'Build: tcp_bbr.ko'
# bash <(wget --no-check-certificate -qO- 'https://raw.githubusercontent.com/MoeClub/BBR/master/build.sh') "$FORCE"
bash <(echo "IyEvYmluL2Jhc2gKIyBCeSBNb2VDbHViCgpbICIkMSIgIT0gIi1mIiBdICYmIFsgISAtZiAiL2xpYi9tb2R1bGVzLyQodW5hbWUgLXIpL2tlcm5lbC9uZXQvaXB2NC90Y3BfYmJyLmtvIiBdICYmIGVjaG8gIlRoaXMgS2VybmVsIE5vdCBTdXBwb3J0IEJCUiBieSBEZWZhdWx0LiIgJiYgZXhpdCAxCgppbnN0YWxsRGVwPSgpCmZvciBkZXAgaW4gJChlY2hvICJnY2MsbWFrZSIgfHNlZCAncy8sL1xuL2cnKTsgZG8gY29tbWFuZCAtdiAiJHtkZXB9IiA+L2Rldi9udWxsIHx8IGluc3RhbGxEZXArPSgiJHtkZXB9Iik7IGRvbmUKbHMgLTEgIi91c3Ivc3JjIiB8Z3JlcCAtcSAiXmxpbnV4LWhlYWRlcnMtJCh1bmFtZSAtcikiIHx8IGluc3RhbGxEZXArPSgibGludXgtaGVhZGVycy0kKHVuYW1lIC1yKSIpCgppZiBbICIkeyNpbnN0YWxsRGVwW0BdfSIgLWd0IDAgXTsgdGhlbgogIGFwdCB1cGRhdGUKICBhcHQgaW5zdGFsbCAteSAiJHtpbnN0YWxsRGVwW0BdfSIKICBpZiBbICQ/IC1uZSAwIF07IHRoZW4KICAgIGVjaG8gIkluc3RhbGwgUGFja2FnZSBGYWlsLiIKICAgIGV4aXQgMQogIGZpCmZpCgprZ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VElPTihbXjtdKjt8TU9EVUxFX0RFU0NSSVBUSU9OKCJUQ1AgQkJSIChCb3R0bGVuZWNrIEJhbmR3aWR0aCBhbmQgUlRUKSBbU1Y6ICckKGRhdGUgKyVZLyVtLyVkKScgSW5zdGFsbGVkXSIpO3xnJyAvdG1wL3RjcF9iYnIuYwoKY2QgL3RtcAptYWtlICYmIG1ha2UgaW5zdGFsbAoKCgo=" |base64 -d) "$FORCE"
[ $? -ne 0 ] && echo "Build: Fail" && exit 1
echo 'Setting: limits.conf'
[ -f /etc/security/limits.conf ] && LIMIT='262144' && sed -i '/^\(\*\|root\)[[:space:]]*\(hard\|soft\)[[:space:]]*\(nofile\|memlock\)/d' /etc/security/limits.conf && echo -ne "*\thard\tmemlock\t${LIMIT}\n*\tsoft\tmemlock\t${LIMIT}\nroot\thard\tmemlock\t${LIMIT}\nroot\tsoft\tmemlock\t${LIMIT}\n*\thard\tnofile\t${LIMIT}\n*\tsoft\tnofile\t${LIMIT}\nroot\thard\tnofile\t${LIMIT}\nroot\tsoft\tnofile\t${LIMIT}\n\n" >>/etc/security/limits.conf
[ -f /etc/systemd/system.conf ] && sed -i 's/#\?DefaultLimitNOFILE=.*/DefaultLimitNOFILE=262144/' /etc/systemd/system.conf
echo 'Setting: sysctl.conf'
cat >/etc/sysctl.conf<<EOF
# This line below add by user.
fs.file-max = 104857600
fs.nr_open = 1048576
vm.overcommit_memory = 1
net.core.somaxconn = 65535
net.core.optmem_max = 262144
net.core.rmem_max = 8388608
net.core.wmem_max = 8388608
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.netdev_max_backlog = 65536
net.ipv4.tcp_mem = 4096 262144 8388608
net.ipv4.tcp_rmem = 4096 262144 8388608
net.ipv4.tcp_wmem = 4096 262144 8388608
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_syn_retries = 3
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_max_syn_backlog = 65535
net.ipv4.tcp_fin_timeout = 16
net.ipv4.tcp_keepalive_intvl = 32
net.ipv4.tcp_keepalive_probes = 3
net.ipv4.tcp_keepalive_time = 900
net.ipv4.tcp_retries1 = 3
net.ipv4.tcp_retries2 = 8
net.ipv4.tcp_no_metrics_save = 1
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv4.ip_forward = 1
net.ipv4.icmp_echo_ignore_all = 1
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv4.tcp_fastopen = 0
net.ipv4.tcp_fack = 1
net.ipv4.tcp_sack = 1
net.ipv4.tcp_dsack = 1
net.ipv4.tcp_ecn = 0
net.ipv4.tcp_ecn_fallback = 1
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
EOF
[ "$REBOOT" -eq "1" ] && reboot