acassen/gtp-guard

GitHub: acassen/gtp-guard

一款基于XDP与eBPF的GPRS隧道协议路由软件,为移动核心网数据面提供安全扩展与高效路由。

Stars: 45 | Forks: 4

# GTP Guard: GPRS 隧道协议路由软件 [![GTP-Guard CI](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/573439b33b182905.svg)](https://github.com/acassen/gtp-guard/actions/workflows/actions-compile.yml) [![GTP-Guard CodeQL](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/50c5fb7a10182908.svg)](https://github.com/acassen/gtp-guard/actions/workflows/codeql.yml) [![DeepWiki Doc](https://deepwiki.com/badge.svg)](https://deepwiki.com/acassen/gtp-guard) GTP-Guard 是一款使用 C 语言编写的路由软件。该项目的主要目标是为 GTP 协议(GPRS 隧道协议)提供强大且安全的扩展功能。GTP 广泛用于移动核心网的数据面。GTP-Guard 实现了三个主要框架。第一个提供数据面调整所需的代理功能;第二个是路由设施,用于互联、封装或提供任何路由相关功能;最后一个是防火墙功能,提供过滤、重写和重定向。GTP-Guard 依赖 Linux 内核的 XDP 框架作为其数据面,使用 eBPF 程序。管理和用户级接口可通过标准的 VTY 终端接口使用。 GTP-Guard 是自由软件;你可以在 GNU Affero General Public License Version 3.0 的条款下重新分发和/或修改它,该许可证由自由软件基金会发布。 # 构建 ``` git clone git@github.com:acassen/gtp-guard.git cd gtp-guard make ``` 使用 Meson 构建系统,请确保已安装。 gcc 是默认编译器。如果更倾向于使用 Clang,请使用以下命令: ``` CC=clang make ``` # 基本运行 请自行定义 `gtp-guard.conf` 设置以启用其 VTY 的 TCP 访问。 ``` $ cat < /tmp/gtp-guard.conf ! pdn request-channel 127.0.0.1 port 8080 ! gtp-router demo gtpc-tunnel-endpoint 0.0.0.0 port 2123 gtpu-tunnel-endpoint 0.0.0.0 port 2152 ! line vty no login listen 127.0.0.1 8888 ! EOFCONF $ sudo bin/gtp-guard --dont-fork --log-console --log-detail -f /tmp/gtp-guard.conf ``` 然后在另一个控制台中,可以使用以下命令通过 Telnet 连接到 `127.0.0.1:8888` 获取 CLI: ``` $ telnet 127.0.0.1 8888 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. Welcome to GTP-Guard VTY xps> show version gtp-guard v1.1.1 (2025/09/02) (). Copyright (C) 2023-2025 Alexandre Cassen, xps> quit Connection closed by foreign host. ``` 之后,你可以向 UDP 端口 2123 和 2152 发送 GTPc 和 GTPu 流量。 ## 基本测试 测试目录中包含一些脚本。这些脚本仅测试 GTPu 用户面部分和 eBPF 程序。以下是一个 gtp-proxy 示例: ``` # 在您的系统上设置链接、IP、sysctls 等 sudo ./test/gtp-proxy.sh setup # 启动并配置 gtp-guard sudo ./test/gtp-proxy.sh run # 发送数据包(在另一个控制台运行) sudo ./test/gtp-proxy.sh pkt # 让您的系统清理(重新启动作为替代方案) sudo ./test/gtp-proxy.sh clean ``` ## 环境变量设置 - `GTP_GUARD_PID_FILE`:设置备用 PID 文件(默认 = /var/run/gtp-guard.pid)
标签:CI, Clang, CodeQL, DeepWiki文档, Docker镜像, GCC, GNU AGPLv3, GPRS, GTP, GTP-Guard, Linux内核, Meson构建系统, TCP接口, VTY终端, XDP, 代理, 代码安全扫描, 内核驱动, 协议扩展, 安全评估工具, 客户端加密, 嵌入式网络, 恶意代码分析, 数据包路由, 数据包转发, 无文件攻击, 核心网, 流量过滤, 流量重写, 流量重定向, 移动通信, 编译构建, 网络协议, 网络安全, 网络性能, 路由软件, 软件定义网络, 配置文件, 防火墙, 隐私保护