Skip to main content

Overview

IP filtering restricts access to Ant Media Server’s REST API and web dashboard based on the client’s IP address. This provides network-level security by allowing only trusted IP addresses or ranges to access administrative functions.

IPFilter Implementation

The IPFilter class (filter/IPFilter.java:18) controls access to REST API endpoints and the management dashboard.

How IP Filtering Works

See filter/IPFilter.java:27-43 for the complete implementation.

Enabling IP Filtering

Via REST API

Via Configuration File

Edit the application settings:

CIDR Notation

IP filtering uses CIDR (Classless Inter-Domain Routing) notation to define IP ranges.

CIDR Format

Examples:
  • 192.168.1.0/24 - Allows 192.168.1.0 through 192.168.1.255 (256 addresses)
  • 10.0.0.0/8 - Allows 10.0.0.0 through 10.255.255.255 (16,777,216 addresses)
  • 172.16.0.0/12 - Allows 172.16.0.0 through 172.31.255.255 (1,048,576 addresses)
  • 203.0.113.5/32 - Allows only 203.0.113.5 (single IP)

Common CIDR Ranges

IP Validation Logic

The validation process (filter/IPFilter.java:51-65):

CIDR Matching Implementation

The checkCIDRList method from AbstractFilter (filter/AbstractFilter.java:66-94) handles CIDR validation:

Configuration Examples

Allow Single Office IP

Allow Local Network

Allow Multiple Networks

Allow Localhost and Private Networks

What Gets Filtered

Protected Resources

IP filtering applies to:
  • REST API endpoints (/rest/v2/*)
  • Web management dashboard
  • Administrative interfaces

Exceptions

  1. ACM Endpoints: Ant Certificate Manager endpoints are exempt:
  1. Cluster Communication: Internal cluster tokens bypass IP filtering:
See filter/IPFilter.java:33-41 for exception handling.

Not Filtered

IP filtering does NOT apply to:
  • Stream playback endpoints
  • WebRTC publishing/playback
  • HLS/DASH manifest requests
For stream-level access control, use Token-Based Access or JWT Authentication.

Cluster Mode Considerations

In cluster deployments:

Edge-Origin Communication

Edge nodes must communicate with origin nodes. Use cluster authorization tokens instead of adding all edge IPs to the CIDR list:

Configuration Strategy

  1. Option 1: Add all cluster node IPs to allowedCIDRList
  2. Option 2: Use cluster communication keys and minimal CIDR list
  3. Recommended: Combine both for defense-in-depth

Load Balancer Considerations

X-Forwarded-For Header

When behind a load balancer or proxy, the remoteIPAddress may be the load balancer’s IP, not the client’s IP. The filter handles some proxy scenarios:

Trusting Proxies

If using a reverse proxy:
  1. Configure the proxy to set X-Forwarded-For header
  2. Add the proxy’s IP to allowedCIDRList
  3. Consider using application-level authentication in addition to IP filtering

Security Best Practices

Always use IP filtering in combination with authentication. IP addresses can be spoofed in some network configurations, so IP filtering should not be your only security mechanism.
Be careful with broad CIDR ranges like /8 or /16. These allow millions of IP addresses. Use the smallest range necessary for your use case.
When enabling IP filtering for the first time, ensure you include your own IP address in the allowed list. Otherwise, you may lock yourself out.
Document your CIDR configuration. Future administrators need to know which ranges are allowed and why.
Test IP filtering in a development environment before applying to production. Misconfiguration can block all access to your server.

Use Cases

Corporate Office Access

Allow only office network:

Multi-Office Deployment

Allow multiple office locations:

Development Environment

Allow localhost and private networks:

VPN-Only Access

Allow only VPN network:

Monitoring and Logging

Failed access attempts are logged:
Monitor logs for:
  • Repeated access attempts from unauthorized IPs
  • Patterns indicating port scanning or attacks
  • Legitimate users being blocked (indicates CIDR misconfiguration)

Troubleshooting

Locked Out of Server

If you’ve locked yourself out:
  1. Access server via SSH
  2. Edit application settings file directly
  3. Disable IP filtering:
  1. Restart Ant Media Server

IP Not Matching CIDR

Check:
  1. Verify your actual IP: curl ifconfig.me
  2. Check CIDR notation is correct
  3. Test CIDR match: Use online CIDR calculator
  4. Review server logs for attempted IP address

Load Balancer Issues

If behind a load balancer:
  1. Add load balancer IP to CIDR list
  2. Configure load balancer to preserve client IP
  3. Use application-level authentication as backup

Combining with Other Security

IP filtering works best when combined with:

JWT Authentication

Token-Based Access

SSL/TLS

Next Steps