{"id":1308,"date":"2017-02-08T03:50:19","date_gmt":"2017-02-08T01:50:19","guid":{"rendered":"http:\/\/www.shukko.com\/x3\/?p=1308"},"modified":"2017-02-08T03:51:44","modified_gmt":"2017-02-08T01:51:44","slug":"how-to-configure-a-static-ip-address-on-centos-7","status":"publish","type":"post","link":"https:\/\/www.shukko.com\/x3\/2017\/02\/08\/how-to-configure-a-static-ip-address-on-centos-7\/","title":{"rendered":"How to configure a static IP address on CentOS 7"},"content":{"rendered":"<p>Gecen gun gene lazim oldu.<br \/>\nalisamadim su centos7 olayina.<br \/>\nalismak lazim.<br \/>\nlazim olursa diye ekleyelim<br \/>\nHow to configure a static IP address on CentOS 7<br \/>\norjinal link:<br \/>\nhxxp:\/\/ask.xmodulo.com\/configure-static-ip-address-centos7.html<\/p>\n<div class=\"question\"><b>Question:<\/b> On CentOS 7, I want to switch from DHCP to static IP address configuration with one of my network interfaces. What is a proper way to assign a static IP address to a network interface permanently on CentOS or RHEL 7?<\/div>\n<p>If you want to set up a static IP address on a network interface in CentOS 7, there are several different ways to do it, varying depending on whether or not you want to use Network Manager for that.<\/p>\n<p>Network Manager is a dynamic network control and configuration system that attempts to keep network devices and connections up and active when they are available). CentOS\/RHEL 7 comes with Network Manager service installed and enabled by default.<\/p>\n<p>To verify the status of Network Manager service:<\/p>\n<div class=\"console\">$ systemctl status NetworkManager.service<\/div>\n<p>To check which network interface is managed by Network Manager, run:<\/p>\n<div class=\"console\">$ nmcli dev status<\/div>\n<div class=\"console\"><a href=\"https:\/\/www.shukko.com\/x3\/wp-content\/uploads\/15295802711_a102a3574d_z.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1309\" src=\"https:\/\/www.shukko.com\/x3\/wp-content\/uploads\/15295802711_a102a3574d_z.jpg\" alt=\"\" width=\"640\" height=\"244\" srcset=\"https:\/\/www.shukko.com\/x3\/wp-content\/uploads\/15295802711_a102a3574d_z.jpg 640w, https:\/\/www.shukko.com\/x3\/wp-content\/uploads\/15295802711_a102a3574d_z-300x114.jpg 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/div>\n<div class=\"console\">\n<p>If the output of nmcli shows &#8220;connected&#8221; for a particular interface (e.g., enp0s3 in the example), it means that the interface is managed by Network Manager. You can easily disable Network Manager for a particular interface, so that you can configure it on your own for a static IP address.<\/p>\n<p>Here are two different ways to assign a static IP address to a network interface on CentOS 7. We will be configuring a network interface named enp0s3.<\/p>\n<p>Configure a Static IP Address without Network Manager<br \/>\nGo to the \/etc\/sysconfig\/network-scripts directory, and locate its configuration file (ifcfg-enp0s3). Create it if not found.<br \/>\n<a href=\"https:\/\/www.shukko.com\/x3\/wp-content\/uploads\/15112399977_d3df8e15f5_z.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1310\" src=\"https:\/\/www.shukko.com\/x3\/wp-content\/uploads\/15112399977_d3df8e15f5_z.jpg\" alt=\"\" width=\"605\" height=\"210\" srcset=\"https:\/\/www.shukko.com\/x3\/wp-content\/uploads\/15112399977_d3df8e15f5_z.jpg 605w, https:\/\/www.shukko.com\/x3\/wp-content\/uploads\/15112399977_d3df8e15f5_z-300x104.jpg 300w\" sizes=\"auto, (max-width: 605px) 100vw, 605px\" \/><\/a><\/p>\n<\/div>\n<div class=\"console\">Open the configuration file and edit the following variables:<\/div>\n<div class=\"console\"><a href=\"https:\/\/www.shukko.com\/x3\/wp-content\/uploads\/15112184199_f4cbf269a6.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1311\" src=\"https:\/\/www.shukko.com\/x3\/wp-content\/uploads\/15112184199_f4cbf269a6.jpg\" alt=\"\" width=\"416\" height=\"321\" srcset=\"https:\/\/www.shukko.com\/x3\/wp-content\/uploads\/15112184199_f4cbf269a6.jpg 416w, https:\/\/www.shukko.com\/x3\/wp-content\/uploads\/15112184199_f4cbf269a6-300x231.jpg 300w\" sizes=\"auto, (max-width: 416px) 100vw, 416px\" \/><\/a><\/div>\n<div class=\"console\">\n<p>In the above, &#8220;NM_CONTROLLED=no&#8221; indicates that this interface will be set up using this configuration file, instead of being managed by Network Manager service. &#8220;ONBOOT=yes&#8221; tells the system to bring up the interface during boot.<\/p>\n<p>Save changes and restart the network service using the following command:<\/p>\n<p># systemctl restart network.service<br \/>\nNow verify that the interface has been properly configured:<\/p>\n<p># ip add<\/p>\n<\/div>\n<div class=\"console\"><a href=\"https:\/\/www.shukko.com\/x3\/wp-content\/uploads\/15112397947_ac69a33fb4_z.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1312\" src=\"https:\/\/www.shukko.com\/x3\/wp-content\/uploads\/15112397947_ac69a33fb4_z.jpg\" alt=\"\" width=\"640\" height=\"259\" srcset=\"https:\/\/www.shukko.com\/x3\/wp-content\/uploads\/15112397947_ac69a33fb4_z.jpg 640w, https:\/\/www.shukko.com\/x3\/wp-content\/uploads\/15112397947_ac69a33fb4_z-300x121.jpg 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/div>\n<div class=\"console\">\n<h2>Configure a Static IP Address with Network Manager<\/h2>\n<p>If you want to use Network Manager to manage the interface, you can use <tt>nmtui<\/tt> (Network Manager Text User Interface) which provides a way to configure Network Manager in a terminal environment.<\/p>\n<p>Before using <tt>nmtui<\/tt>, first set &#8220;NM_CONTROLLED=yes&#8221; in \/etc\/sysconfig\/network-scripts\/ifcfg-enp0s3.<\/p>\n<p>Now let&#8217;s install <tt>nmtui<\/tt> as follows.<\/p>\n<div class=\"console\"># yum install NetworkManager-tui<\/div>\n<p>Then go ahead and edit the Network Manager configuration of <tt>enp0s3<\/tt> interface:<\/p>\n<div class=\"console\"># nmtui edit enp0s3<\/div>\n<p>The following screen will allow us to manually enter the same information that is contained in \/etc\/sysconfig\/network-scripts\/ifcfg-enp0s3.<\/p>\n<p>Use the arrow keys to navigate this screen, press Enter to select from a list of values (or fill in the desired values), and finally click OK at the bottom right:<\/p>\n<p><a href=\"https:\/\/www.shukko.com\/x3\/wp-content\/uploads\/15295804521_4165c97828_z.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1313\" src=\"https:\/\/www.shukko.com\/x3\/wp-content\/uploads\/15295804521_4165c97828_z.jpg\" alt=\"\" width=\"616\" height=\"452\" srcset=\"https:\/\/www.shukko.com\/x3\/wp-content\/uploads\/15295804521_4165c97828_z.jpg 616w, https:\/\/www.shukko.com\/x3\/wp-content\/uploads\/15295804521_4165c97828_z-300x220.jpg 300w\" sizes=\"auto, (max-width: 616px) 100vw, 616px\" \/><\/a><\/p>\n<p>Finally, restart the network service.<\/p>\n<p># systemctl restart network.service<br \/>\nand you&#8217;re ready to go.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Gecen gun gene lazim oldu. alisamadim su centos7 olayina. alismak lazim. lazim olursa diye ekleyelim How to configure a static IP address on CentOS 7 orjinal link: hxxp:\/\/ask.xmodulo.com\/configure-static-ip-address-centos7.html Question: On CentOS 7, I want to switch from DHCP to static IP address configuration with one of my network interfaces. What is a proper way to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1308","post","type-post","status-publish","format-standard","hentry","category-kategerisiz"],"_links":{"self":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts\/1308","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/comments?post=1308"}],"version-history":[{"count":3,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts\/1308\/revisions"}],"predecessor-version":[{"id":1316,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts\/1308\/revisions\/1316"}],"wp:attachment":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/media?parent=1308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/categories?post=1308"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/tags?post=1308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}