{"id":844,"date":"2011-04-16T01:10:23","date_gmt":"2011-04-15T17:10:23","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=844"},"modified":"2023-04-28T09:50:30","modified_gmt":"2023-04-28T09:50:30","slug":"how-to-set-static-ip-on-centosrhel","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-set-static-ip-on-centosrhel\/","title":{"rendered":"How to Set Static IP on CentOS\/RHEL"},"content":{"rendered":"<p>This article assume that you have installed CentOS or RHEL with minimum packages by unchecked all the software during the installation. Therefore, you will not be able to perform TCP\/IP configuration using system-config-network or setup command which provide GUI solution. With minimum packages installed, there is the simple way to change your DHCP IP to prefered static IP address. Just follow below steps that was tested on CentOS\/RHEL. Lets say the linux ip address is 192.168.2.5, Netmask is 255.255.255.0 and the default gateway is 192.168.2.1.<\/p>\n<p>The config file for interface &#8220;eth0&#8221; is located at &#8220;\/etc\/sysconfig\/network-scripts\/ifcfg-eth0&#8221;. If the adapter is configured to use DHCP, the content should be as below :<\/p>\n<ol>\n<pre class=\"code\">cat \/etc\/sysconfig\/network-scripts\/ifcfg-eth0\n<\/pre>\n<\/ol>\n<ol>\n<pre class=\"code\">DEVICE=eth0\nBOOTPROTO=dhcp\nHWADDR=00:xx:xx:xx:xx:xx\nONBOOT=yes\nDHCP_HOSTNAME=[dhcphostname]\n<\/pre>\n<\/ol>\n<p>To change it to static IP address instead, please configure as below :<\/p>\n<ol>\n<pre class=\"code\">vi \/etc\/sysconfig\/network-scripts\/ifcfg-eth0\n<\/pre>\n<\/ol>\n<ol>\n<pre class=\"code\">DEVICE=eth0\nBOOTPROTO=none\nHWADDR=00:xx:xx:xx:xx:xx\nONBOOT=yes\nTYPE=Ethernet\nNETMASK=255.255.255.0\nIPADDR=192.168.2.5\nGATEWAY=192.168.2.1\n<\/pre>\n<\/ol>\n<p>When configuration are done, please run \/etc\/init.d\/network restart to apply the changes<\/p>\n<p>Thats all. Hope this article useful for the beginner.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article assume that you have installed CentOS or RHEL with minimum packages by unchecked all the software during the installation. Therefore, you will not be able to perform TCP\/IP&#8230;<\/p>\n","protected":false},"author":6,"featured_media":323,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[996],"tags":[1246,1536],"class_list":["post-844","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-centos-5-5","tag-linux"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/844","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=844"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/844\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/323"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=844"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=844"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=844"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}