softroute/gateway/README.md
2025-12-02 00:10:47 +08:00

54 lines
1.5 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.

### 脚本功能说明
- **00_env.sh**
- 配置 WAN / LAN 网卡名、下层网段、SOCKS5 地址与端口、CHNROUTE 地址等。
- **10_dhcp_dns.sh**
- 安装 dnsmasq
- 下层 DHCP 分配 IP
- 国内域名直连 DNS 配置,提升国内访问速度
- **20_nat_forward.sh**
- 开启 IPv4 转发
- 配置 NAT 出口,允许下层网络访问上层网络
- **30_chnroute.sh**
- 下载最新 CHNROUTE 国内 IP 列表
- 创建 ipset `chnroute`
- 添加私有网段和国内 IP用于国内外分流
- **40_redsocks.sh**
- 安装 redsocks2
- 配置透明代理,将 TCP 流量重定向到 SOCKS5 代理
- 启动 systemd 服务,自动运行
- **50_dns_over_proxy.sh**
- 将国外 DNS 查询通过 redsocks2 转发,防止 DNS 污染
- 启动 systemd 服务,开机自启
- **60_iptables_rules.sh**
- 设置 iptables NAT 链和 REDSOCKS 链
- 国内 IP 直连,国外 TCP 流量重定向到 redsocks2
- 配合 CHNROUTE ipset 使用,实现国内外分流
- **90_status.sh**
- 查看 ipset 状态
- 查看 iptables NAT 状态
- 查看 redsocks 和 dnsmasq 服务状态
- 测试国内和国外域名解析
- **uninstall.sh**
- 停止并禁用所有服务
- 清理 iptables NAT 规则和 ipset
- 删除配置文件,回滚系统
---
## 3⃣ 部署步骤
1. 下载或复制 `generate_gateway.sh` 脚本到 Ubuntu 22.04 主机:
```bash
wget <你的脚本下载地址> -O generate_gateway.sh