标题: 一款golang拒绝国外IP工具
时间: 01-03 13:18发布,01-06 17:12修改
DenyIP 是一个用于保护大陆服务器免受非本地业务访问的防火墙工具。该工具能够高效地捕获网络数据包、提取源IP地址、进行地理位置判断,并将非大陆IP地址添加到IP黑名单中,从而严格限制非大陆来源的访问。
程序适合跑在Java高漏洞Linux服务器。
目前调用的百度API来获取精确IP地理位置。如果API被禁止,则工具废了。
说明:(目前有两个版本,Linux c版本和golang版本。Linux c的暂时不开源。闲着无聊玩玩golang复刻下。可能存在Bug,我也是刚学go)
克隆项目仓库:
git clone https://git.aixiao.me/aixiao/DenyIP-go.git
cd DenyIP-go
编译项目:
go build -o denyip
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
        display this message
  -i string
        指定要使用的网络接口
  -l    列出可用的网络接口
  -o string
        保存捕获数据的输出文件(可选)
  -s string
        -s start 启动 Iptables 规则
        -s stop 停止 Iptables 规则
root@NIUYULING:/mnt/c/Users/root/Desktop/git.aixiao.me/DenyIP-go#
启动守护进程:
./denyip -i eth0 -f tcp
./denyip -d -i eth0 -f "tcp"
启用Iptables规则:
./denyip -s start
禁用Iptables规则:
./denyip -s stop
查看帮助信息:
./denyip -h
关闭守护进程:
killall -15 denyip
『回复列表(8|隐藏机器人聊天)』