Thursday, 23 May 2013

Setting Hostname on a RHEL CentOS Fedora

Setting Hostname on a RHEL/ CentOS/ Fedora System

Recently I ran into this issue of setting up a Fully Qualified Domain Name (F.Q.D.N) on a RHEL Server. Did a bit of Googling and found a lot many good ways to set a F.Q.D.N, so thought of sharing the same with you.

The following steps should work on Red Hat, CentOS and Fedora based Linux flavors.

Here, I needed to set this particular RHEL server's F.Q.D.N as ""

The first thing to do is create a new file called "hostname" in the /etc/ directory as shown below. You can use any editor to edit the file. Write the system's F.Q.D.N in this file and save it.

Next, run the following command to set the new hostname forcefully:
# hostname -F /etc/hostname

The final thing to do is edit the file /etc/sysconfig/network and add/ update the parameter HOSTNAME according to your needs. Save the file once you have set the new hostname.

In some cases, you may need to restart your Network for the changes to take effect. You can do that by executing the following commands:
# service network stop
# service network start

You should have your F.Q.D.N set now. You can verify it by executing the following command:
# hostname --fqdn

No comments :

Post a Comment

Note: only a member of this blog may post a comment.