{"id":2021,"date":"2015-03-14T03:40:50","date_gmt":"2015-03-14T03:40:50","guid":{"rendered":"https:\/\/qbytes.cloud\/?p=2021"},"modified":"2015-03-14T03:40:50","modified_gmt":"2015-03-14T03:40:50","slug":"change-hostname-in-centos","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2015\/03\/14\/change-hostname-in-centos\/","title":{"rendered":"Change Hostname in CentOS"},"content":{"rendered":"<p>Open the \/etc\/sysconfig\/network file with your favorite text editor. Modify the HOSTNAME= value to match your FQDN host name.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# nano \/etc\/sysconfig\/network\nHOSTNAME=myserver.domain.com\n<\/pre>\n<p>Change the host that is associated to your main IP address for your server, this is for internal networking (found at \/etc\/hosts):<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nnano \/etc\/hosts\n192.xx.xx.xx myserver.domain.com\n<\/pre>\n<p>Hostname<\/p>\n<p>The &#8216;hostname&#8217; command will let you change the hostname on the server that the commandline remembers, but it will not actively update all programs that are running under the old hostname.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# hostname myserver.domain.com\n# hostname\nmyserver.domain.com\n<\/pre>\n<p>Restart Networking<\/p>\n<p>At this point all the necessary changes that needed to be made have been made, you will want to restart networking on your server to make sure that changes will be persistent on reboot:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\n# \/etc\/init.d\/network restart\n\n<\/pre>\n<p>* Hostname reports nothing<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# hostname\n\n<\/pre>\n<p>Try this<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\n$ stat \/bin\/hostname\nFile: `\/bin\/hostname&#039;\nSize: 0 Blocks: 0 IO Block: 4096 regular empty file\nDevice: 803h\/2051d Inode: 40616045 Links: 1\nAccess: (0755\/-rwxr-xr-x) Uid: ( 0\/ root) Gid: ( 0\/ root)\nAccess: 2015-03-13 05:10:01.000000000 -0700\nModify: 2014-12-15 15:33:57.000000000 -0700\nChange: 2014-12-15 15:33:57.000000000 -0700\n\n<\/pre>\n<p>Notice the &#8220;empty file&#8221;<br \/>\nReinstall the package &#8211;  the package it&#8217;s included in (net-tools-1.60-110.el6_2.x86_64).<\/p>\n<p>Now Check<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# stat \/bin\/hostname\n  File: `\/bin\/hostname&#039;\n  Size: 17848           Blocks: 40         IO Block: 4096   regular file\nDevice: fd00h\/64768d    Inode: 269246      Links: 1\nAccess: (0755\/-rwxr-xr-x)  Uid: (    0\/    root)   Gid: (    0\/    root)\nAccess: 2015-03-13 04:47:35.065993289 -0600\nModify: 2012-05-10 03:17:33.000000000 -0500\nChange: 2015-01-30 03:29:41.959201490 -0600\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Open the \/etc\/sysconfig\/network file with your favorite text editor. Modify the HOSTNAME= value to match your FQDN host name. # nano \/etc\/sysconfig\/network HOSTNAME=myserver.domain.com Change the host that is associated to your main IP address for your server, this is for internal networking (found at \/etc\/hosts): nano \/etc\/hosts 192.xx.xx.xx myserver.domain.com Hostname The &#8216;hostname&#8217; command will let &#8230; <a title=\"Change Hostname in CentOS\" class=\"read-more\" href=\"https:\/\/www.qbytes.cloud\/index.php\/2015\/03\/14\/change-hostname-in-centos\/\" aria-label=\"Read more about Change Hostname in CentOS\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,72],"tags":[],"class_list":["post-2021","post","type-post","status-publish","format-standard","hentry","category-centos6","category-networking"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/2021","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=2021"}],"version-history":[{"count":0,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/2021\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=2021"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=2021"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=2021"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}