<commit_before>---
layout: post  
title:  自备SS梯子  
category: blog  
tags: [随想]  
---  
 
撸了个Linode VPS  (CentOS 7)   
### 1.  登录VPS  

>wget --no-check-certificate https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks.sh   
chmod +x shadowsocks.sh  
./shadowsocks.sh 2>&1 | tee shadowsocks.log  

### 2.  安装完成后，脚本提示如下  

>Congratulations, shadowsocks install completed!  
Your Server IP:your_server_ip  
Your Server Port:8989  
Your Password:<PASSWORD>  
Your Local IP:127.0.0.1  
Your Local Port:1080  
Your Encryption Method:aes-256-cfb  
Welcome to visit:http://teddysun.com/342.html  
Enjoy it!  

### 3.  卸载方法  

>./shadowsocks.sh uninstall    

### 4.  配置文件  

> vi /etc/shadowsocks.json   

单用户配置：  

>{  
    "server":"your_server_ip",  
    "server_port":8989,  
    "local_address":"127.0.0.1",  
    "local_port":1080,  
    "password":"<PASSWORD>",  
    "timeout":300,  
    "method":"aes-256-cfb",  
    "fast_open": false  
}  

多用户配置：  

>{  
    "server":"your_server_ip",  
    "local_address": "127.0.0.1",  
    "local_port":1080,  
    "port_password":{  
         "8989":"<PASSWORD>",  
         "9001":"password1",  
         "9002":"<PASSWORD>",  
         "9003":"<PASSWORD>",  
         "9004":"<PASSWORD>"  
    },  
    "timeout":300,  
    "method":"aes-256-cfb",  
    "fast_open": false  
}  

### 5.  相关使用命令  

> /etc/init.d/shadowsocks start/stop/restart/status  

### 6.  防火墙设置  
  
在centos版本的更新迭代过程中，centos7和centos6之间的差异性较大。在centos7，采用的是最新的防火墙filewall而不是传统的iptables  

#### 1.  Iptables  

>iptables -A INPUT -p tcp –dport 443 -j ACCEPT  
service iptables restart

#### 2.  firewall  

>vi etc/firewalled/zones/public.xml  
add \<port protocol="tcp" port="449"/>  
add \<portprotocol="udp" port="443"/>  
systemctrl firewall restart  

### 7.  TCP优化  

#### 1.  增加tcp连接数量  

>vi /etc/security/limits.conf  
add * soft nofile 51200  
add * hard nofile 51200  

开启ss服务之前，先设置一下ulimit

>ulimit -n 51200

#### 2.  调整内核参数

>vi /etc/sysctl.conf  
fs.file-max = 51200  
\#提高整个系统的文件限制  
net.core.rmem_max = 67108864  
net.core.wmem_max = 67108864  
net.core.netdev_max_backlog = 250000  
net.core.somaxconn = 3240000  
net.ipv4.tcp_syncookies = 1  
net.ipv4.tcp_tw_reuse = 1  
net.ipv4.tcp_tw_recycle = 0  
net.ipv4.tcp_fin_timeout = 30  
net.ipv4.tcp_keepalive_time = 1200  
net.ipv4.ip_local_port_range = 10000 65000  
net.ipv4.tcp_max_syn_backlog = 8192  
net.ipv4.tcp_max_tw_buckets = 5000  
net.ipv4.tcp_fastopen = 3  
net.ipv4.tcp_rmem = 4096 87380 67108864  
net.ipv4.tcp_wmem = 4096 65536 67108864  
net.ipv4.tcp_mtu_probing = 1  
\#net.ipv4.tcp_congestion_control = hybla  

>sysctl -p  

---
<commit_msg>Update _posts/2016-11-30-自备SS梯子.md<commit_after>---
layout: post  
title:  自备SS梯子  
category: blog  
tags: [随想]  
---  


撸了个Linode VPS  (CentOS 7)   
### 1.  登录VPS  

	wget --no-check-certificate https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks.sh
	chmod +x shadowsocks.sh
	./shadowsocks.sh 2>&1 | tee shadowsocks.log    

### 2.  安装完成后，脚本提示如下  

	Congratulations, shadowsocks install completed!
	
	Your Server IP:your_server_ip
	Your Server Port:8989
	Your Password:<PASSWORD>
	Your Local IP:127.0.0.1
	Your Local Port:1080
	Your Encryption Method:aes-256-cfb
	
	Welcome to visit:http://teddysun.com/342.html
	Enjoy it!   

### 3.  卸载方法  

	./shadowsocks.sh uninstall    

### 4.  配置文件  

	vi /etc/shadowsocks.json   

单用户配置：  

	{
		"server":"your_server_ip",
		"server_port":8989,
		"local_address":"127.0.0.1",
		"local_port":1080,
		"password":"<PASSWORD>",
		"timeout":300,
		"method":"aes-256-cfb",
		"fast_open": false
	}

多用户配置：  

	{
    	"server":"your_server_ip",
    	"local_address": "127.0.0.1",
    	"local_port":1080,
    	"port_password":{
         	"8989":"<PASSWORD>",
         	"9001":"<PASSWORD>",
         	"9002":"<PASSWORD>",
         	"9003":"<PASSWORD>", 
         	"9004":"<PASSWORD>"
    	},
    	"timeout":300,
    	"method":"aes-256-cfb",
    	"fast_open": false
	}

### 5.  相关使用命令  

	/etc/init.d/shadowsocks start/stop/restart/status  

### 6.  防火墙设置  
  
在centos版本的更新迭代过程中，centos7和centos6之间的差异性较大。在centos7，采用的是最新的防火墙filewall而不是传统的iptables  

#### 1.  Iptables  

	iptables -A INPUT -p tcp –dport 443 -j ACCEPT
	
	service iptables restart

#### 2.  firewall  

	vi etc/firewalled/zones/public.xml
	
	add <port protocol="tcp" port="449"/>
		<portprotocol="udp" port="443"/>
	
	systemctrl firewall restart

### 7.  TCP优化  

#### 1.  增加tcp连接数量  

	vi /etc/security/limits.conf
	
	add * soft nofile 51200
		* hard nofile 51200

开启ss服务之前，先设置一下ulimit

	ulimit -n 51200

#### 2.  调整内核参数

	vi /etc/sysctl.conf
	
	fs.file-max = 51200
	#提高整个系统的文件限制
	net.core.rmem_max = 67108864
	net.core.wmem_max = 67108864
	net.core.netdev_max_backlog = 250000
	net.core.somaxconn = 3240000
	net.ipv4.tcp_syncookies = 1
	net.ipv4.tcp_tw_reuse = 1
	net.ipv4.tcp_tw_recycle = 0
	net.ipv4.tcp_fin_timeout = 30
	net.ipv4.tcp_keepalive_time = 1200
	net.ipv4.ip_local_port_range = 10000 65000
	net.ipv4.tcp_max_syn_backlog = 8192
	net.ipv4.tcp_max_tw_buckets = 5000
	net.ipv4.tcp_fastopen = 3
	net.ipv4.tcp_rmem = 4096 87380 67108864
	net.ipv4.tcp_wmem = 4096 65536 67108864
	net.ipv4.tcp_mtu_probing = 1
	#net.ipv4.tcp_congestion_control = hybla
	
	sysctl -p

---

{'fraction_non_alphanumeric': 0.13889943074003794, 'fraction_numerical': 0.08785578747628084, 'mean_word_length': 2.9871406959152798, 'pattern_counts': {'":': 40, '<': 20, '<?xml version=': 0, '>': 35, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 6, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5431343', 'n_tokens_mistral': 2719, 'n_tokens_neox': 2419, 'n_words': 373}