# 网络隧道说明

## 网络隧道配置

使用SSH建立隧道作为代理比较复杂，为了简化操作，这里共享使用一个已经建立好的隧道连接。

登陆到服务器后，选择20进入容器，输入一个代理端口号（共享隧道端口号为1080）。

![在容器中使用隧道代理](/files/-Lyh4XbDeaqnIjtc408W)

容器中默认已经安装了proxychains，如果没有安装，运行下面命令安装：

```bash
cd /root/shared/downloads/ # *.deb存放在shared/downloads目录，如果找不到可以自己在本地下载后用sftp传到服务器安装
dpkg -i libproxychains4_4.14-1_amd64.deb proxychains4_4.14-1_amd64.deb
```

编辑配置文件vim /etc/proxychains4.conf，最后一行改为如下(其中1080为共享的隧道端口，自建隧道需修改)：

```bash
socks5  127.0.0.1 1080
```

测试和使用代理：

```bash
# 测试
proxychains curl ip.sb
# 使用
proxychains bash
```

{% hint style="info" %}
共享的端口为1080的隧道代理走的是管理员个人流量，注意避免大流量下载。
{% endhint %}

{% hint style="info" %}
为了给容器提供网络，需要先在本地和宿主机间建立隧道，再在宿主机和容器间建立隧道。

* Linux和macOS下建立本地和服务器间的隧道：ssh -D 10888 localhost -t ssh -R 10800:localhost:10888 \<user>@\<ip> -p \<port>
* Windows下本地和服务器间的隧道建立可以参考Fancy录制的视频：<http://datasci.tju.edu.cn/s/demo_windows.mp4>
* 自建隧道不要再用1080-1090之间的端口，可以使用高位端口如40001
  {% endhint %}


---

# 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://docs.aiskyeye.com/manual/ssh-tunnel.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.
