Mint

How to Assign Multiple IP Addresses to Single NIC in Linux Mint 20

Assign Multiple IP Addresses on Linux Mint 20

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, etc. In such cases, you should not purchase additional NICs. Instead, you can assign more than one IP addresses to a single interface. In our previous article, we have described assigning multiple IP addresses to a single NIC in Debian and Ubuntu. In this article, we will describe how to assign multiple IP addresses to a single NIC in Mint.

Note: The commands and procedures have been tested on Linux mint 20.

Temporarily Assigning Multiple IP Addresses to Single NIC in Mint

In this method, we will see 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 display the current IP address of a system. To display your IP address, simply execute this command in Terminal:

$ ip addr

This is the output of the above command which shows our system’s current IP address is 192.168.72.170 on the ens33 interface.

view current ip address

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>.

For example, we want to add the second IP address 192.168.9.5/24 to the NIC ens33. In this case, the command would be:

$ ip addr add 192.168.9.5/24 dev ens33

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

$ ip a

multiple ip addresses

Removing 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.

To remove the second IP address 192.168.9.5/24 from interface ens33, run the following command in Terminal:

$ ip addr del 192.168.9.5/24 dev ens33

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 is the output of the ip addr command which shows our system’s current IP address is 192.168.72.170 on the ens33 interface.

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

$ sudo nano /etc/network/interfaces

Here is what the default configuration of the interfaces file looks like:

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.

For example, we want to assign the 192.168.9.5/24 to the NIC ens33. In this case, the lines would be:

iface ens33 inet static
address 192.168.9.5/24

Similarly, 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

multiple ip addresses in Mint

Removing 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>

For example, to remove the second IP address 192.168.9.5/24 from interface ens33, run the following command in Terminal:

$ ip addr del 192.168.9.5/24 dev ens33

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

This was all about assigning multiple IP addresses to a single interface in Mint OS. By following the above simple procedures, you can either assign the IP address temporarily or permanently to your network interface.

Similar Posts