{"id":3368,"date":"2021-01-11T18:55:57","date_gmt":"2021-01-11T18:55:57","guid":{"rendered":"https:\/\/linuxways.net\/?p=3368"},"modified":"2021-01-11T19:00:09","modified_gmt":"2021-01-11T19:00:09","slug":"how-to-assign-multiple-ip-addresses-to-single-nic-in-linux-mint-20","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/mint\/how-to-assign-multiple-ip-addresses-to-single-nic-in-linux-mint-20\/","title":{"rendered":"How to Assign Multiple IP Addresses to Single NIC in Linux Mint 20"},"content":{"rendered":"<p>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 <a href=\"https:\/\/linuxways.net\/de\/centos\/how-to-assign-multiple-ip-addresses-to-single-nic-in-debian-10\/\">Debian<\/a> and <a href=\"https:\/\/linuxways.net\/de\/ubuntu\/how-to-assign-multiple-ip-addresses-to-single-nic-in-ubuntu-20-04-lts\/\">Ubuntu<\/a>. In this article, we will describe how to assign multiple IP addresses to a single NIC in Mint.<\/p>\n<p>Note: The commands and procedures have been tested on <strong>Linux mint 20<\/strong>.<\/p>\n<h2>Temporarily Assigning Multiple IP Addresses to Single NIC in Mint<\/h2>\n<p>In this method, we will see how to assign more than IP address (temporarily) to a single NIC. We will do this using the <strong>ip addr<\/strong> command. The IP address assigned by this method will be remained assigned until you reboot your system.<\/p>\n<p>The <strong>ip addr<\/strong> command is also used to <a href=\"https:\/\/linuxways.net\/de\/mint\/5-ways-to-find-your-private-ip-address-in-linux-mint-20\/\">display the current IP address<\/a> of a system. To display your IP address, simply execute this command in Terminal:<\/p>\n<pre>$ ip addr<\/pre>\n<p>This is the output of the above command which shows our system\u2019s current IP address is <strong>192.168.72.170<\/strong> on the <strong>ens33<\/strong> interface.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"831\" height=\"338\" class=\"wp-image-3369\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/view-current-ip-address.png\" alt=\"view current ip address\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/view-current-ip-address.png 831w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/view-current-ip-address-300x122.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/view-current-ip-address-768x312.png 768w\" sizes=\"auto, (max-width: 831px) 100vw, 831px\" \/><\/p>\n<p>To assign a second IP address to your Network interface card, use the below syntax:<\/p>\n<pre>$ sudo ip addr add &lt;ip-address\/net-mask&gt; dev &lt;interface&gt;<\/pre>\n<p>Where <strong>&lt;ip-address\/net-mask&gt; is the second IP address you want to allocate to your NIC &lt;interface&gt;.<\/strong><\/p>\n<p>For example, we want to add the second IP address <strong>192.168.9.5\/24<\/strong> to the NIC <strong>ens33<\/strong>. In this case, the command would be:<\/p>\n<pre>$ ip addr add <strong>192.168.9.5\/24<\/strong> dev ens33<\/pre>\n<p>Now, to check if the second IP address has been added to the network interface, run the below command:<\/p>\n<pre>$ ip a<\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"819\" height=\"386\" class=\"wp-image-3370\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/multiple-ip-addresses.png\" alt=\"multiple ip addresses\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/multiple-ip-addresses.png 819w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/multiple-ip-addresses-300x141.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/multiple-ip-addresses-768x362.png 768w\" sizes=\"auto, (max-width: 819px) 100vw, 819px\" \/><\/strong><\/p>\n<h2><strong>Removing the Multiple IP addresses from NIC<\/strong><\/h2>\n<p>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 \u201c<strong>add<\/strong>\u201d which is replaced with the \u201c<strong>del<\/strong>\u201d.<\/p>\n<p>Here is the command to remove the IP address from NIC:<\/p>\n<pre>$ sudo ip addr del &lt;ip-address\/net-mask&gt; dev &lt;interface&gt;<\/pre>\n<p>For multiple IP addresses, repeat the command for each of the IP address.<\/p>\n<p>To remove the second IP address <strong>192.168.9.5\/24 from interface ens33, <\/strong>run the following command in Terminal:<\/p>\n<pre>$ ip addr del <strong>192.168.9.5\/24<\/strong> dev ens33<\/pre>\n<h2>Permanently Assigning Multiple IP Addresses to Single NIC in Mint<\/h2>\n<p>To add multiple IP addresses to a single interface and keep it persistent, you will have to configure it in the <strong>\/etc\/network\/interfaces<\/strong> configuration file.<\/p>\n<p>To display your IP address, simply execute this command in Terminal:<\/p>\n<pre>$ ip addr<\/pre>\n<p>Here is the output of the <strong>ip addr<\/strong> command which shows our system\u2019s current IP address is <strong>192.168.72.170<\/strong> on the <strong>ens33<\/strong> interface.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"831\" height=\"338\" class=\"wp-image-3371\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-152.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-152.png 831w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-152-300x122.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-152-768x312.png 768w\" sizes=\"auto, (max-width: 831px) 100vw, 831px\" \/><\/p>\n<p>To assign a second IP address to your Network interface card, open the <strong>\/etc\/network\/interfaces<\/strong> file:<\/p>\n<pre>$ sudo nano \/etc\/network\/interfaces<\/pre>\n<p>Here is what the default configuration of the interfaces file looks like:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"656\" height=\"168\" class=\"wp-image-3372\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-153.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-153.png 656w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-153-300x77.png 300w\" sizes=\"auto, (max-width: 656px) 100vw, 656px\" \/><\/p>\n<p>In the <strong>\/etc\/network\/interfaces<\/strong> file, append the below lines:<\/p>\n<pre>iface &lt;interface&gt; inet static<\/pre>\n<pre>address &lt;ip-address&gt;<\/pre>\n<p>In the above lines, replace <strong>&lt;interface&gt;<\/strong> with the interface name you want to assign the address to and <strong>&lt;ip-address&gt;<\/strong> with the required IP address.<\/p>\n<p>For example, we want to assign the <strong>192.168.9.5\/24<\/strong> to the NIC <strong>ens33<\/strong>. In this case, the lines would be:<\/p>\n<pre>iface ens33 inet static<\/pre>\n<pre>address <strong>192.168.9.5\/24<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"649\" height=\"251\" class=\"wp-image-3373\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-154.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-154.png 649w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-154-300x116.png 300w\" sizes=\"auto, (max-width: 649px) 100vw, 649px\" \/><\/p>\n<p>Similarly, more IP addresses can be added to your NIC. Save and close the configuration file once you&#8217;re finished with the configurations.<\/p>\n<p>Now to apply the network configuration changes, either restart the networking service using the following command:<\/p>\n<pre>$ sudo systemctl restart networking.service<\/pre>\n<p>Or disable and enable the network interface as follows:<\/p>\n<pre>$ sudo ifdown ens33<\/pre>\n<pre>$ sudo ifup ens33<\/pre>\n<p>Now, to check if the secondary IP address has been added to the NIC, run the following command:<\/p>\n<pre>$ ip a<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"819\" height=\"386\" class=\"wp-image-3374\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/multiple-ip-addresses-in-mint.png\" alt=\"multiple ip addresses in Mint\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/multiple-ip-addresses-in-mint.png 819w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/multiple-ip-addresses-in-mint-300x141.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/multiple-ip-addresses-in-mint-768x362.png 768w\" sizes=\"auto, (max-width: 819px) 100vw, 819px\" \/><\/p>\n<h2>Removing the Multiple IP addresses from NIC<\/h2>\n<p>You can remove the secondary IP addresses either through the <strong>ip addr<\/strong> command or through the <strong>\/etc\/network\/interfaces<\/strong> file.<\/p>\n<p>To remove IP address through the <strong>ip addr<\/strong> command, use the following syntax:<\/p>\n<pre>$ sudo ip addr del &lt;ip-address\/net-mask&gt; dev &lt;interface&gt;<\/pre>\n<p>For example, to remove the second IP address <strong>192.168.9.5\/24 from interface ens33, <\/strong>run the following command in Terminal:<\/p>\n<pre>$ ip addr del <strong>192.168.9.5\/24<\/strong> dev ens33<\/pre>\n<p>To remove IP address through the <strong>\/etc\/network\/interfaces<\/strong> file, open this file through the following command:<\/p>\n<pre>$ sudo nano \/etc\/network\/interfaces<\/pre>\n<p>Then remove the IP address entry address from the file. Then save and close the configuration file once you&#8217;re finished with the configurations.<\/p>\n<p>Now to apply the network configuration changes, either restart the networking service using the following command:<\/p>\n<pre>$ sudo systemctl restart networking.service<\/pre>\n<p>Or disable and enable the network interface as follows:<\/p>\n<pre>$ sudo ifdown ens33<\/pre>\n<pre>$ sudo ifup ens33<\/pre>\n<p>Now, to check if the second IP address has been removed from the NIC, run the following command:<\/p>\n<pre>$ ip a<\/pre>\n<p>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.<\/p>","protected":false},"excerpt":{"rendered":"<p>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&hellip;<\/p>","protected":false},"author":4,"featured_media":3375,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[129,109],"class_list":["post-3368","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mint","tag-linux-mint-20","tag-multiple-ip-addresses"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/3368","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=3368"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/3368\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/3375"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=3368"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=3368"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=3368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}