Setting The Hostname (Fqdn) in Linux Servers

by admin admin Date: 29-05-2013 hostname fqdn linux server apache fedora ubuntu


Here we will show how to set your system's hostname and fully qualified domain name (FQDN). Your hostname should be something unique. Some people name their servers after planets, philosophers, or animals. Note that the system's hostname has no relationship to websites or email services hosted on it, aside from providing a name for the system itself. Your hostname should not be "www" or anything too generic.

CentOS / Fedora

Enter the following commands to set the hostname, replacing myservername with the hostname of your choice:

echo "HOSTNAME=myservername" >> /etc/sysconfig/network
hostname "myservername"

Slackware

Enter the following commands to set the hostname, replacing myservername with the hostname of your choice:

echo "myservername" > /etc/HOSTNAME
hostname -F /etc/HOSTNAME

Gentoo

Enter the following commands to set the hostname, replacing myservername with the hostname of your choice:

echo "HOSTNAME=\"myservername\"" > /etc/conf.d/hostname
/etc/init.d/hostname restart

Arch Linux

Edit your /etc/rc.conf to configure the hostname for your system. Be sure to replace myservername with the hostname of your choice:

File excerpt:/etc/rc.conf

HOSTNAME="myservername"
  

Issue the following command to set the hostname, replacing myservername with the hostname of your choice:

hostname myservername

Update /etc/hosts

Next, edit your /etc/hosts file to resemble the following example, replacing myservername with your chosen hostname, example.com with your system's domain name, and 12.34.56.78 with your system's IP address. As with the hostname, the domain name part of your FQDN does not necesarily need to have any relationship to websites or other services hosted on the server (although it may if you wish). As an example, you might host "www.something.com" on your server, but the system's FQDN might be "mars.somethingelse.com."

File:/etc/hosts

127.0.0.1        localhost.localdomain    localhost
12.34.56.78      myservername.example.com        myservername
  

If you have IPv6 enabled on your Linode, you will also want to add an entry for your IPv6 address, as shown in this example:

File:/etc/hosts

127.0.0.1                       localhost.localdomain    localhost
12.34.56.78                     myservername.example.com        myservername
2600:3c01::a123:b456:c789:d012  myservername.example.com        myservername
  

The value you assign as your system's FQDN should have an "A" record in DNS pointing to your Linode's IPv4 address. For Linodes with IPv6 enabled, you should also set up a "AAAA" record in DNS pointing to your Linode's IPv6 address.

 
by admin admin Date: 29-05-2013 hostname fqdn linux server apache fedora ubuntu hits : 7071  
 
 
 
 

Related Posts