Meds is a high-performance firewall system written in Go.
It integrates with Linux Netfilter via NFQUEUE, inspects inbound traffic in user space, and applies filtering to block malicious or unwanted traffic in real time.
Meds — "net healing" firewall designed to cure your network from malicious traffic.
Requirements:
Since Meds interacts directly with iptables and NFQUEUE, you must run it with root privileges (sudo).
The application manages iptables rules automatically.
API available at http://localhost:8000 (Basic Auth: admin / mypass)
By default, metrics are exposed at:
The metrics endpoint is protected by the same BasicAuth credentials as the API.
Example API usage (see api.go)
-
NFQUEUE-based packet interception
Uses Linux Netfilter queues to copy inbound packets into user space with minimal overhead. -
Fast packet parsing with gopacket
Parses traffic efficiently (lazy and no copy modes enabled). -
Lock-free core
Meds itself does not use any mutexes — all filtering, counters, and rate-limiters use atomic operations. -
Blacklist-based filtering
- IP blacklists: FireHOL, Spamhaus DROP, Abuse.ch
- Domain blacklists: StevenBlack hosts, SomeoneWhoCares hosts
-
TLS SNI & JA3 filtering
Extracts and inspects TLS ClientHello data directly from TCP payload before handshake completion:- Filters by SNI (domain in TLS handshake)
- Filters by JA3 fingerprint using the Abuse.ch SSLBL JA3 database
Allows real-time blocking of malicious TLS clients (e.g., malware beacons, scanners, or C2 frameworks).
-
Rate Limiting per IP
Uses token bucket algorithm to limit burst and sustained traffic per source IP.
Protects against high-frequency floods (SYN, DNS, ICMP, or generic packet floods). -
HTTP API for runtime configuration
Built-in API server (powered by Gin) allows dynamically adding or removing IP/Domain entries in global whitelists/blacklists.
Auth via BasicAuth using MEDS_USERNAME / MEDS_PASSWORD. -
Prometheus metrics export
Exposes metrics for observability:- Total packets processed
- Dropped packets (with reasons)
- Accepted packets (with reasons)
Metrics are available at /v1/metrics via the built-in API server, compatible with Prometheus scrape targets.
-
Asynchronous logging
Uses zerolog with worker-based async logging for minimal overhead. -
Efficient lookups
Uses radix tree and bart for IP/domain matching at scale. -
Extensible design
Modular architecture allows adding new filters (GeoIP, ASN, etc).
-
Packet interception
All inbound packets are queued from Netfilter (iptables rule with -j NFQUEUE). -
Classification pipeline
Packets go through multiple filters:- Global IP/Domain whitelist check
- Rate Limiting per source IP
- IP/Domain check
- SNI/JA3 check
- Global IP/Domain blacklist check
-
Decision engine
- ACCEPT → packet is safe, passed to kernel stack
- DROP → packet is malicious, discarded immediately
-
Metrics & logging
Every decision is counted and exported for monitoring and alerting.
Metrics are exposed in Prometheus format and can be visualized with Grafana.
All events are asynchronously logged to minimize packet processing latency.
Meds is released under the MIT License.
See LICENSE for details.
Pull requests and feature suggestions are welcome!
If you find a bug, please open an issue or submit a fix.
.png)

