Files
notebook/docs/技术/旁路由使用/Linux.md
T

67 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Linux 旁路由使用指南
> 适用于 Ubuntu、Debian、Fedora 等桌面发行版。
---
## 接入旁路由
### 系统代理(GNOME
1. 打开 **设置 → 网络 → 代理**
2. 选择 **手动**
3. 填写:
| 字段 | 值 |
|------|-----|
| SOCKS 代理 | `127.0.0.1` |
| 端口 | `7890` |
?> DNS 会自动使用 AdGuard(因为旁路由本机 DNS 已设为 `127.0.0.1`)。
### 终端代理(可选)
如果需要在终端里走代理,设置环境变量:
```bash
export ALL_PROXY=socks5://127.0.0.1:7890
```
或者写入 `~/.bashrc` 持久化:
```bash
echo 'alias proxy="export ALL_PROXY=socks5://127.0.0.1:7890"' >> ~/.bashrc
echo 'alias unproxy="unset ALL_PROXY"' >> ~/.bashrc
```
用的时候 `proxy` 开启,`unproxy` 关闭。
---
## 验证
```bash
# 测试代理是否通
curl --socks5 127.0.0.1:7890 https://www.google.com -o /dev/null -s -w '%{http_code}'
# 返回 200 → 正常
# 测试 DNS 去广告
nslookup doubleclick.net
# 返回 0.0.0.0 → 广告域名已被拦截
```
---
## 服务管理
旁路由本机就是服务器,所以日常管理命令也在这里执行:
```bash
sudo systemctl restart sing-box # 重启翻墙
sudo systemctl status sing-box # 查看状态
sudo journalctl -u sing-box -f # 实时日志
docker restart adguardhome # 重启去广告
docker logs adguardhome -f # 去广告日志
```