type
status
date
slug
tags
summary
category
password
icon
校园网→公网
我们的服务器都在北大校园网,可以直接连接北大校园网内的一切资源。如果你想访问网络,则需要在服务器上登录。linux上我们给出一个登录校园网的python脚本:需要校园网的用户名和密码。今后计算中心可能提供新方法。
公网→外网
- 执行
wget -O config.yml https://s.suying666.info/link/lAMFcyqpHxkSbAdg?clash=1&log-level=info
下载 Clash 配置文件
- 执行
mkdir clash && cd clash
在用户目录下创建 clash 文件夹。
- 下载适合的Clash二进制文件如clash-linux-amd64-v1.18.0.gz
- 解压重命名为clash:
gzip -d clash-linux-amd64-v1.18.0.gz && mv clash-linux-amd64-v1.18.0 clash
- 执行
./clash -d .
即可启动 Clash,同时启动 HTTP 代理和 Socks5 代理。 - 如提示权限不足,请执行
chmod +x clash
- 在执行过程中,会提示正在下载
Country.mmdb
文件,等待下载完成,使用Ctrl+C退出Clash程序,此时可以在目录~/.config/clash/
下发现三个文件:cache.db
、config.yaml
和Country.mmdb
。我们需要将我们准备好的config.yaml
替换生成出来的config.yaml
,这样就替换了Clash的配置文件。
- 访问 Clash Dashboard 可以进行切换节点、测延迟等操作。Host:
127.0.0.1
,端口:9090
- 以 Ubuntu 19.04 为例,打开系统设置,选择网络,点击网络代理右边的 ⚙ 按钮,选择手动,填写 HTTP 和 HTTPS 代理为
127.0.0.1:7890
,填写 Socks 主机为127.0.0.1:7891
,即可启用系统代理。
ssh proxy
MacOS:
- 在你的clashX上查看proxy port:Settings/Settings/General/Proxy Port,通常是7890
- 安装squidman
- 打开squidman,在Settings/Preferences/general设置HTTP Port:7890,save
- 点击start squid
- 在vscode ssh config正常登陆的脚本下插入
RemoteForward 3129 127.0.0.1:7890
vim ~/.bashrc
7.
source ~/.bashrc
- 要取消代理,您可以使用
unset
命令来取消之前设置的环境变量。具体操作如下:
执行以上命令后,之前设置的代理就会被取消。如果您是在脚本中设置的代理,确保在脚本执行完成后取消代理,以免影响其他应用的网络连接。如果是在shell中设置的代理,只要关闭当前的shell会话,代理设置也会消失。如果希望代理在所有会话和重启后都有效,就需要在像
~/.bashrc
或 ~/.profile
这样的配置文件中设置,取消时也同样需要在这些文件中删除对应的设置。Windows/linux
- 安装 Squid 作为proxy server. See http://www.squid-cache.org/. (Squid没有MacOS版本,MacOS用户可以安装Squidman)
- 将/etc/squid/squid.conf (in Linux,in Windows, open squid.configuration, for Squidman, open Preference → template) 中的
http_access deny all
换成http_access allow all
在

- 对于Squidman,需要将Preference → General → Http_port设置为本地机代理端口(例如6.中的3128)。
- 如果你翻墙的代理服务器端口在7890,则你可以在squid的设置里加入。如果不翻墙就不用
- stop squid service, start squid service,让设置生效。
- 创建ssh隧道
在服务器一侧
- Add the following entries to ~/.bashrc
source ~/.bashrc
or directly execute command
检测联网是否成功
FAQ
- What is 3129?
3129 is the server port. You can use any other port. However, don’t forget to set the environment variable
http_proxy
and https_proxy
to the server port and the squid port to the laptop port.- Error: Connection reset by peers.
If you see a warning on the port when logging in, maybe the port you use has been used by other programs. Just change the port.
- 作者:GraphPKU
- 链接:graphpku.cn/article/a25127cc-6e16-4840-9f99-d78c4932cb17
- 声明:本文采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。