How to Add Additional IPv6 Addresses on Hetzner Cloud Servers
Configuring additional IPv6 addresses on Hetzner Cloud servers allows for enhanced resource management and scalability. This guide will provide step-by-step instructions on how to assign multiple IPv6 addresses, ensure they persist across reboots, and clarify optional configurations for subnet accessibility.Note: These instructions are specifically tailored for Debian-based systems that use the traditional /etc/network/interfaces method. If you are using Ubuntu (17.10 and later), you will need to use Netplan for network configuration, which follows a different syntax and structure.
Understanding IPv6 Addressing
Each Hetzner Cloud server is assigned a /64 IPv6 subnet, which allows for a vast range of usable addresses. For example, if your assigned subnet is 2a01:4f8:1c1c:dd6::/64, you can utilize any address within this range.
Temporarily Assigning Additional IPv6 Addresses
To quickly test additional IPv6 addresses, you can use the following command:
ip address add 2a01:4f8:1c1c:dd6::3 dev eth0
To verify that the new address is reachable, use:
ping -6 2a01:4f8:1c1c:dd6::3
You can assign any address within the subnet range, such as:
ip address add 2a01:4f8:1c1c:dd6:0000:0000:1000 dev eth0
ip address add 2a01:4f8:1c1c:dd6:0000:0000:0815:0000 dev eth0
ip address add 2a01:4f8:1c1c:dd6:af9c:1c59:91a5:1d63 dev eth0
However, keep in mind that these configurations will not persist after a reboot.
Making IPv6 Address Assignments Persistent
To ensure that your additional IPv6 addresses remain configured after a reboot, you need to modify the network configuration files.
Step 1: Check Existing Configuration
Before making changes, it’s useful to check the existing IPv6 configuration. You can do this by running:
cat /etc/network/interfaces.d/50-cloud-init
This command will display the current configuration, including existing DNS and gateway settings. You can copy these details for use in your new configuration.
Step 2: Edit Network Configuration
Open or create the custom configuration file:
vi /etc/network/interfaces.d/99-custom
Step 3: Add Your Additional IPv6 Addresses
In this file, you can add configuration blocks for each additional IPv6 address you want to assign. For example:
# Additional IPs for services
iface eth0 inet6 static
address 2a01:4f8:1c1c:dd6::3/128
dns-nameservers 2a01:4ff:ff00::add:1 2a01:4ff:ff00::add:2
gateway fe80::1
iface eth0 inet6 static
address 2a01:4f8:1c1c:dd6::4/128
dns-nameservers 2a01:4ff:ff00::add:1 2a01:4ff:ff00::add:2
gateway fe80::1
Optional Step for Subnet Accessibility
If you want your server to respond to all IPs within the /64
subnet without creating individual blocks for each IPv6 address, you can add the following lines at the end of your 99-custom
file:
post-up ip -6 route add local 2a01:4f8:1c1c:dd6::/64 dev eth0
pre-down ip -6 route del local 2a01:4f8:1c1c:dd6::/64 dev eth0
Note: This step is optional. If you prefer to create specific configuration blocks for each IPv6 address that your server should be reachable at (as shown in Step 2), then this optional step is not required.
Step 4: Apply Changes
To apply your changes, restart the networking service:
systemctl restart networking
Conclusion
By following these steps, you can efficiently add additional IPv6 addresses to your Hetzner Cloud server while ensuring they persist across reboots. You have the flexibility to either create individual blocks for each address or configure your server to respond to all addresses within the subnet. Always verify that your new addresses are reachable and properly configured after making these changes.