Whitelisting allows you to exempt specific IP addresses from your blocked ranges. When an IP is whitelisted, it bypasses all range checks and is always allowed through, regardless of whether it would otherwise match a blocked range.This is essential when you need to block broad ranges (like entire cloud providers) but want to allow specific trusted IPs within those ranges.
Whitelist check - if IP is whitelisted, request is immediately allowed
Range check - if IP matches blocked ranges, responder is triggered
If no match, request continues normally
Source Code:matchers/ip/ip.go:65-82
func (c *IPChecker) ReqAllowed(ctx context.Context, clientIP net.IP) bool { ipAddr, err := ipToAddr(clientIP) if err != nil { c.log.Warn("Invalid IP address format", zap.String("ip", clientIP.String()), zap.Error(err)) return false } // Check if the IP is whitelisted if ok, _ := c.whitelist.Matches(ipAddr); ok { c.log.Debug("IP is whitelisted", zap.String("ip", clientIP.String())) return true // Allow immediately } // Check if the IP is in the blocked ranges return !c.IPInRanges(ctx, ipAddr)}
The whitelist check happens first, so whitelisted IPs never trigger the responder even if they match blocked ranges.
The whitelist only supports individual IP addresses, not CIDR ranges or subnets.
From the code comment in plugin.go:97-98:
// An optional whitelist of IP addresses to exclude from blocking. If empty, no IPs are whitelisted.// NOTE: this only supports IP addresses, not ranges.
If you need to whitelist a range, you must specify each IP individually.
Begin with a small whitelist and expand as needed. It’s easier to add IPs than debug why traffic isn’t getting through.
Document Your Whitelist
Add comments explaining why each IP is whitelisted:
# Production API serverwhitelist 203.0.113.10# Monitoring servicewhitelist 198.51.100.5
Test Before Deploying
Always include your own IP in the whitelist when testing with ranges all or broad ranges.
Monitor Logs
Enable debug logging initially to verify whitelist behavior, then disable it in production for performance.
Critical: If you lock yourself out by blocking your own IP, you’ll need console/shell access to fix the configuration. Always test whitelist configurations carefully.
Whitelisting works identically with all responder types:
# Works with blockdefender block { ranges openai whitelist 203.0.113.1}# Works with tarpitdefender tarpit { ranges aws gcloud whitelist 35.247.0.1 tarpit_config { timeout 5m }}# Works with redirectdefender redirect { ranges all whitelist 192.0.2.1 url https://example.com/blocked}
The whitelist is checked in the middleware layer (middleware.go:66), before the responder is invoked, so it works consistently across all responder types.