Overview
The IP Blocking system in Argos Mesh provides a distributed blacklist managed by Redis. When suspicious activity is detected, IP addresses are automatically banned for a configurable duration to prevent further abuse.The IP blacklist is shared across all Sentinel service instances, ensuring consistent protection throughout your distributed system.
How IP Blocking Works
IP blocking is managed by theRedisService component, which provides two core operations:
- Ban an IP: Add an IP to the blacklist with a TTL
- Check if banned: Query whether an IP is currently blocked
RedisService Implementation
Here’s the complete implementation from the Sentinel service:sentinel/src/main/java/com/argos/sentinel/service/RedisService.java
Automatic Banning
Trigger Conditions
IPs are automatically banned when they exceed the rate limit:sentinel/src/main/java/com/argos/sentinel/service/TrafficAnalyzer.java:33-36
Ban Duration
The default ban duration is 10 minutes. This provides a balance between security and user experience, preventing temporary network issues from causing permanent blocks.
Configuring Ban Duration
To modify the ban duration, update thebanIp() call in TrafficAnalyzer.java:
Redis Key Structure
The blacklist uses a simple key-value pattern:| Key Pattern | Example | Value | TTL |
|---|---|---|---|
blacklist:ip:<address> | blacklist:ip:203.0.113.42 | "BANNED" | Duration (minutes) |
Checking Ban Status
TheisBanned() method is called at multiple checkpoints:
1. Before Rate Limiting
TrafficAnalyzer.java:23
2. Before Event Processing
SalesListener.java:29-31
Manual IP Management
While Argos Mesh handles banning automatically, you can also manage the blacklist manually using Redis CLI.Manually Ban an IP
Manually Unban an IP
Check Ban Status
View All Banned IPs
Check Remaining Ban Time
Integration Flow
Here’s how IP blocking integrates with the complete security pipeline:Performance & Scalability
O(1) Lookups
Redis
EXISTS and HASKEY operations are constant time, providing instant ban checks.Distributed State
All Sentinel instances share the same Redis blacklist, ensuring consistent protection.
Automatic Cleanup
Redis TTL automatically removes expired bans without manual intervention.
Memory Efficient
Each banned IP uses only ~100 bytes of memory in Redis.
Use Cases
Preventing Scalping Bots
E-commerce bots often attempt to purchase limited inventory by making hundreds of requests per second. IP blocking stops these attacks after the first 50 requests.
DDoS Mitigation
During a distributed denial-of-service attack, each attacking IP is automatically identified and banned, reducing the attack surface.API Abuse Prevention
If a client misconfigures their application and sends excessive traffic, they’re temporarily banned until the issue is resolved.Monitoring the Blacklist
Create a monitoring script to track banned IPs:Best Practices
Monitor False Positives
Regularly review banned IPs to ensure legitimate users aren’t being blocked.
Whitelist Critical IPs
Implement a whitelist for internal services and monitoring systems to prevent accidental bans.
Adjust Ban Duration
For production systems, consider longer ban durations (30-60 minutes) for repeat offenders.
Log Ban Events
Implement structured logging to track when and why IPs are banned for audit purposes.
Next Steps
Rate Limiting
Understand how rate limiting triggers automatic bans
DDoS Protection
See how IP blocking fits into the complete security strategy