Assign Multiple IP Addresses to Single NIC in Linux Mint 20 - How to Do it ?

There are certain cases when you are required to have multiple NICs attached to your system. Like when you have two separate networks in your office and you need to connect to both of them or you want to host multiple SSL websites, and so on. 

In such cases, you should not purchase additional NICs. Instead, you can assign more than one IP addresses to a single interface. 

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform Linux Mint queries.

Previously, we have reviewed assigning multiple IP addresses to a single NIC in Debian  and Ubuntu.

In this context, we shall look into how to assign multiple IP addresses to a single NIC in Mint.


How to Temporarily Assigning Multiple IP Addresses to Single NIC in Mint ?

Here, you will learn how to assign more than IP address (temporarily) to a single NIC. We will do this using the ip addr command. 

The IP address assigned by this method will be remained assigned until you reboot your system.

The ip addr command is also used to show the current IP address of a system .

To display your IP address, simply execute this command in Terminal:

$ ip addr

The output of the above command will shows the system's current IP address as well as its interface.


To assign a second IP address to your Network interface card, use the below syntax:

$ sudo ip addr add <ip-address/net-mask> dev <interface>

Where <ip-address/net-mask> is the second IP address you want to allocate to your NIC <interface>.


Now, to check if the second IP address has been added to the network interface, run the below command:

$ ip a


How to remove the Multiple IP addresses from NIC ?

You can also remove multiple IP addresses allocated to a NIC. The command to remove the IP address is almost similar to the one that is used to add the IP address, except “add” which is replaced with the “del”.

Here is the command to remove the IP address from NIC:

$ sudo ip addr del <ip-address/net-mask> dev <interface>

For multiple IP addresses, repeat the command for each of the IP address.


How to Permanently Assigning Multiple IP Addresses to Single NIC in Mint ?

To add multiple IP addresses to a single interface and keep it persistent, you will have to configure it in the /etc/network/interfaces configuration file.

To display your IP address, simply execute this command in Terminal:

$ ip addr

Here, the output of the ip addr command will shows our system's current IP address as well as its interface.


To assign a second IP address to your Network interface card, open the /etc/network/interfaces file:

$ sudo nano /etc/network/interfaces

In the /etc/network/interfaces file, append the below lines:

iface <interface> inet static
address <ip-address>

In the above lines, replace <interface> with the interface name you want to assign the address to and <ip-address> with the required IP address.


Also, more IP addresses can be added to your NIC.

Save and close the configuration file once you’re finished with the configurations.

Now to apply the network configuration changes, either restart the networking service using the following command:

$ sudo systemctl restart networking.service

Or disable and enable the network interface as follows:

$ sudo ifdown ens33
$ sudo ifup ens33

Now, to check if the secondary IP address has been added to the NIC, run the following command:

$ ip a


How to remove the Multiple IP addresses from NIC ?

You can remove the secondary IP addresses either through the ip addr command or through the /etc/network/interfaces file.

To remove IP address through the ip addr command, use the following syntax:

$ sudo ip addr del <ip-address/net-mask> dev <interface>

To remove IP address through the /etc/network/interfaces file, open this file through the following command:

$ sudo nano /etc/network/interfaces

Then remove the IP address entry address from the file.

Then save and close the configuration file once you’re finished with the configurations.


Now to apply the network configuration changes, either restart the networking service using the following command:

$ sudo systemctl restart networking.service

Or disable and enable the network interface as follows:

$ sudo ifdown ens33
$ sudo ifup ens33

Now, to check if the second IP address has been removed from the NIC, run the following command:

$ ip a


[Need urgent assistance to install missing packages on Linux Mint? We can help you. ]

This article covers how to assign multiple IP addresses to a single interface in Mint OS. By following our guide carefully, you can either assign the IP address temporarily or permanently to your network interface.

NIC stands for network interface controller or network interface (controller) card. WNIC is wireless network interface controller or wireless network interface (controller) card. IP Addresses belong to network interfaces, not to the computer itself.


To Restart network service using command:

# systemctl restart network

To Verify the new IP address using command:

# ip addr


How configure multiple IP address in CentOS ?

Now, in order to add additional IP addresses you'll need to edit the configuration file (from hereon called “config file”) for this specific interface. On CentOS 7, the interface config files are located in /etc/sysconfig/network-scripts/ and they are all prefixed with ifcfg-.


How remove secondary IP address Linux?

To add or remove additional IP adresses and keep the configuration persistent, we need to Edit the corresponding /etc/sysconfig/network-scripts/ifcfg-eth[x] configuration file and add/remove as many additional IPADDR[n] and PREFIX[n] entries as additional IP addresses are required.


To configure a static IP address on CentOS  / RHEL :

1. Create a file named /etc/sysconfig/network-scripts/ifcfg-eth0 as follows:

DEVICE=eth0.

BOOTPROTO=none.

ONBOOT=yes.

PREFIX=24.

IPADDR=your_ip_address

2. Restart network service: systemctl restart network.


How do I login as a different user in Linux?

To change to a different user and create a session as if the other user had logged in from a command prompt, type "su -" followed by a space and the target user's username. Type the target user's password when prompted.


What is Nmcli in Linux?

nmcli is a command-line tool which is used for controlling NetworkManager. nmcli commnad can also be used to display network device status, create, edit, activate/deactivate, and delete network connections. Typical Uses: Scripts: Instead of manually managing the network connections it utilize NetworkMaager via nmcli.


Difference between the output of ifconfig and ipconfig:

Functionality: The ipconfig command displays all the currently connected network interfaces whether they are active or not. 

On the other hand, the ifconfig command displays only the enabled network interfaces that are connected to the system.

Related Posts