X
X

Knowledge Base

HomepageKnowledge BaseDedicated ServerHow to Add an Additional IP on a De...

How to Add an Additional IP on a Dedicated Server (Debian/Ubuntu)

How to Add an Additional IP on Debian/Ubuntu with Netplan

This guide will walk you through the process of configuring an additional IP address on your Erkmenhost dedicated server running Debian 12 or Ubuntu 20.04 (and newer). These systems use Netplan to manage network interfaces.

Following this guide is the recommended best practice, as we will create a separate configuration file. This isolates your changes, making it simple to revert them without affecting your server's primary connection.


Step 1: Find Your Network Interface Name

First, you need to know the name of your server's main network interface. Connect to your server via SSH and run the following command:

ip a

Look through the output for your server's main IP address. The name listed next to the number (e.g., eth0, ens3, or similar) is your interface name. Note this down, as you'll need it in the next step.


Step 2: Create a New Netplan Configuration File

Next, you'll create a new .yaml configuration file inside the /etc/netplan/ directory. We'll name our example 51-cloud-init.yaml, but you can choose a different name.

Use a text editor like nano to create and open the file:

sudo nano /etc/netplan/51-cloud-init.yaml

Step 3: Add Your IP Configuration

Now, add the following configuration to the file.

Important:

  • Replace INTERFACE_NAME with the interface name you found in Step 1.
  • Replace ADDITIONAL_IP with the new IP address you want to add.
  • YAML files are very sensitive to spacing. Use spaces, not the Tab key, to indent the lines exactly as shown below.

For a single Additional IP:

Copy and paste this code, then edit the values. The /32 at the end of the IP is the subnet mask and is required.

network:
  version: 2
  ethernets:
    INTERFACE_NAME:
      dhcp4: true
      addresses:
        - ADDITIONAL_IP/32

For multiple Additional IPs:

If you need to add more than one IP, simply list them under addresses:

network:
  version: 2
  ethernets:
    INTERFACE_NAME:
      dhcp4: true
      addresses:
        - ADDITIONAL_IP_1/32
        - ADDITIONAL_IP_2/32
        - ADDITIONAL_IP_3/32

Once you are done, save the file and exit the editor (in nano, press CTRL + X, then Y, then Enter).


Step 4: Test and Apply the Configuration

Before making the change permanent, Netplan allows you to test your new configuration. This test will apply the settings for 120 seconds and automatically revert if you lose connectivity.

Run the test command:

sudo netplan try

A Note on Permissions: You may see a warning like: Permissions for /etc/netplan/51-cloud-init.yaml are too open. This is just a security notice and will not prevent your IP from working correctly. You can safely proceed.

After the test is successful, apply the configuration permanently:

sudo netplan apply

That's it! Your new IP address is now configured and active on your server.

Can't find the information you are looking for?

Create a Support Ticket
Did you find it useful?
(1 times viewed / 0 people found it helpful)

Top