So Hetzner offers a “floating IP” feature which is basically an IP address you can assign to various servers.
If you follow Hetzner’s official wiki [ https://wiki.hetzner.de/index.php/Cloud_floating_IP_persistent/en ], you will just end up with a “new IP”. The default will remain. Your server will be reachable from both, but this behavior can cause issues with various tools.
So, I just change out the default IP to the floating one. If I ever need to re-assign the floating IP, I’ll just open up the Console from the Hetzner website and change it back out.
Steps to use floating as default IP. Both incoming & outgoing.
resolvconf. For some reason we need to set our own DNS otherwise the server won’t be able to do DNS lookups. Worry not, this is a very easy and simple step.
# let’s install the package
sudo apt update && sudo apt install resolvconf
# let’s open the ‘head’ file
sudo nano -w /etc/resolvconf/resolv.conf.d/head
# add a DNS such as Cloudflare and Google
2. Check the default gateway address. Without touching anything, you should check what gateway do you currently use. This can be done easily with the following command:
ip route | grep default
Note down the IP address you get. Example: “126.96.36.199”.
3. Back up the default, current network configuration.
sudo cp /etc/network/interfaces.d/50-cloud-init.cfg /root/50-cloud-init.cfg
This copy, as it is here, will copy the file into
/root/. You can place it anywhere, name it anyhow. This is only an example of course.
4. Open the
.cfg file for edit.
sudo nano -w /etc/network/interfaces.d/50-cloud-init.cfg
5. You need to edit the eth0 part. So it becomes:
iface eth0 inet static
dns-nameservers <leave them here>
gateway <write here the noted gateway ip>
You can save the file and exit. (CTRL+O and then CTRL+X).
6. At this point you can restart networking, or do a reboot. I would recommend a reboot, just to be on the safe side.
7. Once your VM boots up, only the floating IP should be in use and you should be able to ping IPs and domain addresses both.