Skip to main content
The Route Planner allows Lavalink to rotate through multiple IP addresses to avoid rate limiting and IP bans from audio sources. This is particularly useful when handling high-traffic loads or when certain sources implement aggressive rate limiting.

Overview

Route Planner uses IP blocks (CIDR blocks) to rotate outgoing connections across different IP addresses. When configured properly, it helps:

Avoid Rate Limits

Distribute requests across multiple IPs to stay under rate limits

Handle Bans

Automatically switch IPs when one gets banned

Improve Reliability

Continue operating even when some IPs are blocked

Scale Traffic

Support higher request volumes across multiple addresses

Terminology

An IP block is a collection of IP addresses, usually contiguous and described in CIDR notation.Examples:
  • 192.168.1.0/24 - 256 IPv4 addresses (192.168.1.0 to 192.168.1.255)
  • 2001:db8::/64 - 2^64 IPv6 addresses
  • 10.0.0.0/8 - 16,777,216 IPv4 addresses
For more information about CIDR blocks, refer to Understanding CIDR Notation.
When multiple CIDR blocks are configured in the ipBlocks array, Lavaplayer treats them as a single virtual IP block.Example:
ipBlocks:
  - "1.0.0.0/24"
  - "2.0.0.0/24"
  - "2001:db8::/64"
These are combined into one pool for rotation strategies.

Configuration

Configure the Route Planner in your application.yml:
application.yml
lavalink:
  server:
    ratelimit:
      ipBlocks:
        - "1.0.0.0/8"
        - "2001:db8::/64"
      excludedIps:
        - "1.0.0.1"
      strategy: "RotateOnBan"
      searchTriggersFail: true
      retryLimit: -1

Configuration Parameters

List of IP blocks in CIDR notation to use for rotation.Example:
ipBlocks:
  - "1.0.0.0/8"      # IPv4 block
  - "2001:db8::/64"  # IPv6 block
Specific IP addresses to exclude from the rotation pool.Example:
excludedIps:
  - "1.0.0.1"           # Exclude specific IPv4
  - "2001:db8::1"       # Exclude specific IPv6
IP rotation strategy to use.Options:
  • RotateOnBan - Switch IP when banned
  • LoadBalance - Random IP selection
  • NanoSwitch - Nanosecond-based switching
  • RotatingNanoSwitch - Rotating nanosecond-based switching
See Strategies for detailed information.
Whether a search 429 (Too Many Requests) response should trigger marking the IP as failing.
  • true - Search rate limits trigger IP rotation
  • false - Only playback rate limits trigger rotation
Number of retry attempts for failed requests.
  • -1 - Use default Lavaplayer value
  • 0 - Infinite retries
  • >0 - Specific number of retry attempts

Environment Variables

LAVALINK_SERVER_RATELIMIT_IP_BLOCKS=["1.0.0.0/8","2001:db8::/64"]
LAVALINK_SERVER_RATELIMIT_EXCLUDE_IPS=["1.0.0.1"]
LAVALINK_SERVER_RATELIMIT_STRATEGY=RotateOnBan
LAVALINK_SERVER_RATELIMIT_SEARCH_TRIGGERS_FAIL=true
LAVALINK_SERVER_RATELIMIT_RETRY_LIMIT=-1

Strategies

RotateOnBan Strategy

Uses the RotatingIpRoutePlanner which switches to a new IP address as soon as the current one gets banned.
How it works:
  1. Uses one IP address at a time
  2. When a ban is detected, immediately rotates to the next IP
  3. Cycles through all available IPs in the block
Best for:
  • IPv4 blocks
  • IPv6 blocks with bitmask < /64
  • Smaller IP pools
  • Predictable rotation patterns

LoadBalance Strategy

Uses the BalancingIpRoutePlanner which randomly selects IP addresses from the configured blocks.
How it works:
  1. Randomly selects an IP for each request
  2. Distributes load across all available IPs
  3. No specific rotation order
Best for:
  • Large IP blocks
  • High traffic loads
  • Services with strict per-IP rate limits
Some services ban IPs after just a few automated requests per day. You should have a large IP block to effectively use this strategy.

NanoSwitch Strategy

Uses the NanoIpRoutePlanner which switches IPs based on the current nanosecond clock offset.
How it works:
  1. Uses current nanosecond timestamp as offset in IP block
  2. Changes IP on each clock update
  3. Provides extremely rapid IP rotation
Requirements:
  • At least a /64 IPv6 block (2^64 addresses)
  • IPv6-capable network infrastructure
If your CIDR block is larger than /64, consider using RotatingNanoSwitch instead for better ban handling.

RotatingNanoSwitch Strategy

Uses the RotatingNanoIpRoutePlanner which combines nanosecond switching with /64 block rotation on bans.
How it works:
  1. Uses nanosecond offset within the current /64 block
  2. When a ban occurs, rotates to the next /64 block
  3. Provides both rapid rotation and ban resilience
Requirements:
  • At least one /64 IPv6 block (2^64 addresses)
  • For effective rotation: at least two /64 blocks
Not recommended to combine different-sized blocks (e.g., two /65s). Use multiple /64 blocks or larger for best results.

Strategy Comparison

StrategyMin IPs RequiredRotation MethodBan HandlingBest For
RotateOnBanAny size blockSequential on banSwitch to next IPIPv4, small blocks
LoadBalanceLarge blocksRandom selectionAvoid banned IPsHigh traffic, large pools
NanoSwitch/64 IPv6Nanosecond offsetNone (single /64)Extreme rotation
RotatingNanoSwitchMultiple /64sNano + block rotationSwitch /64 blockBest IPv6 strategy

IPv6 Setup

Before using IPv6-based strategies, you need to configure IPv6 on your server. See the IPv6 Setup Guide for detailed instructions for various hosting providers.

Hetzner

Just 3 commands to setup

Contabo

Built-in /64 address

DigitalOcean

16 IPv6 addresses or Tunnelbroker

Complete Examples

application.yml
lavalink:
  server:
    ratelimit:
      ipBlocks:
        - "192.168.1.0/24"  # 256 addresses
      excludedIps:
        - "192.168.1.1"     # Gateway
        - "192.168.1.255"   # Broadcast
      strategy: "RotateOnBan"
      searchTriggersFail: true
      retryLimit: 3

Testing Your Configuration

After configuring the Route Planner, verify it’s working correctly:
1

Check Logs

Look for Route Planner initialization messages in the Lavalink logs:
INFO - Route planner initialized with strategy: RotateOnBan
INFO - IP blocks: [1.0.0.0/8]
2

Monitor IP Usage

Use the REST API to check which IPs are being used:
curl http://localhost:2333/v4/routeplanner/status \
  -H "Authorization: youshallnotpass"
3

Test Rotation

Make multiple requests and verify different IPs are being used (check external service logs or use IP tracking).
4

Test Ban Handling

Simulate a ban and verify the strategy rotates to a new IP appropriately.

Troubleshooting

Check:
  1. Route Planner is configured correctly in application.yml
  2. IP blocks are in valid CIDR notation
  3. Strategy is specified and valid
  4. Lavalink has permission to bind to the IP addresses
  5. IPv6 is properly configured on your server (if using IPv6)
Possible causes:
  1. IP block is too small for your traffic volume
  2. Requests are too frequent for the strategy
  3. Source service has very aggressive rate limiting
Solutions:
  • Get a larger IP block
  • Switch to LoadBalance or NanoSwitch strategy
  • Reduce request frequency
  • Implement request queuing
  1. Verify IPv6 is configured: ping6 google.com
  2. Check nonlocal bind is enabled: sysctl net.ipv6.ip_nonlocal_bind
  3. Verify route is configured: ip -6 route show
  4. See IPv6 Setup Guide for detailed instructions
  1. Verify you meet the minimum requirements for the strategy
  2. Check that IP blocks are the correct size
  3. Review logs for strategy initialization messages
  4. Ensure excluded IPs aren’t blocking rotation
  5. Try a different strategy to compare behavior

Best Practices

  • Small IP pools (less than 256 addresses): Use RotateOnBan
  • Large IPv4 pools: Use LoadBalance
  • Single IPv6 /64: Use NanoSwitch
  • Multiple IPv6 /64s or larger: Use RotatingNanoSwitch
  • Monitor your traffic and ban rates
  • Start with a conservative block size
  • Expand if you’re hitting rate limits
  • For IPv6: /64 minimum, /48 recommended for production
  • Set up alerts for high ban rates
  • Monitor IP rotation frequency
  • Track which IPs are banned most often
  • Log rate limit responses for analysis
  • Test thoroughly in a staging environment
  • Start with conservative settings
  • Monitor closely after deployment
  • Have a rollback plan ready
  • Document your configuration

IPv6 Setup

Configure IPv6 on your server

application.yml Reference

Complete configuration reference

Build docs developers (and LLMs) love