{"id":10322,"date":"2022-12-23T09:15:28","date_gmt":"2022-12-23T09:15:28","guid":{"rendered":"https:\/\/mainvps.net\/blog\/?p=10322"},"modified":"2024-12-05T11:17:34","modified_gmt":"2024-12-05T11:17:34","slug":"how-to-configure-an-ip-range-on-centos-in-linux","status":"publish","type":"post","link":"https:\/\/mainvps.net\/blog\/how-to-configure-an-ip-range-on-centos-in-linux\/","title":{"rendered":"How to configure an IP range on Centos 6\/7 OS"},"content":{"rendered":"\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" 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: #999;color:#999\" 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><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/mainvps.net\/blog\/how-to-configure-an-ip-range-on-centos-in-linux\/#A_guide_that_describes_How_to_configure_an_IP_range\" >A guide that describes How to configure an IP range.<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/mainvps.net\/blog\/how-to-configure-an-ip-range-on-centos-in-linux\/#Step_1_check_the_network_interface_and_assign_IP\" >Step 1 : check the network interface and assign IP<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/mainvps.net\/blog\/how-to-configure-an-ip-range-on-centos-in-linux\/#Step_2_Go_to_the_path_and_create_file\" >Step 2 : Go to the path and create file<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/mainvps.net\/blog\/how-to-configure-an-ip-range-on-centos-in-linux\/#Step_3_Now_we_need_to_create_the_IP_range_file\" >Step 3 : Now we need to create the IP range file.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/mainvps.net\/blog\/how-to-configure-an-ip-range-on-centos-in-linux\/#Step_4_Check_the_create_file\" >Step 4 : Check the create file<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/mainvps.net\/blog\/how-to-configure-an-ip-range-on-centos-in-linux\/#Step_5_Lets_restart_the_Network_service\" >Step 5 : Lets restart the Network service.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/mainvps.net\/blog\/how-to-configure-an-ip-range-on-centos-in-linux\/#Step_6_Add_IP_ranges_Temparory\" >Step 6 :\u00a0 Add IP ranges Temparory<\/a><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"A_guide_that_describes_How_to_configure_an_IP_range\"><\/span><strong>A guide that describes How to configure an IP range.<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The following tutorial will describe how to easily configure an IP range on CentOS 6\/7 operating systems.<\/p>\n\n\n\n<h4 class=\"wp-block-heading has-medium-font-size\"><span class=\"ez-toc-section\" id=\"Step_1_check_the_network_interface_and_assign_IP\"><\/span><strong>Step 1 : check the network interface and assign IP<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p><mark style=\"background-color: #ff6900;\" class=\"has-inline-color has-white-color\">\u00a0 #ifconfig &amp; ip a <\/mark><\/p>\n\n\n\n<p>By default, all <a href=\"https:\/\/mainvps.net\/vps\">Linux servers<\/a> are provided with one main IP address, as we can see in the screenshot below using the <mark style=\"background-color: #ff6900;\" class=\"has-inline-color has-white-color\"> \u201c<em>ip a\u201d <\/em><\/mark><em>\u00a0<\/em>command. Alternatively, you can use <mark style=\"background-color: #ff6900;\" class=\"has-inline-color has-white-color\"> \u201c<em>ifconfig\u201d <\/em><\/mark><em>\u00a0<\/em>command to see the output.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"635\" height=\"291\" src=\"https:\/\/mainvps.net\/blog\/wp-content\/uploads\/2022\/12\/1.png\" alt=\"\" class=\"wp-image-10323\" srcset=\"https:\/\/mainvps.net\/blog\/wp-content\/uploads\/2022\/12\/1.png 635w, https:\/\/mainvps.net\/blog\/wp-content\/uploads\/2022\/12\/1-300x137.png 300w\" sizes=\"auto, (max-width: 635px) 100vw, 635px\" \/><\/figure>\n\n\n\n<p>The IP range is configured on the main network interface. In this case, it\u2019s called <mark class=\"has-inline-color has-white-color\" style=\"background-color: #ff6900;\"> \u201ceth0\u201d <\/mark>, so we\u2019ll bond the IP range with it.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"642\" height=\"269\" src=\"https:\/\/mainvps.net\/blog\/wp-content\/uploads\/2022\/12\/2-e1671786707524.png\" alt=\"\" class=\"wp-image-10324\" srcset=\"https:\/\/mainvps.net\/blog\/wp-content\/uploads\/2022\/12\/2-e1671786707524.png 642w, https:\/\/mainvps.net\/blog\/wp-content\/uploads\/2022\/12\/2-e1671786707524-300x126.png 300w\" sizes=\"auto, (max-width: 642px) 100vw, 642px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading has-medium-font-size\"><span class=\"ez-toc-section\" id=\"Step_2_Go_to_the_path_and_create_file\"><\/span><strong>Step 2 : Go to the path and create file<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p><mark class=\"has-inline-color has-white-color\" style=\"background-color: #ff6900;\"> #vi\/etc\/sysconfig\/network-scritps\/ <\/mark><\/p>\n\n\n\n<p>In linux network configuration is located at&nbsp;<em><mark class=\"has-inline-color has-white-color\" style=\"background-color: #ff6900;\"> \/etc\/sysconfig\/network-scripts\/ <\/mark><\/em> The main network interface configuration file is called <em><mark class=\"has-inline-color has-white-color\" style=\"background-color: #ff6900;\"> ifcfg-$NET-ADAPTER-NAME <\/mark><\/em> In this case, it\u2019s&nbsp;<em><mark class=\"has-inline-color has-white-color\" style=\"background-color: #ff6900;\"> ifcfg-eth0 <\/mark><\/em><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"644\" height=\"213\" src=\"https:\/\/mainvps.net\/blog\/wp-content\/uploads\/2022\/12\/3.png\" alt=\"\" class=\"wp-image-10325\" srcset=\"https:\/\/mainvps.net\/blog\/wp-content\/uploads\/2022\/12\/3.png 644w, https:\/\/mainvps.net\/blog\/wp-content\/uploads\/2022\/12\/3-300x99.png 300w\" sizes=\"auto, (max-width: 644px) 100vw, 644px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading has-medium-font-size\"><span class=\"ez-toc-section\" id=\"Step_3_Now_we_need_to_create_the_IP_range_file\"><\/span><strong>Step 3 : Now we need to create the IP range file.<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p><mark class=\"has-inline-color has-white-color\" style=\"background-color: #ff6900;\">&nbsp;#vi ifcfg-range0 <\/mark><\/p>\n\n\n\n<p>To make the process easier, we\u2019ll create an IP range file. This will allow us to configure multiple IP addresses with little work. Using your preferred text editor like <mark class=\"has-inline-color has-white-color\" style=\"background-color: #ff6900;\"> \u201cvi or vim\u201d <\/mark>, in the path <em><mark class=\"has-inline-color has-white-color\" style=\"background-color: #ff6900;\">\/etc\/sysconfig\/network-scripts&nbsp;<\/mark><\/em> directory , create a file called&nbsp;<em><mark class=\"has-inline-color has-white-color\" style=\"background-color: #ff6900;\"> ifcfg-eth0-range0 <\/mark><\/em><\/p>\n\n\n\n<p><em>Keypoint&nbsp; &#8211; <\/em>To add the second range you need to create another file called <mark class=\"has-inline-color has-white-color\" style=\"background-color: #ff6900;\"> \u201cifcfg-eth0-range1\u201d <\/mark> with the CLONENUM_START start with 300 (setting up the number in CLONENUM_START is very important here to avoid the ip overwritten<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"595\" height=\"291\" src=\"https:\/\/mainvps.net\/blog\/wp-content\/uploads\/2022\/12\/4.png\" alt=\"\" class=\"wp-image-10326\" srcset=\"https:\/\/mainvps.net\/blog\/wp-content\/uploads\/2022\/12\/4.png 595w, https:\/\/mainvps.net\/blog\/wp-content\/uploads\/2022\/12\/4-300x147.png 300w\" sizes=\"auto, (max-width: 595px) 100vw, 595px\" \/><\/figure>\n\n\n\n<p>Using that information, let\u2019s configure the IP range file on our operating system:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"436\" height=\"193\" src=\"https:\/\/mainvps.net\/blog\/wp-content\/uploads\/2022\/12\/5.png\" alt=\"\" class=\"wp-image-10327\" style=\"width:648px;height:287px\" srcset=\"https:\/\/mainvps.net\/blog\/wp-content\/uploads\/2022\/12\/5.png 436w, https:\/\/mainvps.net\/blog\/wp-content\/uploads\/2022\/12\/5-300x133.png 300w\" sizes=\"auto, (max-width: 436px) 100vw, 436px\" \/><\/figure>\n\n\n\n<p>Save the changes and exit the text writer. If you\u2019ve done everything correctly, you\u2019ll see a new network configuration file has appeared in&nbsp;<em><mark class=\"has-inline-color has-white-color\" style=\"background-color: #ff6900;\"> \/etc\/sysconfig\/network-scripts\/ &nbsp;<\/mark><\/em>directory:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_4_Check_the_create_file\"><\/span><strong>Step 4 : Check the create file<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p><mark class=\"has-inline-color has-white-color\" style=\"background-color: #ff6900;\"> #ls <\/mark><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"644\" height=\"283\" src=\"https:\/\/mainvps.net\/blog\/wp-content\/uploads\/2022\/12\/6.png\" alt=\"\" class=\"wp-image-10328\" srcset=\"https:\/\/mainvps.net\/blog\/wp-content\/uploads\/2022\/12\/6.png 644w, https:\/\/mainvps.net\/blog\/wp-content\/uploads\/2022\/12\/6-300x132.png 300w\" sizes=\"auto, (max-width: 644px) 100vw, 644px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading has-medium-font-size\"><span class=\"ez-toc-section\" id=\"Step_5_Lets_restart_the_Network_service\"><\/span><strong>Step 5 : Lets restart the Network service.<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>Finally, restart the&nbsp;<em>network&nbsp;<\/em>service&nbsp; using the below command and check the IP configuration again. The IP range is now fully configured:<\/p>\n\n\n\n<p><mark class=\"has-inline-color has-white-color\" style=\"background-color: #ff6900;\"> #service network restart <\/mark><\/p>\n\n\n\n<p><mark class=\"has-inline-color has-white-color\" style=\"background-color: #ff6900;\"> #systemctl restart NetworkManager<\/mark><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"644\" height=\"389\" src=\"https:\/\/mainvps.net\/blog\/wp-content\/uploads\/2022\/12\/7.png\" alt=\"\" class=\"wp-image-10329\" srcset=\"https:\/\/mainvps.net\/blog\/wp-content\/uploads\/2022\/12\/7.png 644w, https:\/\/mainvps.net\/blog\/wp-content\/uploads\/2022\/12\/7-300x181.png 300w\" sizes=\"auto, (max-width: 644px) 100vw, 644px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading has-medium-font-size\"><span class=\"ez-toc-section\" id=\"Step_6_Add_IP_ranges_Temparory\"><\/span>Step 6 :\u00a0 Add IP ranges Temparory<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p><mark class=\"has-inline-color has-white-color\" style=\"background-color: #ff6900;\"> #for i in {3..252}; do ip addr add 213.209.148.$i\/24 dev eth0; done <\/mark><\/p>\n\n\n\n<p>KEY POINT &#8211;\u00a0 there is one shortcut also available to add the multiple IP ranges with the help of below above script, using this script configure any\u00a0 range in main <a href=\"https:\/\/www.reddit.com\/r\/linux4noobs\/comments\/8m9iz8\/what_is_a_network_interface_and_why_do_i_need_it\/\" target=\"_blank\" rel=\"noopener\">network interface<\/a> of the server, in my case main interface is \u201ceth0\u201d, but this configuration is temparory after the reboot server it will be not there.<\/p>\n\n\n\n<p><mark class=\"has-inline-color has-white-color\" style=\"background-color: #ff6900;\"> #for i in {3..252}; do ip addr add 213.209.148.$i\/24 dev eth0; done <\/mark><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A guide that describes How to configure an IP range. The following tutorial will describe how to easily configure an IP range on CentOS 6\/7 operating <a class=\"read-more-link\" href=\"https:\/\/mainvps.net\/blog\/how-to-configure-an-ip-range-on-centos-in-linux\/\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":10337,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[122],"tags":[],"class_list":["post-10322","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-system-hardware"],"_links":{"self":[{"href":"https:\/\/mainvps.net\/blog\/wp-json\/wp\/v2\/posts\/10322","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mainvps.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mainvps.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mainvps.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mainvps.net\/blog\/wp-json\/wp\/v2\/comments?post=10322"}],"version-history":[{"count":14,"href":"https:\/\/mainvps.net\/blog\/wp-json\/wp\/v2\/posts\/10322\/revisions"}],"predecessor-version":[{"id":10772,"href":"https:\/\/mainvps.net\/blog\/wp-json\/wp\/v2\/posts\/10322\/revisions\/10772"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mainvps.net\/blog\/wp-json\/wp\/v2\/media\/10337"}],"wp:attachment":[{"href":"https:\/\/mainvps.net\/blog\/wp-json\/wp\/v2\/media?parent=10322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mainvps.net\/blog\/wp-json\/wp\/v2\/categories?post=10322"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mainvps.net\/blog\/wp-json\/wp\/v2\/tags?post=10322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}