Adding Additional IPv4 using nmcli

Note:

This guide is applicable only for KVM based VPSes running distributions that use NetworkManager (such as AlmaLinux 8/9, RockyLinux 8/9, CentOS Stream, Fedora, and similar).

To View Network Gateway and Netmask

Before configuring an additional IP, you'll need the gateway and netmask details of your server.

To know the gateway and netmask of your IP address, please see this guide here

Configuring Additional IPv4

First, we need to find the name of the network interface on our server.

To find the name of the network interface, simply run:

nmcli device status

This will give you an output similar to:

[root@test-server ~]# nmcli device status

DEVICE  TYPE      STATE      CONNECTION
eth0    ethernet  connected  eth0
lo      loopback  unmanaged  --

Here, we see that we have eth0 as our network interface from the above example.

Other similar interfaces could be ens3, enp0s3, ens18, and many more.

If that's the case, you will have to replace eth0 with the interface name you have on your server for the following steps further in this guide.

View Existing Connection

To identify the active NetworkManager connection, run:

nmcli connection show

Example output:

[root@test-server ~]# nmcli connection show

NAME   UUID                                  TYPE      DEVICE
eth0   6f6a5b58-3d6a-4d1c-a8f4-xxxxxxxxxxxx  ethernet  eth0

In this example, the connection name is eth0.

Add Additional IPv4 Address

Run the following command to add the additional IPv4 address to the existing connection:

nmcli connection modify eth0 +ipv4.addresses "IP_ADDRESS/PREFIX"

Replace:

  • eth0 with your connection name.
  • IP_ADDRESS with your additional IPv4 address.
  • PREFIX with your subnet prefix (for example 24 for a /24 network).

Example:

nmcli connection modify eth0 +ipv4.addresses 192.0.2.10/24

Apply the Changes

Bring the connection back online:

nmcli connection down eth0 && nmcli connection up eth0

Alternatively:

systemctl restart NetworkManager

Verify the Additional IPv4

Check that the IP has been assigned successfully:

ip a

You should see output similar to:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500
    inet 104.194.215.70/24 brd 104.194.215.255 scope global
    inet 192.0.2.10/24 scope global secondary

Adding Multiple Additional IPv4 Addresses

To add more IP addresses, repeat the command for each additional IPv4:

nmcli connection modify eth0 +ipv4.addresses 192.0.2.11/24
nmcli connection modify eth0 +ipv4.addresses 192.0.2.12/24
nmcli connection modify eth0 +ipv4.addresses 192.0.2.13/24

Apply the changes:

nmcli connection down eth0 && nmcli connection up eth0

Remove an Additional IPv4 Address

If you need to remove an additional IPv4 address later, use:

nmcli connection modify eth0 -ipv4.addresses 192.0.2.10/24

Then reload the connection:

nmcli connection down eth0 && nmcli connection up eth0

Verification

After completing all steps, confirm your IPs are working by:

ip a

You can also verify connectivity by pinging from the newly assigned IP:

ping -I IP_ADDRESS 8.8.8.8

Your additional IPv4 address should now be active and persistent across reboots.


CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!

1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month

Available Locations: LAX | MIA | ATL | FRA | AMS