{"id":1592,"date":"2013-10-17T22:14:11","date_gmt":"2013-10-18T02:14:11","guid":{"rendered":"http:\/\/www.eyoungwon.com\/journal\/?p=1592"},"modified":"2024-07-15T22:29:36","modified_gmt":"2024-07-16T02:29:36","slug":"configure-static-ip-address-in-centos","status":"publish","type":"post","link":"https:\/\/eyoungwon.com\/journal\/configure-static-ip-address-in-centos\/","title":{"rendered":"Configure Static IP Address in CentOS"},"content":{"rendered":"<p>After installing CentOS you will wan\u2019t to most likely configure a static ip address.\u00a0<a title=\"CentOS.org\" href=\"http:\/\/www.centos.org\/\" target=\"_blank\" rel=\"noopener\">CentOS<\/a> is mostly used as Server for some purpose be it hosting your website or running a gaming server.\u00a0 So whatever the case you will want to give it a static IP address.\u00a0 By default CentOS interface is configured to receive IP from DHCP server if this is turned on. Here I will show you how to configure static IP address in CentOS system.<\/p>\n<p>1. You will need to edit the file for your Ethernet connection under <strong>\/etc\/sysconfig\/network-scripts<\/strong>.\u00a0 We will edit this file and add the correct settings. \u00a0 You will need to use an editor like <strong>vi<\/strong>, <strong>vim<\/strong>, <strong>nano, pico<\/strong> etc.\u00a0 In this example I will use <strong>nano<\/strong> editor. After you start your server running <strong>CentOS<\/strong> enter root user credentials and get in. Type the command, <strong># nano \/etc\/sysconfig\/network-scripts\/ifcfg-eth0<\/strong> it will look something like this <strong><br \/>\n<\/strong><\/p>\n<p><img decoding=\"async\" class=\"alignleft size-full wp-image-1594\" title=\"editing the eth0  - either settings\" alt=\"Screen Shot 2013-10-17 at 9.48.51 PM\" src=\"http:\/\/www.eyoungwon.com\/journal\/wp-content\/uploads\/2013\/10\/Screen-Shot-2013-10-17-at-9.48.51-PM.png\" width=\"533\" height=\"47\" srcset=\"https:\/\/eyoungwon.com\/journal\/wp-content\/uploads\/2013\/10\/Screen-Shot-2013-10-17-at-9.48.51-PM.png 533w, https:\/\/eyoungwon.com\/journal\/wp-content\/uploads\/2013\/10\/Screen-Shot-2013-10-17-at-9.48.51-PM-300x26.png 300w\" sizes=\"(max-width: 533px) 100vw, 533px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>2. The settings may look like this<\/p>\n<figure id=\"attachment_1595\" aria-describedby=\"caption-attachment-1595\" style=\"width: 416px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/www.eyoungwon.com\/journal\/wp-content\/uploads\/2013\/10\/etho-settings.png\"><img fetchpriority=\"high\" decoding=\"async\" class=\"size-full wp-image-1595\" alt=\"settings you  may see\" src=\"http:\/\/www.eyoungwon.com\/journal\/wp-content\/uploads\/2013\/10\/etho-settings.png\" width=\"416\" height=\"223\" srcset=\"https:\/\/eyoungwon.com\/journal\/wp-content\/uploads\/2013\/10\/etho-settings.png 416w, https:\/\/eyoungwon.com\/journal\/wp-content\/uploads\/2013\/10\/etho-settings-300x160.png 300w\" sizes=\"(max-width: 416px) 100vw, 416px\" \/><\/a><figcaption id=\"caption-attachment-1595\" class=\"wp-caption-text\">settings you may see<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>3. Now change the configurations to something like this<\/p>\n<figure id=\"attachment_1596\" aria-describedby=\"caption-attachment-1596\" style=\"width: 394px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/www.eyoungwon.com\/journal\/wp-content\/uploads\/2013\/10\/eth0new.png\"><img decoding=\"async\" class=\"size-full wp-image-1596\" alt=\"New settings\" src=\"http:\/\/www.eyoungwon.com\/journal\/wp-content\/uploads\/2013\/10\/eth0new.png\" width=\"394\" height=\"250\" srcset=\"https:\/\/eyoungwon.com\/journal\/wp-content\/uploads\/2013\/10\/eth0new.png 394w, https:\/\/eyoungwon.com\/journal\/wp-content\/uploads\/2013\/10\/eth0new-300x190.png 300w\" sizes=\"(max-width: 394px) 100vw, 394px\" \/><\/a><figcaption id=\"caption-attachment-1596\" class=\"wp-caption-text\">New settings<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>4. Save the file in whichever editor your using.<\/p>\n<p>5. Now restart the network services by issuing the command,<br \/>\n<i><b>[root@hostname~]# service network restart<\/b><\/i><\/p>\n<p>6. To verify the IP address issue the following command,<br \/>\n<strong><i><b>[root@hostname~]# ifconfig<\/b><\/i><\/strong><\/p>\n<p><a href=\"http:\/\/www.eyoungwon.com\/journal\/wp-content\/uploads\/2013\/10\/Screen-Shot-2013-10-17-at-10.02.16-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-1597\" alt=\"Screen Shot 2013-10-17 at 10.02.16 PM\" src=\"http:\/\/www.eyoungwon.com\/journal\/wp-content\/uploads\/2013\/10\/Screen-Shot-2013-10-17-at-10.02.16-PM.png\" width=\"559\" height=\"354\" srcset=\"https:\/\/eyoungwon.com\/journal\/wp-content\/uploads\/2013\/10\/Screen-Shot-2013-10-17-at-10.02.16-PM.png 559w, https:\/\/eyoungwon.com\/journal\/wp-content\/uploads\/2013\/10\/Screen-Shot-2013-10-17-at-10.02.16-PM-300x189.png 300w\" sizes=\"(max-width: 559px) 100vw, 559px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>7.\u00a0 Next you will want to configure your DNS settings we&#8217;ll need to edit the DNS file so we type the command\u00a0 thing is to edit <strong>\/etc\/recolv.conf<\/strong>.\u00a0 Using nano editor to configure DNS information, <strong>\/etc\/recolv.conf<\/strong>.\u00a0 Using nano editor to configure DNS information,<br \/>\n<strong><i>[root@hostname~]<\/i># nano \/etc\/resolv.conf<\/strong><\/p>\n<p>8.\u00a0 After you save this file, you&#8217;ll want to test your connection with a simple command like ping www.bbc.co.uk which should come back with something like this below.<\/p>\n<figure id=\"attachment_1598\" aria-describedby=\"caption-attachment-1598\" style=\"width: 707px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/www.eyoungwon.com\/journal\/wp-content\/uploads\/2013\/10\/Screen-Shot-2013-10-17-at-10.11.32-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1598\" alt=\"ping any know website \" src=\"http:\/\/www.eyoungwon.com\/journal\/wp-content\/uploads\/2013\/10\/Screen-Shot-2013-10-17-at-10.11.32-PM.png\" width=\"707\" height=\"196\" srcset=\"https:\/\/eyoungwon.com\/journal\/wp-content\/uploads\/2013\/10\/Screen-Shot-2013-10-17-at-10.11.32-PM.png 707w, https:\/\/eyoungwon.com\/journal\/wp-content\/uploads\/2013\/10\/Screen-Shot-2013-10-17-at-10.11.32-PM-300x83.png 300w\" sizes=\"(max-width: 707px) 100vw, 707px\" \/><\/a><figcaption id=\"caption-attachment-1598\" class=\"wp-caption-text\">ping any know website<\/figcaption><\/figure>\n<p>You should be all setup and ready.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Configure Static IP Address in CentOS<\/p>\n","protected":false},"author":62,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[114,44,282],"tags":[753],"class_list":["post-1592","post","type-post","status-publish","format-standard","hentry","category-linuxunix","category-servers","category-technology","tag-configure-static-ip-address-in-centos"],"_links":{"self":[{"href":"https:\/\/eyoungwon.com\/journal\/wp-json\/wp\/v2\/posts\/1592","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eyoungwon.com\/journal\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eyoungwon.com\/journal\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eyoungwon.com\/journal\/wp-json\/wp\/v2\/users\/62"}],"replies":[{"embeddable":true,"href":"https:\/\/eyoungwon.com\/journal\/wp-json\/wp\/v2\/comments?post=1592"}],"version-history":[{"count":5,"href":"https:\/\/eyoungwon.com\/journal\/wp-json\/wp\/v2\/posts\/1592\/revisions"}],"predecessor-version":[{"id":1703,"href":"https:\/\/eyoungwon.com\/journal\/wp-json\/wp\/v2\/posts\/1592\/revisions\/1703"}],"wp:attachment":[{"href":"https:\/\/eyoungwon.com\/journal\/wp-json\/wp\/v2\/media?parent=1592"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eyoungwon.com\/journal\/wp-json\/wp\/v2\/categories?post=1592"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eyoungwon.com\/journal\/wp-json\/wp\/v2\/tags?post=1592"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}