Back
Featured image of post setting up tunnelbroker (netplan)

setting up tunnelbroker (netplan)

Setting up tunnelbroker for lavalink using netplan.

Why

lavalink is usually used for discord bot to play music to discord.

If your bot is on alot of servers and alot of people, you need tunnelbroker to prevent youtube from rate limiting your ip.


First and formost, we need to install lavalink. if you dont know how to you can check out the lavalink setup guide

Getting TunnelBroker

Configuring TunnelBroker

The first thing to do is enable IPv6 Binding in Linux. This enables Lavalink (and other programs) to bind to local addresses that would otherwise be considered illegal:

# Enable now
sysctl -w net.ipv6.ip_nonlocal_bind=1
# Persist for next boot
echo 'net.ipv6.ip_nonlocal_bind = 1' >> /etc/sysctl.conf

Next you’ll need to configure netplan. create a file on /etc/netplan/ named anything ending in .yaml and add the following:

network:
  version: 2
  tunnels:
    he-ipv6:
      mode: sit
      remote:
      local:
      addresses:
        - ""
      gateway6: ""

You will now need to add your IPv6 subnet details, you’ll need to go to tunnelbroker and copy the Server IPv4 address, Client IPv4 address, and Routed IPv6 address.

Then you can add the following to your /etc/netplan/ file, these should be arrange as shown in the template above.

  • Your remote will be your ‘Server IPv4 address’
  • Your local will be your ‘Client IPv4 address’
  • Your gateway6 will be your ‘Routed IPv6 address’
  • Your addresses will be your ‘Routed IPv6 address’ Remember, you do not need to include any speech marks or apostrophes, we have simply listed them to clearly display what should only be listed. Please look at the sample configuration below, this should look similar but not the same as
network:
  version: 2
  tunnels:
    he-ipv6:
      mode: sit
      remote: 216.66.84.42
      local: 54.39.86.164
      addresses:
        - "2001:470:cc7b::2/48"
      gateway6: "2001:470:cc7b::1"

after doing all of that you can run netplan apply to apply the changes.

Last step is to set the dev lo to your IPv6 /48 blocks

ip -6 route replace local YOUR_48_BLOCK dev lo
# Example
# ip -6 route replace local 2b21:d0:a4sf::/48 dev lo

Test your configuration

Before setting up the lavalink, we need to test it to make sure it actually works.

# Test that IPv6 works in the first place
ping6 google.com

# Test your tunnel with
ping6 -I he-ipv6 google.com

# If you have the IPv6 block 1234:1234:1234::/48
# You should be able to use any of the IPs within that block
ping6 -I 1234:1234:1234:: google.com
ping6 -I 1234:1234:1234::1 google.com
ping6 -I 1234:1234:1234:dead::beef google.com

# Make sure your /48 block appears when running this command
ip -6 route
## it should look something like this
#::1 dev lo proto kernel metric 256 pref medium
#2001:470:cc7b::/48 dev he-ipv6 proto kernel metric 256 pref medium
#fdba:17c8:6c94::/64 dev pterodactyl0 proto kernel metric 256 pref medium
#fe80::/64 dev eth0 proto kernel metric 256 pref medium
#fe80::/64 dev pterodactyl0 proto kernel metric 256 pref medium
#fe80::/64 dev vethff50ad0 proto kernel metric 256 pref medium
#fe80::/64 dev veth5832748 proto kernel metric 256 pref medium
#default via 2001:470:cc7b::1 dev he-ipv6 proto static metric 1024 pref medium

Add the ratelimit block to your config:

lavalink:
  server:
    # ...
    ratelimit:
      ipBlocks: ["1234:1234:1234::/48"]
      strategy: "LoadBalance"
      searchTriggersFail: true

You can read more about the different strategies in ROUTEPLANNERS.md

“Help, I’ve tried the steps above but It doesn’t work.” If you’ve followed this entire guide and It doesn’t work, then please contact me on my discord server discord.darrennathanael.com and I’ll help you out. and also provide the following information:

  • Which distro you are on
  • The network config you wrote based on one of the Tunnelbroker examples
  • A screenshot of the Tunnelbroker website with your tunnel details
  • Your Netplan config
  • The output of ip -6 route
  • Don’t say “doesn’t work”. Describe your problem in details

And please don’t censor your IPs. It makes it harder for me to help, I wont attack you.


Inspired by Freya Arbjerg https://blog.arbjerg.dev/2020/3/tunnelbroker-with-lavalink

Thank you for reading, have a great day!

May your USB connectors always be facing the right way.
Theme designed Jimmy.

AbuseIPDB Contributor Badge DMCA.com Protection Status