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
- Make a tunnelbroker Account
- Create a new regular tunnel
- Enter your IPv4 address and select a nearby region.
You can use https://github.com/DarrenOfficial/scripts-util/blob/main/general/he_ping.sh to find nearest / lowest ping tunnelbroker server.
- Request a new /48 by clicking the “Assign /48” button. We can use /64, but is much more likely to be blocked.
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:
1# Enable now 2sysctl -w net.ipv6.ip_nonlocal_bind=1 3# Persist for next boot 4echo '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:
1network: 2 version: 2 3 tunnels: 4 he-ipv6: 5 mode: sit 6 remote: 7 local: 8 addresses: 9 - "" 10 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
1network: 2 version: 2 3 tunnels: 4 he-ipv6: 5 mode: sit 6 remote: 22.214.171.124 7 local: 126.96.36.199 8 addresses: 9 - "2001:470:cc7b::2/48" 10 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
1ip -6 route replace local YOUR_48_BLOCK dev lo 2# Example 3# ip -6 route replace local 2b21:d0:a4sf::/48 dev lo
Before setting up the lavalink, we need to test it to make sure it actually works.
1# Test that IPv6 works in the first place 2ping6 google.com 3 4# Test your tunnel with 5ping6 -I he-ipv6 google.com 6 7# If you have the IPv6 block 1234🔢1234::/48 8# You should be able to use any of the IPs within that block 9ping6 -I 1234🔢1234:: google.com 10ping6 -I 1234🔢1234::1 google.com 11ping6 -I 1234🔢1234:dead::beef google.com 12 13# Make sure your /48 block appears when running this command 14ip -6 route 15## it should look something like this 16#::1 dev lo proto kernel metric 256 pref medium 17#2001:470:cc7b::/48 dev he-ipv6 proto kernel metric 256 pref medium 18#fdba:17c8:6c94::/64 dev pterodactyl0 proto kernel metric 256 pref medium 19#fe80::/64 dev eth0 proto kernel metric 256 pref medium 20#fe80::/64 dev pterodactyl0 proto kernel metric 256 pref medium 21#fe80::/64 dev vethff50ad0 proto kernel metric 256 pref medium 22#fe80::/64 dev veth5832748 proto kernel metric 256 pref medium 23#default via 2001:470:cc7b::1 dev he-ipv6 proto static metric 1024 pref medium
Add the ratelimit block to your config:
1lavalink: 2 server: 3 # ... 4 ratelimit: 5 ipBlocks: ["1234🔢1234::/48"] 6 strategy: "LoadBalance" 7 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!