{"id":570,"date":"2019-10-03T00:43:53","date_gmt":"2019-10-03T00:43:53","guid":{"rendered":"https:\/\/server-help.org\/?p=570"},"modified":"2019-10-03T01:00:04","modified_gmt":"2019-10-03T01:00:04","slug":"configure-static-ip-for-centos-7","status":"publish","type":"post","link":"https:\/\/server-help.org\/index.php\/2019\/10\/03\/configure-static-ip-for-centos-7\/","title":{"rendered":"Configure Static IP for Centos 7"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><\/h2>\n\n\n\n<p>How to configure your default IP as static on Centos 7.<\/p>\n\n\n\n<p>You will need to SSH into the server, and change directory to \/etc\/sysconfig\/network-scripts\/<\/p>\n\n\n\n<p>You will need to edit the ifcfg-eth0 file. Keep in mind that your NIC device may have a different name. Check ifconfig before moving forward. Before editing make sure you make a backup of the original file. I typically create a new directory in network scripts call &#8220;off&#8221;. Then copy the original file to that directory. After that you can edit the file in network scripts. Example of a file is below.<\/p>\n\n\n\n<p>Example ifcfg-eth0 file\u2026<\/p>\n\n\n\n<p>TYPE=Ethernet<br> NAME=eth0<br> DEVICE=eth0<br> ONBOOT=yes<br> BOOTPROTO=static                     <strong>&lt;&lt;&lt; &#8220;Change this line from dhcp to static&#8221;<\/strong><br> IPADDR=&#8221;xxx.xxx.xxx.xxx&#8221;       <strong>&lt;&lt;&lt; &#8220;You will need to add this line with the default IP address of your server&#8221;<\/strong><br> NETMASK=&#8221;255.255.255.255&#8243;   <strong>&lt;&lt;&lt; &#8221; You will need to add this line&#8221;<\/strong> <br> DEFROUTE=yes<br> PEERDNS=yes<br> PEERROUTES=yes<br> IPV4_FAILURE_FATAL=no<br> LINKDELAY=30<br> NM_CONTROLLED=no<br> ONBOOT=yes<br> IPV6INIT=yes<br> NETWORKING_IPV6=yes<br> IPV6_AUTOCONF=yes<br> DHCPV6C=yes<br> DHCPV6C_OPTIONS=-nw<br> ONBOOT=yes<br> DHCP_HOSTNAME=AD47E10<\/p>\n\n\n\n<p><strong>**save and close the above.<\/strong><\/p>\n\n\n\n<p>Then you will need to create the below&#8230; <\/p>\n\n\n\n<p>vi \/etc\/sysconfig\/network-scripts\/route-eth0<br> 10.255.255.1 dev eth0<br> default via 10.255.255.1 dev eth0<\/p>\n\n\n\n<p><strong> **save and close the above.<\/strong> <\/p>\n\n\n\n<p>\/etc\/init.d\/network restart<\/p>\n\n\n\n<p>Note:<\/p>\n\n\n\n<p>please check with ifconfig -a command to see the Interface name, some times it could be eth0, eth0:1 or eth0, eth1, ens<\/p>\n\n\n\n<p>If both Interfaces eth0, and eth0:x then the route-eth0 is fair enough <br>\nIf the Interfaces are eth0 and eth1, then create 2 files (route-eth0 and route-eth1), and add the above commad with changing ethx regarding the file name. (eth0 goes with eth0, and eth1 goes with eth1)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to configure your default IP as static on Centos 7. You will need to SSH into the server, and change directory to \/etc\/sysconfig\/network-scripts\/ You will need to edit the ifcfg-eth0 file. Keep in mind that your NIC device may have a different name. Check ifconfig before moving forward. Before editing make sure you make&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,4,1],"tags":[],"_links":{"self":[{"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/posts\/570"}],"collection":[{"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/comments?post=570"}],"version-history":[{"count":9,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/posts\/570\/revisions"}],"predecessor-version":[{"id":579,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/posts\/570\/revisions\/579"}],"wp:attachment":[{"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/media?parent=570"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/categories?post=570"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/tags?post=570"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}