{"id":474578,"date":"2022-07-16T09:02:34","date_gmt":"2022-07-16T06:02:34","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/how-to-add-an-additional-ip-address-to-your-linux-server\/"},"modified":"2022-07-16T09:02:34","modified_gmt":"2022-07-16T06:02:34","slug":"how-to-add-an-additional-ip-address-to-your-linux-server","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/how-to-add-an-additional-ip-address-to-your-linux-server\/","title":{"rendered":"#How to Add an Additional IP Address to Your Linux Server"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_87 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6aa07e72c3821\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6aa07e72c3821\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-add-an-additional-ip-address-to-your-linux-server\/#%E2%80%9CHow_to_Add_an_Additional_IP_Address_to_Your_Linux_Server%E2%80%9D\" >&#8220;How to Add an Additional IP Address to Your Linux Server&#8221;<\/a><ul class='ez-toc-list-level-2' ><li class='ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-add-an-additional-ip-address-to-your-linux-server\/#Why_Use_Another_IP_Address\" >Why Use Another IP Address?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-add-an-additional-ip-address-to-your-linux-server\/#How_Do_I_Get_More_IP_Addresses\" >How Do I Get More IP Addresses?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-add-an-additional-ip-address-to-your-linux-server\/#How_Do_Multiple_IP_Addresses_Work\" >How Do Multiple IP\u00a0Addresses Work?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-add-an-additional-ip-address-to-your-linux-server\/#Configuring_Linux_to_Use_Multiple_IP_Addresses\" >Configuring Linux to Use Multiple IP Addresses<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h1><span class=\"ez-toc-section\" id=\"%E2%80%9CHow_to_Add_an_Additional_IP_Address_to_Your_Linux_Server%E2%80%9D\"><\/span>&#8220;How to Add an Additional IP Address to Your Linux Server&#8221;<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<div>\n<figure style=\"width: 7360px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage wp-image-12670 size-full\" data-pagespeed-no-defer=\"\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/csit\/2021\/07\/09c0a66a.jpg?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"network switch panel\" width=\"7360\" height=\"4180\" data-crediturl=\"https:\/\/www.shutterstock.com\/image-photo\/network-panel-switch-cable-data-center-1172940130\" data-credittext=\"asharkyu\/Shutterstock.com\"\/><figcaption class=\"wp-caption-text\"><span class=\"type:primaryImage imagecredit\"><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.shutterstock.com\/image-photo\/network-panel-switch-cable-data-center-1172940130\">asharkyu\/Shutterstock.com<\/a><\/span><\/figcaption><\/figure>\n<p>Most Linux servers, including virtual private servers, will come with a public IP address for you to connect to. However, the physical network card used to carry the connection can support any number of IP addresses. Here\u2019s how to add a new one to your server.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Why_Use_Another_IP_Address\"><\/span>Why Use Another IP Address?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Having multiple addresses is great for a number of reasons. The main benefit is being able to have multiple <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">app<\/a>lications running on the same port, but on different addresses. For example, you couldn\u2019t run NGINX and Apache at the same time, as they\u2019re both web servers that need to use port 80. However, if you ran NGINX bound to one IP address, and Apache bound to another, you could do so without any conflict.<\/p>\n<p>In this case of serving web content, you can also solve this problem with a reverse proxy\u2014a type of web server that sits in front of your content, listens on one port, and directs content to other locations, often multiple different locations.<\/p>\n<p><strong>RELATED:<\/strong> <strong><em>How to Set Up a Reverse Proxy With Apache<\/em><\/strong><\/p>\n<p>However, having multiple actual IP addresses can be much simpler with no reverse proxy configuration to maintain. You simply start the services on the correct address, and it will listen directly on that address.<\/p>\n<p>Multiple addresses <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.cloudsavvyit.com\/?p=16020\">also work really well with Docker<\/a>, which is a tool that can package applications into portable containers and run them anywhere. Having multiple external IPs to bind containers to allows your server to run many different applications easily on one machine.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"How_Do_I_Get_More_IP_Addresses\"><\/span>How Do I Get More IP Addresses?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>There are a finite number of public IPs left in the world, and most are already allocated to internet companies. In order to get more, you will need to buy or rent them from your hosting provider. Most mainstream cloud providers will have an option for extra IPs, but the setup will depend on what you\u2019re using.<\/p>\n<p>For example, if you\u2019re on AWS, you probably already have an Elastic IP Address for your EC2 instances. However, you can just add more Elastic IPs, at the cost of $3.65 per month for each one.<\/p>\n<p><strong>RELATED:<\/strong> <strong><em>What Are AWS Elastic IPs, and What Do They Do?<\/em><\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-16044\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/csit\/2022\/03\/5645f99c.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"1223\" height=\"463\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Other cloud providers might let you purchase entire blocks of addresses. OVH, one of the largest dedicated server providers, offers CIDR blocks of up to \/24 in size, for a one-time fee.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-16022\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/csit\/2022\/03\/8d1961a0.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"719\" height=\"391\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Large corporations that want to directly own and control a large amount of IPv4 address space can also purchase <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/ipv4.global\/\">entire blocks directly from IANA (through a brokerage)<\/a>. However, this comes at a large premium\u2014often over $50 per address, and large blocks cost tens or even hundreds of thousands of dollars.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"How_Do_Multiple_IP_Addresses_Work\"><\/span>How Do Multiple IP\u00a0Addresses Work?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Linux networking is a little weird. Each network card physically attached to your server will show up in <code>ip addr show<\/code>\u00a0as a network interface like <code>eth0<\/code>\u00a0or <code>eno1<\/code>. There can also be various types of virtual interfaces, but all actual connections out from the server go through a physical network interface.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-16021\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/csit\/2022\/03\/f9b1591e.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"958\" height=\"320\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>IP addresses are different\u2014they are not tangible things that are associated with your server\u2019s network interface, they\u2019re simply an abstraction used to identify servers for routing. Your hosting provider will get a request, and if it\u2019s destined for an IP address you own, it will be routed to your server using the host\u2019s routing configuration.<\/p>\n<p>The key part there is that your server\u2019s network interface must be <em>configured in software<\/em> to receive that request. If your server doesn\u2019t have the address added to a network interface\u2019s config, it won\u2019t respond. You could technically configure your server to listen on any address, even ones you don\u2019t own, though it wouldn\u2019t do anything.<\/p>\n<p>IP addresses are allocated in blocks, represented in CIDR notation. The smallest is <code>\/32<\/code>, which represents a single address. As the number gets smaller, the number of addresses increases.<\/p>\n<pre>192.168.0.0\/24 -&gt; 192.168.0.0 to 192.168.0.255<\/pre>\n<p><strong>RELATED:<\/strong> <strong><em>What are Subnets, and How Do They Affect My Network?<\/em><\/strong><\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Configuring_Linux_to_Use_Multiple_IP_Addresses\"><\/span>Configuring Linux to Use Multiple IP Addresses<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Linux network configuration can be hard, and there are multiple tools out there to make it easier. One of the best is <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/netplan.io\/\"><code>netplan<\/code>, created by the team behind Ubuntu<\/a>. It configures network interfaces using easy YAML templates. It should be installed by default on most systems.<\/p>\n<p>Create a new template in <code>\/etc\/netplan\/config.yaml<\/code>:<\/p>\n<pre>sudo nano\u00a0\/etc\/netplan\/config.yaml<\/pre>\n<p>Then, add your configuration. Note that this example is for the interface <code>eno1<\/code>, which may need to be changed to <code>eth0<\/code>\u00a0or something similar.<\/p>\n<pre><!--StartFragment --><\/pre>\n<pre>network:&#13;\n    version: 2&#13;\n    ethernets:&#13;\n        eno1:&#13;\n            addresses:&#13;\n            - 123.1.2.3\/32<\/pre>\n<p>You can specify multiple address blocks here, or single IP addresses as singular\u00a0<code>\/32<\/code>\u00a0blocks.<\/p>\n<p>Once configured, run <code>netplan try<\/code>\u00a0to test it out. If the config is faulty, it will be rolled back.<\/p>\n<pre>sudo netplan try<\/pre>\n<p>If it works, apply the config:<\/p>\n<pre>sudo netplan apply<\/pre>\n<p>You can debug your routing by running <code>tcpdump<\/code>\u00a0to display requests sent to an interface:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-16045\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/csit\/2022\/03\/f012dff0.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"1070\" height=\"337\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<\/div>\n<p><script>\n setTimeout(function(){\n  !function(f,b,e,v,n,t,s)\n  {if(f.fbq)return;n=f.fbq=function(){n.callMethod?\n  n.callMethod.apply(n,arguments):n.queue.push(arguments)};\n  if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';\n  n.queue=[];t=b.createElement(e);t.async=!0;\n  t.src=v;s=b.getElementsByTagName(e)[0];\n  s.parentNode.insertBefore(t,s) } (window, document,'script',\n  'https:\/\/connect.facebook.net\/en_US\/fbevents.js');\n   fbq('init', '335401813750447');\n   fbq('track', 'PageView');\n  },3000);\n<\/script><\/p>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.howtogeek.com\/devops\/how-to-add-an-additional-ip-address-to-your-linux-server\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;How to Add an Additional IP Address to Your Linux Server&#8221; asharkyu\/Shutterstock.com Most Linux servers, including virtual private servers, will come with a public IP address for you to connect to. However, the physical network card used to carry the connection can support any number of IP addresses. Here\u2019s how to add a new one&#8230;<\/p>\n","protected":false},"author":1,"featured_media":474579,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.howtogeek.com\/wp-content\/uploads\/csit\/2021\/07\/09c0a66a.jpg?height=200p&trim=2,2,2,2","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-474578","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/474578","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=474578"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/474578\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/474579"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=474578"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=474578"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=474578"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}