# 云梯

## VPN服务器

1. 从 <https://my.vultr.com/> 购买一个centos服务器，服务器每个月给1000G的流量包，足够使用了

   **配置VPN服务器**

   ```bash
   # 下载python2.7
   yum install python2
   # 建个软件接
   ln -s /usr/bin/python2.7 /usr/bin/python
   ```

   **安装shadowsocks服务**

   可以从这个博客了解一下什么是shadowsocks <http://www.devtalking.com/articles/shadowsocks-guide/>

   下载地址 <https://pypi.org/project/shadowsocks/>

   ```python
   # 直接使用pip下载
   pip install shadowsocks
   ```

   **使用配置文件启动`shadowsocks`服务**

   配置文件 `/etc/shadowsocks.json`

   ```javascript
   {
       "server":"IP字符串",
       "server_port":8388,
       "local_port":1080,
       "password":"设置一个连接密码",
       "timeout":600,
       "method":"aes-256-cfb",
       "auth": true
   }
   ```

   **启动服务**

   报错的解决办法 <https://blog.csdn.net/weixin_39220714/article/details/86729935>

   将`cleanup`全部替换为`reset`

   ```bash
   # 启动服务
   ssserver -c /etc/shadowsocks.json -d start
   # 关闭服务
   ssserver -c /etc/shadowsocks.json -d stop
   # 重启
   ssserver -c /etc/shadowsocks.json -d restart
   ```

   **客户端连接的时候老是没有反应**防火墙堵了，干脆直接把防火墙关了

   参考 <https://blog.csdn.net/bbwangj/article/details/74502967>

   我的centos8是 **firewall防火墙**

   ```bash
   # 开启
   service firewalld start
   # 重启
   service firewalld restart
   # 关闭
   service firewalld stop
   ```

   查看服务端的运行日志

   ```bash
   less /var/log/shadowsocks.log
   ```

## 客户端配置

下载对应版本的客户端 <https://github.com/shadowsocks/shadowsocks-windows/releases>

安卓版 <https://github.com/shadowsocks/shadowsocks-android>

之后之间进行连接，配置信息和 `shadowsocks.json` 文件一一对应好就行

### 客户端报错

```
2019-11-10 19:48:58] System.Reflection.TargetInvocationException: 操作过程中出现异常，结果无效。  有关异常的详细信息，请查看 InnerException。 ---> System.Net.WebException: 基础连接已经关闭: 发送时发生错误。 ---> System.IO.IOException: 由于远程方已关闭传输流，身份验证失败。
   在 System.Net.TlsStream.EndWrite(IAsyncResult asyncResult)
   在 System.Net.PooledStream.EndWrite(IAsyncResult asyncResult)
   在 System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar)
   --- 内部异常堆栈跟踪的结尾 ---
```

### 解决

参考官方说明 <https://github.com/shadowsocks/shadowsocks-windows/wiki/Troubleshooting>

* Sometimes the `Winsock` and `TCP/IP` protocol is corrupted for some reason. Please execute the following command with Administrator privilege in `CMD`. Then reboot./有时候系统的`Winsock`和`TCP/IP`协议栈因未知原因损坏，请以管理员权限在`CMD`中执行以下命令，然后重启：

```
netsh interface ipv4 reset
netsh interface ipv6 reset
netsh winsock reset
```

## 连接时访问慢的原因可能是端口被运营商封闭的原因

登录到运营商那里，打开端口就ok了


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://zpliu.gitbook.io/booknote/linux/yun-ti.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
