2025-01-02 18:03:26 +08:00
|
|
|
|
# DenyIP
|
|
|
|
|
|
|
|
|
|
## 概述
|
|
|
|
|
|
2025-01-08 09:46:07 +08:00
|
|
|
|
`DenyIP` 是一个用于保护大陆服务器免受非本地业务访问的防火墙工具。
|
|
|
|
|
该工具能够高效地捕获网络数据包、提取源IP地址、进行地理位置判断,从而严格限制非大陆来源的访问。
|
2025-01-02 18:03:26 +08:00
|
|
|
|
|
|
|
|
|
### 构建项目
|
|
|
|
|
|
|
|
|
|
克隆项目仓库:
|
|
|
|
|
|
|
|
|
|
```bash
|
2025-01-08 16:01:08 +08:00
|
|
|
|
apt-get install ipset
|
|
|
|
|
apt-get install libpcap-dev
|
|
|
|
|
|
2025-01-06 17:13:16 +08:00
|
|
|
|
git clone https://git.aixiao.me/aixiao/DenyIP-go.git
|
2025-01-02 18:03:26 +08:00
|
|
|
|
cd DenyIP-go
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 构建
|
|
|
|
|
|
|
|
|
|
编译项目:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
go build -o denyip
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 命令行选项
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
root@NIUYULING:/mnt/c/Users/root/Desktop/git.aixiao.me/DenyIP-go# ./denyip -h
|
|
|
|
|
Denyip firewall
|
|
|
|
|
Version 0.1
|
|
|
|
|
E-mail: aixiao@aixiao.me
|
|
|
|
|
Date: 20250102
|
|
|
|
|
Usage of ./denyip:
|
|
|
|
|
-child
|
|
|
|
|
子进程模式
|
|
|
|
|
-d 守护进程模式
|
|
|
|
|
-f string
|
|
|
|
|
指定 BPF 过滤器 (default "tcp")
|
|
|
|
|
-h
|
|
|
|
|
-help
|
2025-01-08 09:46:07 +08:00
|
|
|
|
帮助信息
|
2025-01-02 18:03:26 +08:00
|
|
|
|
-i string
|
|
|
|
|
指定要使用的网络接口
|
|
|
|
|
-l 列出可用的网络接口
|
|
|
|
|
-o string
|
|
|
|
|
保存捕获数据的输出文件(可选)
|
|
|
|
|
-s string
|
|
|
|
|
-s start 启动 Iptables 规则
|
2025-01-08 09:46:07 +08:00
|
|
|
|
-s stop 停止 Iptables 规则
|
|
|
|
|
-s list 打印 Iptables 规则
|
|
|
|
|
|
2025-01-02 18:03:26 +08:00
|
|
|
|
root@NIUYULING:/mnt/c/Users/root/Desktop/git.aixiao.me/DenyIP-go#
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 示例命令
|
|
|
|
|
|
|
|
|
|
- **启动守护进程**:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
./denyip -i eth0 -f tcp
|
|
|
|
|
./denyip -d -i eth0 -f "tcp"
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
- **启用Iptables规则**:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
./denyip -s start
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
- **禁用Iptables规则**:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
./denyip -s stop
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
- **查看帮助信息**:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
./denyip -h
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
- **关闭守护进程**:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
killall -15 denyip
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 贡献
|
|
|
|
|
|
|
|
|
|
欢迎贡献代码和提出改进建议!请通过 Pull Request 或 Issue 的方式提交。
|
|
|
|
|
|
|
|
|
|
## 联系信息
|
|
|
|
|
|
|
|
|
|
- **邮箱**:<aixiao@aixiao.me>
|
2025-01-06 17:16:36 +08:00
|
|
|
|
- **日期**:20250102
|
2025-01-02 18:03:26 +08:00
|
|
|
|
|
|
|
|
|
## 许可证
|
|
|
|
|
|
|
|
|
|
本项目遵循 GNU 许可证,详情参见 [LICENSE](LICENSE) 文件。
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
希望这个 `README.md` 文件能够帮助您更好地介绍和使用 `DenyIP` 项目。如果有任何其他需求或修改,请随时告知。
|