How to Assign Multiple IP Addresses to Single NIC in Red Hat Enterprise Linux 9

How to Assign Multiple IP Addresses to Single NIC in Red Hat Enterprise Linux 9

There could be several reasons for assigning multiple IP addresses to a single NIC. You can host multiple websites on different IP addresses. Assigning multiple IP addresses helps you to assign IP addresses to different subnets.

There are several methods to assign multiple IP addresses to a single NIC in Red Hat Enterprise Linux 9. In this tutorial, we will teach you the methods to assign multiple IP addresses to a single NIC using nmcli tool.

List connections

Open up the terminal and list all network connections of your machine. Note down the connection to whom you want to assign multiple addresses.

Add multiple addresses

For the sake of understanding, suppose we want to assign multiple IP addresses in CIDR notation (10.1.1.1, 10.1.1.2) to ens160 interface. We will modify the connection and would run on the terminal:

sudo nmcli connection modify 'ens160' +ipv4.addresses "10.1.1.1/8, 10.1.1.2/8"

Apply the changes

Keep the Interface down and then up so that the changes are applied. Run on the terminal.

sudo nmcli connection down 'ens160'
sudo nmcli connection up ‘ens160’

Verify the changes

Let’s verify the changes made to the interface. You should run:

nmcli con show ens160

You can see from the below partial output, that both ip addresses have been assigned.

Let’s ping them one by one to see if they are working correctly and responding to ping requests.

ping 10.1.1.1

Conclusion

By now, we expect you have successfully assigned multiple IP addresses to a single NIC. If you have any questions or feedback, ping us using comments. Keep visiting Linux World.