It is possible to have up to five public IPv4 and IPv6 addresses per your UpCloud server. Start allocating a new IP address by logging into your UpCloud Control Panel and going to Server settings and IP Addresses -tab. You’ll need to shut down you cloud server before making changes to the network interfaces.

Add a new IP address by clicking either the button for New IPv4 Address or New IPv6 Address, the new address will then be shown at the end of the list.

After allocating new IP addresses, there are some operations that must be done at the OS-level in order for the system to become aware of the changes. Check below for OS specific instructions for your server.

Debian and Ubuntu

Log into your cloud server. Once in you’ll need to add a new interface configuration to the /etc/network/interfaces -file. Open it for edit with elevated privileges.

sudo nano /etc/network/interfaces

Then enter one of the examples underneath to the end of the file. The number of the network interface needs to be unique, set it to one larger than the previous one. If you haven’t added addresses before it should be eth3 like in the example here.

auto eth3
iface eth3 inet dhcp

In the case of IPv6 the syntax is a little different, use the following instead.

auto eth3
iface eth3 inet6 auto
   dhcp 1

Then save the file and exit the editor.

Afterwards, you’ll need to restart the network to have the changes take effect.

# On Debian you can restart the network service
sudo service networking restart
# With Ubuntu just restart the new interface, eth3 for example:
sudo ifdown eth3 && sudo ifup eth3

Check that the new interface appears and shows the correct new IP address with the following command.

ip addr

If the IP addresses are not working after this, add the following lines to /etc/sysctl.conf:

sudo nano /etc/sysctl.conf
net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0
net.ipv4.ip_forward = 1

On Ubuntu, you might also need to add the following to the specific new network interface, replace the number on the lines as appropriate.

net.ipv4.conf.eth3.rp_filter = 0
net.ipv4.conf.eth3.arp_filter = 0

Once you’ve saved the sysctl.conf, update the system with:

sudo sysctl -p

Then restart the network or interface using the same command as above and check the IP addresses again.

ip addr
5: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 6e:d7:1b:bf:63:c8 brd ff:ff:ff:ff:ff:ff
    inet 185.26.50.223/22 brd 185.26.51.255 scope global eth3
       valid_lft forever preferred_lft forever
    inet6 fe80::6cd7:1bff:febf:63c8/64 scope link
       valid_lft forever preferred_lft forever

Once you see the new interface at the end of the list like in the example above you’ve successfully configured a new IP address to your cloud server. It can now be used to connect to the host just as the other addresses.

If you have problems reaching one of the IP addresses with ping for example, try rebooting the server and test the connection again.

sudo reboot

Also, make sure your firewall settings allow connecting to the new IP address as well.

CentOS

You’ll need to create a new network interface configuration file in the /etc/sysconfig/network-scripts -folder. Copy one of the pre-existing files to have a starting point, for example, the ifcfg-eth0 to ifcfg-eth3 with:

sudo cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth3

Then open the new file and change it to suit the new interface. Replace the device number on the first line with a new higher number. Commonly it would be eth3 like in the example below if this is the first address you are adding after deploying the cloud server.

DEVICE=eth3
BOOTPROTO=dhcp
ONBOOT=yes

Check your /etc/sysctl.conf, make sure the default rp_filter is set to 0:

sudo sysctl -a | grep default.rp_filter

If not, open the file for edit and add the parameter to the end of the file

net.ipv4.conf.default.rp_filter = 0

If you made changes to the sysctl.conf, update the system with:

sudo sysctl -p

Use the following command after you have done these operations to restart the network.

sudo service network restart

Then check the IP configuration with

ip addr
5: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 6e:d7:1b:bf:49:64 brd ff:ff:ff:ff:ff:ff
    inet 185.20.138.90/22 brd 185.20.139.255 scope global dynamic eth3
       valid_lft 86189sec preferred_lft 86189sec
    inet6 fe80::6cd7:1bff:febf:4964/64 scope link
       valid_lft forever preferred_lft forever

When you see the new IP address in the command output it’s connected and ready to use.

If you have problems reaching one of the IP addresses with ping for example, try rebooting the server and test the connection again.

sudo reboot

Also, make sure your firewall settings allow connecting to the new IP address as well.

Windows

New network interfaces should show up automatically without manual configuration. In the case of IPv6, you should run a couple of commands via Command Prompt with Administrator privilege. Open the program by typing cmd in the run window and press enter, then copy in the commands below.

netsh interface ipv6 set global randomizeidentifiers=disabled store=active 
netsh interface ipv6 set global randomizeidentifiers=disabled store=persistent 
netsh interface ipv6 set privacy state=disabled store=active 
netsh interface ipv6 set privacy state=disabled store=persistent

Afterwards, you should restart the new network interface by disabling and re-enabling it at the Network Connections window.

Note that Windows Server firewall blocks ICMP requests by default. If you want to test the new interface with ping, open the firewall settings with wf.msc in the run window. Find the ICMPv4 and ICMPv6 protocols in the Inbound Rules and enable the ones you need.

Other options

It’s also possible to manually set additional public IPv4 addresses to the primary interface, for example creating aliases like eth0:1, eth0:2 on Linux, by using static configuration. Currently, this is not supported with IPv6 addresses. You can find instructions for setting up alias addresses at our articles for configuring floating IPs on CentOS, Debian, Ubuntu or Windows.