{"id":366,"date":"2012-05-02T10:03:38","date_gmt":"2012-05-02T10:03:38","guid":{"rendered":"http:\/\/www.plugged.in\/?p=366"},"modified":"2012-05-02T10:03:38","modified_gmt":"2012-05-02T10:03:38","slug":"bind-multiple-ip-addresses-on-a-single-network-card","status":"publish","type":"post","link":"https:\/\/www.veriteknik.net.tr\/en\/bind-multiple-ip-addresses-on-a-single-network-card\/","title":{"rendered":"Bind Multiple IP Addresses on a Single Network Card IPv4 &#038; IPv6"},"content":{"rendered":"<p>The beauty of having multiple IP addresses on a single server is that you can run several services with different addressing. This way you can announce your FTP service on a different address and your HTTP on another.<\/p>\n<p>Below I&#8217;ll describe how to achieve this in Debian based and Red Hat based distros seperately.<\/p>\n<p>Using Debian based distros (Ubuntu, Mint etc.), setting multiple IP addresses on a single network interface is simple.<\/p>\n<p>What we will do is to edit the \/etc\/network\/interfaces file.<br \/>\nIf you are using DHCP, then your file should look similar to this,<\/p>\n<pre class=\"brush: text; gutter: true; first-line: 1\">auto eth0\niface eth0 inet dhcp\n\nauto eth0:0\niface eth0:0 inet dhcp\niface eth0:0 inet6 dhcp<\/pre>\n<p>Here, the <strong>eth0:0<\/strong> is how we get the secondary IP address on the <strong>eth0<\/strong> device.<\/p>\n<p>If you&#8217;re using a static IP address instead of DHCP, then your interfaces file should be like,<\/p>\n<pre class=\"brush: text; gutter: true; first-line: 1\">auto eth0\niface eth0 inet static\naddress 10.20.30.40\nnetmask 255.255.255.0\nnetwork 10.20.30.0\nbroadcast 10.20.30.255\ngateway 10.20.30.1\ndns-nameservers 8.8.8.8\n\niface eth0 inet6 static\naddress 2f00:7300:100::10\nnetmask 64\n\nauto eth0:0\niface eth0:0 inet static\naddress 10.20.30.41\nnetmask 255.255.255.0\n\niface eth0:0 inet6 static\naddress 2f00:7300:100::11\nnetmask 64<\/pre>\n<p>You can add as many as you want, such as <strong>eth0:1<\/strong>, <strong>eth0:2<\/strong> &#8230;<\/p>\n<p>Sometimes when adding multiple IPv6 addresses on Debian systems, it is possible that you get an error. The current workaround for that is to enable and disable the device a couple of times. You can find the solution to that problem <a href=\"https:\/\/bugs.launchpad.net\/ubuntu\/+source\/ifupdown\/+bug\/617978\" target=\"_blank\">here<\/a>.<\/p>\n<p>In Red Hat based distros (CentOS, Fedora etc.), the interfaces are edited through the directory <strong>\/etc\/sysconfig\/network-scritps<\/strong>. Here we have multiple files, each pointing for a device. For instance, to have 2 additional IP&#8217;s on a single ethernet device (totaling 3 addresses) we should have 3 files as follows,<\/p>\n<p><strong>\/etc\/sysconfig\/network-scripts\/ifcfg-eth0<br \/>\n\/etc\/sysconfig\/network-scripts\/ifcfg-eth0:1<br \/>\n\/etc\/sysconfig\/network-scripts\/ifcfg-eth0:2<\/strong><\/p>\n<p>The main device file would be just a standard one, we don&#8217;t have to change anything with it.<br \/>\nOn the other hand, the <strong>ifcfg-eth0:1<\/strong> file should be similar to this,<\/p>\n<pre class=\"brush: text; gutter: true; first-line: 1\">NAME=\"\"\nBOOTPROTO=static\nMACADDR=\"\"\nIPV6INIT=no\nDEVICE=eth0:1\nNETMASK=255.255.255.0\nMTU=\"\"\nBROADCAST=10.20.30.255\nONPARENT=yes\nIPADDR=10.20.30.41\nNETWORK=10.20.30.0\nIPV6INIT=yes\nIPV6ADDR=2f00:7300:100::11\nIPV6_DEFAULTGW=2f00:7300:100::1\nONBOOT=yes<\/pre>\n<p>This would suffice. Don&#8217;t forget to restart your network services after adding the lines (or files) to with your appropriate settings.<\/p>\n<p>For Debian : <strong>$ \/etc\/init.d\/networking stop &amp;&amp; \/etc\/init.d\/networking start<\/strong><br \/>\nFor Red Hat : <strong>$ service network restart<\/strong><\/p>\n<p>For additional IPv6 addresses you should need to add\u00a0IPV6ADDR_SECONDARIES=&#8221;&#8221; line to \/etc\/sysconfig\/network-scripts\/ifcfg-eth0 file<\/p>\n<pre class=\"brush: text; gutter: true; first-line: 1\">IPV6INIT=yes\nIPV6ADDR=2f00:7300:1::2\/64\nIPV6ADDR_SECONDARIES=\"2f00:7300:1::3\/64 2f00:7300:1::4\/64 2f00:7300:1::fff4\/64 2f00:7300:1::fff5\/64\"<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The beauty of having multiple IP addresses on a single server is that you can run several services with different addressing. This way you can announce your FTP service on a different address and your HTTP on another. Below I&#8217;ll describe how to achieve this in Debian based and Red Hat based distros seperately. Using [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"categories":[370,386],"tags":[402,491,492,409,371,493],"yst_prominent_words":[911,930,1900,1905,928,1909,605,711,1908,908,839,925,1899,1903,1904,1902,148,1907,1901,1906],"class_list":["post-366","post","type-post","status-publish","format-standard","hentry","category-linux","category-network","tag-bind","tag-ip","tag-ipv4","tag-ipv6","tag-linux-2","tag-network-2"],"jetpack_featured_media_url":"","uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Mustafa Emre Ayd\u0131n","author_link":"https:\/\/www.veriteknik.net.tr\/en\/author\/eaydin\/"},"uagb_comment_info":0,"uagb_excerpt":"The beauty of having multiple IP addresses on a single server is that you can run several services with different addressing. This way you can announce your FTP service on a different address and your HTTP on another. Below I&#8217;ll describe how to achieve this in Debian based and Red Hat based distros seperately. Using&hellip;","_links":{"self":[{"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/posts\/366","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/comments?post=366"}],"version-history":[{"count":0,"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/posts\/366\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/media?parent=366"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/categories?post=366"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/tags?post=366"},{"taxonomy":"yst_prominent_words","embeddable":true,"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/yst_prominent_words?post=366"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}