{"id":1553,"date":"2012-01-05T23:33:53","date_gmt":"2012-01-05T15:33:53","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=1553"},"modified":"2023-06-25T09:13:27","modified_gmt":"2023-06-25T09:13:27","slug":"how-to-configure-static-ip-address-on-centos-6-2-linux-server","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-configure-static-ip-address-on-centos-6-2-linux-server\/","title":{"rendered":"How to Configure Static IP Address on CentOS 6.2 Linux Server"},"content":{"rendered":"<p>In server administration, configuring a static IP address on your CentOS 6.2 Linux server is a fundamental skill.<\/p>\n<p>This guide will walk you through the process step-by-step, ensuring you understand each part of the process. This tutorial is designed for those who have already installed CentOS 6.2 on their server.<\/p>\n<p>Upon the completion of your CentOS 6.2 installation, your network configuration will look something like this:<\/p>\n<pre>\r\nDEVICE=\"eth0\"\r\nHWADDR=\"xx:xx:xx:xx:xx:xx\"\r\nNM_CONTROLLED=\"yes\"\r\nONBOOT=\"no\"\r\n<\/pre>\n<p>This configuration means that your system will not automatically acquire an IP address, and the network interface will not auto-start even after the server is rebooted. This guide will show you how to set a static IP and configure it to auto-start upon reboot.<\/p>\n<h2>Step 1: Configure eth0<\/h2>\n<p>The first step is to configure your network interface, eth0. Open the network scripts for eth0 by typing the following command into your terminal:<\/p>\n<pre>\r\n[root@centos6 ~]# vi \/etc\/sysconfig\/network-scripts\/ifcfg-eth0\r\n<\/pre>\n<p>In the opened file, set the following parameters:<\/p>\n<pre>\r\nDEVICE=\"eth0\"\r\nHWADDR=\"00:0C:29:67:51:B1\"\r\nNM_CONTROLLED=\"yes\"\r\nONBOOT=\"yes\"\r\nIPADDR=192.168.1.44\r\nBOOTPRO=static\r\nNETMASK=255.255.255.0\r\n<\/pre>\n<p>This configuration sets your network interface (eth0) to start automatically upon boot (ONBOOT=&#8221;yes&#8221;) and assigns it a static IP address (IPADDR=192.168.1.44) with a netmask of 255.255.255.0.<\/p>\n<h2>Step 2: Configure Default Gateway<\/h2>\n<p>The next step is to configure your default gateway. Open the network configuration file by typing the following command into your terminal:<\/p>\n<pre>\r\n[root@centos6 ~]# vi \/etc\/sysconfig\/network\r\n<\/pre>\n<p>In the opened file, set the following parameters:<\/p>\n<pre>\r\nNETWORKING=yes\r\nHOSTNAME=centos6.2\r\nGATEWAY=192.168.1.1\r\n<\/pre>\n<p>This configuration enables networking (NETWORKING=yes), sets your hostname (HOSTNAME=centos6.2), and defines your default gateway (GATEWAY=192.168.1.1).<\/p>\n<h2>Step 3: Restart Network Interface<\/h2>\n<p>After configuring your network interface and default gateway, you need to restart your network interface for the changes to take effect. You can do this by typing one of the following commands into your terminal:<\/p>\n<pre>\r\n[root@centos6 ~]# \/etc\/init.d\/network restart\r\n<\/pre>\n<p>or<\/p>\n<pre>\r\n[root@centos6 ~]# Service network restart\r\n<\/pre>\n<h2>Step 4: Configure DNS Server<\/h2>\n<p>The final step is to configure your DNS server. Open the resolv.conf file by typing the following command intoyour terminal:<\/p>\n<pre>\r\n[root@centos6 ~]# vi \/etc\/resolv.conf\r\n<\/pre>\n<p>In the opened file, set the following parameters:<\/p>\n<pre>\r\nnameserver 8.8.8.8\r\nnameserver 192.168.1.1\r\n<\/pre>\n<p>This configuration sets your primary DNS server to 8.8.8.8 (Google&#8217;s public DNS server) and your secondary DNS server to 192.168.1.1 (usually your router&#8217;s IP address).<\/p>\n<h2>Commands Mentioned<\/h2>\n<ul>\n<li><span class=\"fw-bold\">vi \/etc\/sysconfig\/network-scripts\/ifcfg-eth0<\/span> \u2013 Opens the network scripts for the eth0 interface<\/li>\n<li><span class=\"fw-bold\">vi \/etc\/sysconfig\/network<\/span> \u2013 Opens the network configuration file<\/li>\n<li><span class=\"fw-bold\">\/etc\/init.d\/network restart<\/span> \u2013 Restarts the network interface<\/li>\n<li><span class=\"fw-bold\">Service network restart<\/span> \u2013 An alternative command to restart the network interface<\/li>\n<li><span class=\"fw-bold\">vi \/etc\/resolv.conf<\/span> \u2013 Opens the DNS configuration file<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>Configuring a static IP address on your CentOS 6.2 Linux server is a crucial step in setting up your server for optimal performance. By following this guide, you&#8217;ve learned how to configure your network interface, set a static IP address, configure your default gateway, and set up your DNS servers. Remember, understanding each step of the process is key to successful server administration.<\/p>\n<p>Whether you&#8217;re running a <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-dedicated-server-hosting\/\">dedicated server<\/a>, a <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-vps-hosting\/\">VPS server<\/a>, or utilizing <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-cloud-hosting\/\">cloud hosting<\/a> or <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-shared-hosting\/\">shared hosting<\/a>, having a firm grasp on these fundamental skills will serve you well. Keep exploring, keep learning, and keep pushing the boundaries of what you can do with your server.<\/p>\n<h2>FAQ<\/h2>\n<ol itemscope itemtype=\"https:\/\/schema.org\/FAQPage\">\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">What is a static IP address?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">A static IP address is a fixed IP address that is manually assigned to a device on a network. Unlike dynamic IP addresses, which are assigned by a DHCP server and can change over time, static IP addresses remain constant.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">Why would I need to configure a static IP address on my server?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">Configuring a static IP address on your server ensures that the IP address remains constant, even after a reboot. This is crucial for services that require a consistent IP address, such as DNS servers, mail servers, or websites.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">What is the purpose of the &#8220;ONBOOT&#8221; parameter in the network configuration?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">The &#8220;ONBOOT&#8221; parameter in the network configuration determines whether the network interface should be activated at boot time. If set to &#8220;yes&#8221;, the network interface will automatically start upon system boot.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">What is a DNS server and why do I need to configure it?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">A DNS (Domain Name System) server translates domain names into IP addresses. This allows users to access websites by typing in the domain name instead of the IP address. Configuring a DNS server ensures your server can resolve domain names correctly.<\/span>\n            <\/p>\n<\/li>\n<li itemscopeitemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">What is the difference between a primary and secondary DNS server?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">The primary DNS server is the first server your computer will query to resolve a domain name into an IP address. If the primary DNS server is unavailable or cannot provide the requested information, your computer will query the secondary DNS server.<\/span>\n            <\/p>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>In server administration, configuring a static IP address on your CentOS 6.2 Linux server is a fundamental skill. This guide will walk you through the process step-by-step, ensuring you understand&#8230;<\/p>\n","protected":false},"author":6,"featured_media":1554,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[2055],"tags":[1253,2089,1536,1798],"class_list":["post-1553","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","tag-centos-6-2","tag-configuration","tag-linux","tag-static-ip"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/1553","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=1553"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/1553\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/1554"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=1553"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=1553"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=1553"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}