1. Home
  2. Knowledge Base
  3. Product
  4. Networking
  5. Assign Multiple Secondary IPs on Different Operating Systems

Assign Multiple Secondary IPs on Different Operating Systems

This guide explains how to add multiple secondary IP addresses on your network interface across Ubuntu/Debian, CentOS/AlmaLinux.


🐧 Ubuntu / Debian

1. Check active interface

ip a

Example output:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 ...
    inet 192.168.1.100/24 brd 192.168.1.255 scope global eth0

Interface name here is eth0.

2. Backup network configuration

sudo cp /etc/netplan/50-cloud-init.yaml /etc/netplan/50-cloud-init.yaml.bak

(Optional: Backup the full Netplan directory)

sudo cp -r /etc/netplan /etc/netplan_backup_$(date +%F)

3. Edit configuration

sudo vi /etc/netplan/50-cloud-init.yaml

Add multiple IPs under your interface:

network:
  version: 2
  ethernets:
    eth0:
      dhcp4: no
      addresses:
        - 192.168.1.100/24   # Primary
        - 192.168.1.101/24   # Secondary 1
        - 192.168.1.102/24   # Secondary 2
      gateway4: 192.168.1.1
      nameservers:
        addresses:
          - 8.8.8.8
          - 8.8.4.4

4. Apply and verify

sudo netplan apply
ip a show eth0

🐧 CentOS / AlmaLinux / Rocky

1. Check active interface

ip addr

Example output:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> ...
    inet 192.168.1.100/24 brd 192.168.1.255 scope global eth0

Interface name here is eth0.

2. Backup existing config

sudo cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.bak

3. Create alias files for secondary IPs

Secondary IP 1

sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0:0

Add:

DEVICE=eth0:0
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.1.101
PREFIX=24

Secondary IP 2

sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0:1

Add:

DEVICE=eth0:1
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.1.102
PREFIX=24

4. Apply and verify

sudo systemctl restart NetworkManager
ip addr show eth0

This article provides a step-by-step approach to assigning multiple secondary IPs across major Linux distributions.

Was this article helpful?

Related Articles

This is a staging environment