When you order an additional IPv4 address or add an additional IPv6 address to your IP addresses via the control panel, these are not automatically added to your VPS via DHCP. You will need to manually add the additional IP addresses to the network interfaces.
In this article, we explain how to add or set a static IPv4 and IPv6 address on your Ubuntu 24.04 VPS. For this, you need an additional IPv4 and/or IPv6 address (depending on what you want to set up/add). Don't have one yet? First, consult one of the following articles:
- Order an additional IPv4 address in the control panel
- Create an additional IPv6 address in the control panel
See here for an overview of all our guides on how to add or statically set IPv4 and IPv6 addresses on different Linux distros, or here for Windows.
- This guide is about public IP addresses. In this guide you will find more information about setting up internal addresses (for your private network).
- A VPS comes with one IPv4 address by default, but you can expand this to a maximum of 20 IPv4 addresses.
- Each VPS has a default /64 IPv6 range at its disposal, from which IP addresses can be added as desired. A /64 IPv6 range contains a total of 18,446,744,073,709,551,616 IP addresses, so the chance is quite small that you will run out! The gateway is outside this range, so always set the netmask to 48.
Adding an IPv4 address in Ubuntu 24.04
Step 1
Connect to your VPS via the VPS console or via SSH.
Step 2
Once logged in, you can view the current network interfaces and the IPs assigned to them using the command:
ip a
You will see an overview as shown below.
Step 3
Note: If you are using the fast installs feature for VPS and chose installation via SSH keys, one-time password, or cloud-config user data, there are additional steps involved in the configuration. Click below on 'Fast installs process' for these steps.
Fast installs process
For Fast Installs, we use Cloud Init. Cloud Init automatically overrides your network configuration, so either Cloud Init or its network control must be disabled as follows (the choice is yours):
Disable Cloud Init network management
Open/create the following file:
nano /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
Add the content below to the file. Then save your changes and close the file (ctrl + x > y > enter).
network:
config: disabled
To avoid confusion in the future, it is recommended to rename the network configuration file created by Cloud Init to 01-netcfg.yaml. You can do this with the command:
mv /etc/netplan/50-cloud-init.yaml /etc/netplan/01-netcfg.yaml
You can now proceed with the rest of step 3.
Disable Cloud Init
Cloud Init is only used for the initial setup of your VPS. It does no harm to completely disable Cloud Init. You can do this by creating a single empty file:
touch /etc/cloud/cloud-init.disabled
To avoid confusion in the future, it is recommended to rename the network configuration file created by Cloud Init to 01-netcfg.yaml. You can do this with the command:
mv /etc/netplan/50-cloud-init.yaml /etc/netplan/01-netcfg.yaml
You can now proceed with the rest of step 3. If after following this guide, Cloud Init does not process the change correctly, execute the following command:
dpkg-reconfigure cloud-init
Now add the extra IPv4 address to the network interfaces. To do this, open the network interface configuration:
sudo nano /etc/netplan/01-netcfg.yaml
A configuration file will open that looks like the screenshot below.
Expand the values in the file as follows:
ethernets:
ens3:
dhcp4: no
dhcp6: yes
addresses:
- 149.210.181.124/24
- 149.210.189.113/24
routes:
- to: default
via: 149.210.181.1
- Under 'addresses', first enter your primary IPv4 address with the /24 range addition (in our example 149.210.181.124/24).
- Add extra IPv4 addresses on a new line with the same syntax, e.g.: - 149.210.189.113/24
- The IPv4 addresses you enter under 'Addresses' can be found in your control panel.
- Under 'routes' > 'via', use the IPv4 gateway address of your primary IP address as the gateway (also found in the control panel). Do not specify a gateway for secondary IP addresses.
Do not modify other existing variables such as ‘match’, ‘set-name’ and 'version'.
Save the changes and exit nano (ctrl + x > y > enter).
Step 4
To apply the new IP address, process the changes with the following command:
sudo netplan apply
Step 5
When you now run ip a again, you will see the newly added IPv4 address. You can test this IP address by performing a ping test from another computer/IP.
If you don't see the correct configuration, check if there is a file named 01-network-manager-all.yaml in /etc/netplan/ with the command:
ls /etc/netplan/
If so, rename the file with the command:
sudo mv /etc/netplan/01-network-manager-all.yaml /etc/netplan/01-network-manager-all-yaml.backup
Then repeat steps 4 and 5. You should now see the correct configuration.
Adding an IPv6 address in Ubuntu 24.04
Step 1
Connect to your VPS via the VPS console or via SSH.
Step 2
Once logged in, you can view the current network interfaces and the IPs assigned to them using the command:
ip a
You will see an overview as shown below.
Step 3
Note: If you are using the fast installs feature for VPS and chose installation via SSH keys, one-time password, or cloud-config user data, there are additional steps involved in the configuration. Click below on 'Fast installs process' for these steps.
Fast installs process
For Fast Installs, we use Cloud Init. Cloud Init automatically overrides your network configuration, so either Cloud Init or its network control must be disabled as follows (the choice is yours):
Disable Cloud Init network management
Open/create the following file:
nano /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
Add the content below to the file. Then save your changes and close the file (ctrl + x > y > enter).
network:
config: disabled
To avoid confusion in the future, it is recommended to rename the network configuration file created by Cloud Init to 01-netcfg.yaml. You can do this with the command:
mv /etc/netplan/50-cloud-init.yaml /etc/netplan/01-netcfg.yaml
You can now proceed with the rest of step 3.
Disable Cloud Init
Cloud Init is only used for the initial setup of your VPS. It does no harm to completely disable Cloud Init. You can do this by creating a single empty file:
touch /etc/cloud/cloud-init.disabled
To avoid confusion in the future, it is recommended to rename the network configuration file created by Cloud Init to 01-netcfg.yaml. You can do this with the command:
mv /etc/netplan/50-cloud-init.yaml /etc/netplan/01-netcfg.yaml
You can now proceed with the rest of step 3. If after following this guide, Cloud Init does not process the change correctly, execute the following command:
dpkg-reconfigure cloud-init
Now add the extra IPv6 address to the network interfaces. First, open the network interface configuration:
sudo nano /etc/netplan/01-netcfg.yaml
A configuration file will open that looks like the screenshot below (nano has been slightly modified in the current, newer version).
Adjust the values in the file as follows:
ethernets:
ens3:
dhcp4: yes
dhcp6: no
addresses:
- 2a01:7c8:aab5:4cd::1/48
- 2a01:7c8:aab5:4cd::2/48
routes:
- to: default
via: 2a01:7c8:aab5::1
- Under 'addresses', first enter your primary IPv6 address with the /48 range addition (in our example 2a01:7c8:aab5:4cd::1/48).
- Add extra IP addresses on a new line with the same syntax, e.g.: - 2a01:7c8:aab5:4cd::2/48
- The IPv6 addresses you enter under 'Addresses' can be found in your control panel.
- Under 'routes' > 'via', use the IPv6 gateway address of your primary IPv6 address as the gateway (also found in the control panel). Do not specify a gateway for secondary IPv6 addresses.
Do not modify other existing variables such as ‘match’, ‘set-name’ and 'version'.
Save the changes and exit nano (ctrl + x > y > enter).
Step 4
To apply the new IP address, process the changes with the following command:
sudo netplan apply
Step 5
When you now run ip a again, you will see the newly added IPv4 address. You can test this IP address by performing a ping test from another computer/IP.
You can combine the steps for IPv4 and IPv6 to statically set both your IPv4 and IPv6 addresses, for example, as follows:
ethernets:
ens3:
dhcp4: no
dhcp6: no
addresses:
- 149.210.181.124/24
- 149.210.189.113/24
- 2a01:7c8:aab5:4cd::1/48
- 2a01:7c8:aab5:4cd::2/48
routes:
- to: default
via: 149.210.181.1
- to: default
via: 2a01:7c8:aab5::1
If you don't see the correct configuration, check if there is a file named 01-network-manager-all.yaml in /etc/netplan/ with the command:
ls /etc/netplan/
If so, rename the file with the command:
sudo mv /etc/netplan/01-network-manager-all.yaml /etc/netplan/01-network-manager-all-yaml.backup
Then repeat steps 4 and 5. You should now see the correct configuration.