[关闭]
@ferstar 2016-04-09T21:08:55.000000Z 字数 1992 阅读 9199

AWS EC2搭梯子记录(仅备忘, 非教程)

EC2 梯子


注册

需要绑定信用卡
https://aws.amazon.com/cn/

因为免费配额有限, 为防止超出配额被收费, 最好设定下配额超限的邮件提醒

创建一个 EC2 服务实例

建议 Ubuntu 节点选择韩国或者日本

安全组设置入站规则

需要开放 ssh/22, ss/xxx(梯子端口)

xshell 直接导入 pem 密钥

注意 Ubuntu 登录用户名是 ubuntu

装梯子

  1. Add GPG public key:
  2. wget -O- http://shadowsocks.org/debian/1D27208A.gpg | sudo apt-key add -
  3. Add either of the following lines to your /etc/apt/sources.list:
  4. # Ubuntu 14.04 or above
  5. deb http://shadowsocks.org/ubuntu trusty main
  6. # Debian Wheezy, Ubuntu 12.04 or any distribution with libssl > 1.0.1
  7. deb http://shadowsocks.org/debian wheezy main
  8. Then:
  9. sudo apt-get update
  10. sudo apt-get install shadowsocks-libev

梯子配置

sudo vi /etc/shadowsocks-libev/config.json

  1. {
  2. "server":"0.0.0.0",
  3. "server_port":listen port,
  4. "password":"your passwd",
  5. "timeout":300,
  6. "method":"encrypt type",
  7. "fast_open": true
  8. }

开梯子

  1. # 启动
  2. sudo service shadowsocks-libev start
  3. # 停
  4. sudo service shadowsocks-libev stop

优化梯子

参考https://www.zxc.so/shadowsocks-ladder.html

sudo vi /etc/sysctl.d/local.conf

  1. # max open files
  2. fs.file-max = 51200
  3. # max read buffer
  4. net.core.rmem_max = 67108864
  5. # max write buffer
  6. net.core.wmem_max = 67108864
  7. # default read buffer
  8. net.core.rmem_default = 65536
  9. # default write buffer
  10. net.core.wmem_default = 65536
  11. # max processor input queue
  12. net.core.netdev_max_backlog = 4096
  13. # max backlog
  14. net.core.somaxconn = 4096
  15. # resist SYN flood attacks
  16. net.ipv4.tcp_syncookies = 1
  17. # reuse timewait sockets when safe
  18. net.ipv4.tcp_tw_reuse = 1
  19. # turn off fast timewait sockets recycling
  20. net.ipv4.tcp_tw_recycle = 0
  21. # short FIN timeout
  22. net.ipv4.tcp_fin_timeout = 30
  23. # short keepalive time
  24. net.ipv4.tcp_keepalive_time = 1200
  25. # outbound port range
  26. net.ipv4.ip_local_port_range = 10000 65000
  27. # max SYN backlog
  28. net.ipv4.tcp_max_syn_backlog = 4096
  29. # max timewait sockets held by system simultaneously
  30. net.ipv4.tcp_max_tw_buckets = 5000
  31. # TCP receive buffer
  32. net.ipv4.tcp_rmem = 4096 87380 67108864
  33. # TCP write buffer
  34. net.ipv4.tcp_wmem = 4096 65536 67108864
  35. # turn on path MTU discovery
  36. net.ipv4.tcp_mtu_probing = 1
  37. # for low-latency network
  38. net.ipv4.tcp_congestion_control = htcp
  39. #net.ipv4.tcp_congestion_control = hybla
  40. # turn on TCP Fast Open on both client and server side
  41. net.ipv4.tcp_fastopen = 3

sudo /etc/init.d/procps restart

sudo vi /etc/modules

最下面添加一行

  1. tcp_htcp

sudo modprobe tcp_htcp

enjoy

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注