Skip to content

Commit

Permalink
Update docs: added how-to setup IPv6 (#1045)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: topi314 <git@topi.wtf>
  • Loading branch information
manybaht and topi314 committed Jun 22, 2024
1 parent 8a8ff75 commit e5cb787
Show file tree
Hide file tree
Showing 7 changed files with 355 additions and 0 deletions.
43 changes: 43 additions & 0 deletions docs/configuration/ipv6/contabo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
description: How to configure IPv6 on your Contabo VPS.
---

Setting up IPv6 for Lavalink on Contabo VPS is super easy. The VPS comes with a /64 address to use.

This how-to may depend on your system's OS, but it has already been tested on `Ubuntu` and `Debian`.

First, you need to enable IPv6 on your Contabo VPS. It's very easy, as they have already included auto commands in the .bashrc for you.
Enable IPv6 by using this command: `enable_ipv6`

Then reboot your server once, as stated in the Contabo documentation. `reboot`

To see your IPv6 /64 address, simply type: `ip a`

Expected output:
```
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:50:56:51:fc:62 brd ff:ff:ff:ff:ff:ff
altname enp0s18
altname ens18
inet xxx.xxx.xxx.xxx/22 brd xxx.xxx.xxx.xxx scope global eth0
valid_lft forever preferred_lft forever
inet6 you-want-to-copy-this-one::1/64 scope global <------- copy this ipv6 /64
valid_lft forever preferred_lft forever
inet6 ignore-this-one/64 scope link
valid_lft forever preferred_lft forever
```

Then we need to enable nonlocal bind: `sysctl -w net.ipv6.ip_nonlocal_bind=1`

And `echo 'net.ipv6.ip_nonlocal_bind=1' >> /etc/sysctl.conf` (So you do not need to adjust sysctl settings again when rebooting the server.)

Then `ip -6 route replace local the-ipv6-you-copied::/64 dev lo` (Don't forget to remove the '1' from the address that you copy from, for example 'you-want-to-copy-this-one::1/64', the '1' after '::'.)

Test your IPv6
```
# Replace 1234:1234:1234:: with your IPv6 address.
ping6 -I 1234:1234:1234:: -c 2 google.com
ping6 -I 1234:1234:1234::1 -c 2 google.com
ping6 -I 1234:1234:1234::2 -c 2 google.com
ping6 -I 1234:1234:1234:dead:beef:1234:1234 -c 2 google.com
```
39 changes: 39 additions & 0 deletions docs/configuration/ipv6/digitalocean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
description: How to configure IPv6 on your DigitalOcean VPS.
---

As the IPv6 rotation plan suggests, it is recommended to use a block size larger than /64. However, with DigitalOcean, they only provides you with 16 IPv6 addresses. If you prefer to use an IPv6 /64 or /48 block size for your DigitalOcean VPS, consider this alternative instead. [Using Tunnelbroker to make Lavalink balance its requests over many IPv6 addresses](https://blog.arbjerg.dev/2020/3/tunnelbroker-with-lavalink)

As of now, if you want to use Tunnelbroker with DigitalOcean, you might encounter a block when trying to create a tunnel for your DigitalOcean IP. You may need to contact them to unblock your server.

This how-to may depend on your system's OS, but it has already been tested on `Ubuntu` and `Debian`.

### Create DigitalOcean Droplet with IPv6 enabled.

In `Create Droplets` panel -> `Advanced Options` -> Click `Enable IPv6 (free)`

### Enable IPv6 on existed DigitalOcean Droplet.

Go to your Droplet panel -> Turn off your Droplet -> `Networking` -> `PUBLIC IPV6 ADDRESS` -> `Enable` -> Then turn your Droplet on again.

After you enable IPv6 on the existing Droplet, you need to configure it manually. Please refer to your OS System in this link. [https://docs.digitalocean.com/products/networking/ipv6/how-to/enable/](https://docs.digitalocean.com/products/networking/ipv6/how-to/enable/)

After that, reboot your server once: `reboot`

Test your IPv6 connection: `ping6 google.com` or `ping6 2001:4860:4860::8888`

### [Optional] use all 16 IPv6 Addresses

Please refer to your OS System in this link. [How to Enable Additional IPv6 Addresses](https://docs.digitalocean.com/products/networking/ipv6/how-to/configure-additional-addresses/)

Test your IPv6
```
# Don't forgot to replace IPv6 in the example with your IPv6 address.
ping6 -I 2400:6180:0:d0::fa6:2000 -c 2 google.com
ping6 -I 2400:6180:0:d0::fa6:2001 -c 2 google.com
ping6 -I 2400:6180:0:d0::fa6:2002 -c 2 google.com
ping6 -I 2400:6180:0:d0::fa6:2003 -c 2 google.com
ping6 -I 2400:6180:0:d0::fa6:2004 -c 2 google.com
...
ping6 -I 2400:6180:0:d0::fa6:200f -c 2 google.com
```
29 changes: 29 additions & 0 deletions docs/configuration/ipv6/hetzner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
description: How to configure IPv6 on your Hetzner VPS.
---

Setting up IPv6 for Lavalink on a Hetzner VPS is just 3 commands. The VPS comes with a /64 address to use and already has IPv6 enabled for you.

This how-to may depend on your system's OS, but it has already been tested on `Ubuntu` and `Debian`.

Look up your IPv6 /64 address on your hetzner cloud panel.

HETZNER Cloud panel -> Your server -> Networking tab -> PUBLIC NETWORK -> PRIMARY IP.

Expected address should be something like this:
`2a01:4f9:xxxx:xxxx::/64`

First, we need to enable nonlocal bind: `sysctl -w net.ipv6.ip_nonlocal_bind=1`

And `echo 'net.ipv6.ip_nonlocal_bind=1' >> /etc/sysctl.conf` (So you do not need to adjust sysctl settings again when rebooting the server.)

Then `ip -6 route replace local 2a01:4f9:xxxx:xxxx::/64 dev lo` (Replace the `2a01:4f9:xxxx:xxxx::/64` with your IPv6 address from panel.)

Test your IPv6
```
# Replace 1234:1234:1234:: with your IPv6 address.
ping6 -I 1234:1234:1234:: -c 2 google.com
ping6 -I 1234:1234:1234::1 -c 2 google.com
ping6 -I 1234:1234:1234::2 -c 2 google.com
ping6 -I 1234:1234:1234:dead:beef:1234:1234 -c 2 google.com
```
19 changes: 19 additions & 0 deletions docs/configuration/ipv6/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
description: IPv6 related information.
---

Nowadays, most server providers will give you an IPv6 `/64` with a VPS for free. You can easily check by `ping6 google.com` or using `ip a` to check for an IPv6 address.

If your hosting provider stated that they provide IPv6 but your server does not have one, kindly ask them about IPv6 and how to configure it. Sometimes, the server provider might require you to open a ticket for providing IPv6 to your server.

For Lavalink use, most IPv6 rotation plans recommend IPv6 with a block size larger than `/64`, but you can still configure it for use with Lavalink even if it's less than `/64`.

Here are some guides for some popular server providers:
- [Contabo](/docs/configuration/ipv6/contabo.md)
- [DigitalOcean](/docs/configuration/ipv6/digitalocean.md)
- [Hetzner](/docs/configuration/ipv6/hetzner.md)


If your server provider is not listed above, you can use you can check out the general [Debian/Ubuntu](/docs/configuration/ipv6/ubuntudebian.md) guide on how to configure IPv6 on your server.

If your server provider does not provide IPv6 or your IPv6 block size is less than `/64`, you can use [Tunnelbroker](/docs/configuration/ipv6/tunnelbroker.md) instead.
180 changes: 180 additions & 0 deletions docs/configuration/ipv6/tunnelbroker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
---
description: How to configure IPv6 using Tunnelbroker on your VPS.
---

This how-to is for super-newbie and may depend on your system's OS, but it has already been tested on `Ubuntu (22, 23 and 24)` with `netplan`.

### Hello Tunnelbroker!

1. Create an account at [Tunnelbroker](https://tunnelbroker.net)
2. Create a new `Create Regular Tunnel`
3. Enter your server IPv4 and select the Tunnelbroker server with the lowest ping to your server. `ping xxx.xxx.xxx.xxx`
4. (Optional) Get IPv6 /48 block by clicking `assign /48`
5. Go to `Example Configurations`
6. Select `Linux (netplan 0.103+)`
7. Copy the whole config

[WARNING] `xxxx` or `xxx` for example: `2001:470:xxxx:xxx::2/64` is just for censoring real information PLEASE REPLACE IT WITH YOUR IPV6

Example configuration generated from tunnelbroker.net
```yml
network:
version: 2
tunnels:
he-ipv6:
mode: sit
remote: 216.218.142.50
local: 195.xxx.xx.xxx
addresses:
- "2001:470:xxxx:xxx::2/64"
routes:
- to: default
via: "2001:470:xxxx:xxx::1"
```
On your server, go to the netplan folder: `cd /etc/netplan`

Create a new file using your choice of text editor, but in this how-to, we will be using nano.
`nano 99-he-tunnel.yaml`

Then paste the whole configuration into that file.

Example configuration of 99-he-tunnel.yaml with /64
```
network:
version: 2
tunnels:
he-ipv6:
mode: sit
remote: 216.218.142.50
local: 195.xxx.xx.xxx
addresses:
- "2001:470:xxxx:xxx::2/64"
routes:
- to: default
via: "2001:470:xxxx:xxx::1"
```
Example configuration of 99-he-tunnel.yaml with /48
```
network:
version: 2
tunnels:
he-ipv6:
mode: sit
remote: 216.218.142.50
local: 195.xxx.xx.xxx
addresses:
- "2001:470:xxxx::2/48"
routes:
- to: default
via: "2001:470:xxxx::1"
```
### [Optional] You already had IPv6 but still want to use Tunnelbroker.
Most hosting providers will have an OS image that is generated configuration called `50-cloud-init.yaml`.
Start edit that file: `nano 50-cloud-init.yaml`
Example configuration from 50-cloud-init.yaml
```
network:
ethernets:
ens3:
addresses:
- 195.xxx.xx.xxx/23
- 2402:xxxx:xxxx::xx/128
- 2402:xxxx:xxxx:xxxx::a/56
gateway4: 195.xxx.xx.x
gateway6: 2402:xxxx:xxxx::1
match:
macaddress: 00:34:a0:e1:de:5d
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
- 2001:4860:4860::8888
- 2001:4860:4860::8844
routes:
- scope: link
to: 195.xxx.xx.x
via: 0.0.0.0
- scope: link
to: 2402:xxxx:xxxx::1
via: ::0
version: 2
```
We will be removing
```
addresses:
- 195.xxx.xx.xxx/23
- 2402:xxxx:xxxx::xx/128 <---
- 2402:xxxx:xxxx:xxxx::a/56 <---
gateway4: 195.xxx.xx.x
gateway6: 2402:xxxx:xxxx::1 <---
```
And
```
- scope: link <---
to: 2402:xxxx:xxxx::1 <---
via: ::0 <---
```
Final configuration
```
network:
ethernets:
ens3:
addresses:
- 195.xxx.xx.xxx/23
gateway4: 195.xxx.xx.x
match:
macaddress: 00:34:a0:e1:de:5d
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
- 2001:4860:4860::8888
- 2001:4860:4860::8844
routes:
- scope: link
to: 195.xxx.xx.x
via: 0.0.0.0
version: 2
```
### Applying netplan and checking your IPv6
Let try our new configuration: `netplan try`
Ignore the warning and if there is no error then just press enter to accept new configuration.
Reboot server one time: `reboot`
Try your IPv6 from Tunnelbroker: `ping6 google.com`
Try curl to make sure that it is Tunnelbroker IPv6: `curl -6 https://ifconfig.co`
And it should return `2001:470:xxxx:xxx::2` or `2001:470:xxxx::2` if you are using /48
Next, we're going to configure IPv6 for Lavalink.
Enable non local binding
`sysctl -w net.ipv6.ip_nonlocal_bind=1`
And so the next time you don't need to type it again
`echo 'net.ipv6.ip_nonlocal_bind = 1' >> /etc/sysctl.conf`
Now, we replace this command with our IPv6 from Tunnelbroker.
`ip -6 route replace local 2001:470:xxxx:xxx::/64 dev lo`
or if you are using /48
`ip -6 route replace local 2001:470:xxxx::/48 dev lo`
Now test your new configuration
```cmd
ping6 -I 2001:470:xxxx:xxx:dead::beef google.com
```
or if you are using /48
```cmd
ping6 -I 2001:470:xxxx:dead::beef google.com
```

Now you can use your new IPv6 `2001:470:xxxx:xxx::/64` or `2001:470:xxxx::/48` to put in your Lavalink configuration.
38 changes: 38 additions & 0 deletions docs/configuration/ipv6/ubuntudebian.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
description: How to configure IPv6 on your Ubuntu/Debian VPS.
---

Setting up IPv6 for Lavalink on a Ubuntu/Debian VPS can be challenging depending on how your provider sets up the OS system for you, but most of the time, it is pretty easy.

Mostly, the provider will already set up IPv6 for you. You can find the IPv6 address by using the `ip a` command.

Expected output:
```
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:50:56:51:fc:62 brd ff:ff:ff:ff:ff:ff
altname enp0s18
altname ens18
inet xxx.xxx.xxx.xxx/22 brd xxx.xxx.xxx.xxx scope global eth0
valid_lft forever preferred_lft forever
inet6 you-want-to-copy-this-one::1/64 scope global <------- this is your ipv6 /64
valid_lft forever preferred_lft forever
inet6 ignore-this-one/64 scope link
valid_lft forever preferred_lft forever
```

If not, kindly ask your provider about providing an IPv6 address for your server and how to configure it.

First, we need to enable nonlocal bind: `sysctl -w net.ipv6.ip_nonlocal_bind=1`

And `echo 'net.ipv6.ip_nonlocal_bind=1' >> /etc/sysctl.conf` (So you do not need to adjust sysctl settings again when rebooting the server.)

Then `ip -6 route replace local 2a01:4f9:xxxx:xxxx::/64 dev lo` (Replace the `2a01:4f9:xxxx:xxxx::/64` with your IPv6 address from `ip a` command.) (Don't forget to remove the '1' from the address that you copy from, for example 'you-want-to-copy-this-one::1/64', the '1' after '::'.)

Test your IPv6
```
# Replace 1234:1234:1234:: with your IPv6 address.
ping6 -I 1234:1234:1234:: -c 2 google.com
ping6 -I 1234:1234:1234::1 -c 2 google.com
ping6 -I 1234:1234:1234::2 -c 2 google.com
ping6 -I 1234:1234:1234:dead:beef:1234:1234 -c 2 google.com
```
7 changes: 7 additions & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ nav:
- Systemd: configuration/systemd.md
- Docker: configuration/docker.md
- RoutePlanner: configuration/routeplanner.md
- IPv6:
- configuration/ipv6/index.md
- Tunnelbroker: configuration/ipv6/tunnelbroker.md
- Ubuntu/Debian: configuration/ipv6/ubuntudebian.md
- Hetzner: configuration/ipv6/hetzner.md
- Contabo: configuration/ipv6/contabo.md
- DigitalOcean: configuration/ipv6/digitalocean.md
- Clients: clients.md
- Plugins: plugins.md
- API:
Expand Down

0 comments on commit e5cb787

Please sign in to comment.