0850 885 09 42 bilgi@verinomi.com Knowledge Base Support Ticket Client Area TR EN ₺ TL $ USD

Home / Knowledge Base / Linux

Knowledge Base

Guides and answers to frequently asked questions.

Back to Linux

Adding a Second (Additional) IP Address to an Ubuntu Server

Print

This guide explains how to configure the additional IP address you purchased on a server running Ubuntu 20.04, 22.04 or 24.04. On Ubuntu the network is configured with Netplan. The steps are ordered so that your SSH connection is not dropped; still, before you start we recommend making sure you can reach the server another way (for example by keeping a second SSH session open).

Before you start

Run the commands as root or with sudo. The examples below use these values; replace them with your own:

  • Network interface: ens192 (it may be different on your server, such as eth0 or ens18)
  • Primary IP address: 203.0.113.10/24, gateway: 203.0.113.1
  • Additional IP address: 203.0.113.20/24

You can see the interface name and your primary address with:

ip -4 addr show

In the output, a line such as inet 203.0.113.10/24 shows your primary address and the name at the end of the line is the interface. Your additional IP address is shown on your service's page in the client area. For the additional IP you usually use the same prefix length as your primary address (such as /24); if you were given a different value, use that one. Do not add a gateway for the additional IP.

Differences between versions

  • Ubuntu 20.04, 22.04, 24.04: the steps are the same. In the Netplan file the gateway may be written in the new form with a routes: block or in the old form with a gateway4: line; leave whichever you have as it is.
  • Ubuntu 18.04: the steps are the same, but Netplan in this version does not understand the routes: - to: default form; the gateway must stay on a gateway4: line.
  • Ubuntu 16.04: there is no Netplan; the network is configured in /etc/network/interfaces. On this version you can follow the "Adding with ifupdown" steps in the Debian article.

1. Find the Netplan file

ls -l /etc/netplan/

The folder usually holds a single .yaml file, for example 50-cloud-init.yaml or 00-installer-config.yaml. You will add the additional IP to this file. Do not create a separate file for the same interface: Netplan reads the files in name order and a later file replaces the same setting in an earlier one, so your primary address could be lost.

First back up the file (replace the file name with yours):

cp /etc/netplan/50-cloud-init.yaml /root/netplan-backup.yaml

2. If the file is named 50-cloud-init.yaml

This file is created by cloud-init when the server is first set up. So that your change is not rewritten by cloud-init, turn off cloud-init's network configuration:

printf 'network:\n  config: disabled\n' > /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg

This only stops cloud-init from touching the network configuration; the server's existing network settings stay as they are. If your file has a different name, skip this step.

3. Add the additional IP to the file

Open the file (example: nano /etc/netplan/50-cloud-init.yaml) and add the additional IP address as a new line in your interface's addresses list. Indentation uses spaces, not tabs; do not change the existing lines. The whole file looks similar to this; you only need to add the - 203.0.113.20/24 line:

network:
  version: 2
  ethernets:
    ens192:
      addresses:
        - 203.0.113.10/24
        - 203.0.113.20/24
      routes:
        - to: default
          via: 203.0.113.1
      nameservers:
        addresses: [8.8.8.8, 1.1.1.1]

If the address list in your file is written on one line (such as addresses: [203.0.113.10/24]), add the new address with a comma: addresses: [203.0.113.10/24, 203.0.113.20/24]. Leave the gateway line (routes: or gateway4:) and the DNS lines as they are.

4. Check and apply the configuration safely

First check the file for mistakes; any error is shown with its line:

netplan generate

If Netplan warns about file permissions, make the file readable by root only:

chmod 600 /etc/netplan/*.yaml

Then try the configuration:

netplan try

The command applies the new configuration and waits for your confirmation. If your connection still works, press Enter to confirm. If something goes wrong and you cannot confirm, it returns to the previous configuration automatically after 120 seconds, so you do not lose access to the server. Once confirmed, the configuration is permanent.

5. Checking

  • On the server, both addresses should appear in the output of ip -4 addr show dev ens192.
  • From your own computer, check that you can reach the new address with ping 203.0.113.20.
  • To test that it persists, you can restart the server at a convenient time and check that the address is still configured.

The address the server uses for outgoing connections does not change; it stays your primary IP address. The additional address is used for incoming connections and for the services you bind to it (for example a second website or SSL certificate).

If you use a control panel

  • Plesk: after adding the address to the operating system, go to Tools & Settings > IP Addresses in Plesk and click Reread IP.
  • cPanel: add the additional IP in WHM under IP Functions > Add a New IP Address; WHM configures the address on the server itself. In that case do not also add it to the Netplan file.

Troubleshooting

  • netplan generate shows an error: it is usually an indentation mistake. Check that the lines are indented with spaces and aligned with the ones above; if needed, restore the backup: cp /root/netplan-backup.yaml /etc/netplan/50-cloud-init.yaml
  • The new address cannot be reached: check that you entered the address and prefix length correctly. If you use a firewall on the server (ufw, iptables, nftables), make sure incoming connections to the new address are allowed.
  • The additional address is missing after a restart: if your file is named 50-cloud-init.yaml, make sure you completed step 2.
  • Access to the server was lost: if you used netplan try, wait 120 seconds and the change is reverted. If the problem continues, you can open a support ticket from the client area.
Was this answer helpful? 0

Let us call you

For sales and information requests. For technical support on an existing service, please open a support ticket.

Your details are used only to get back to you. Privacy policy