Setting the Hostname (FQDN) in Linux Servers

Setting the Hostname (FQDN) in Linux Servers
by Janeth Kent 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 Janeth Kent Date: 29-05-2013 hostname fqdn linux server apache fedora ubuntu hits : 18368  
 
Janeth Kent

Janeth Kent

Licenciada en Bellas Artes y programadora por pasión. Cuando tengo un rato retoco fotos, edito vídeos y diseño cosas. El resto del tiempo escribo en MA-NO WEB DESIGN AND DEVELOPMENT.

 
 
 

Related Posts

How to set up your own free web server with XAMPP

Nowadays anyone can create their own website easily and free of charge. Whether through a CMS (such as WordPress) or by hand with HTML, CSS and JavaScript, in a few…

How To Use Varnish As A Highly Available Load Balancer On Ubuntu 20.04 With SSL

Load balancing with high availability can be tough to set up. Fortunately, Varnish HTTP Cache server provides a dead simple highly available load balancer that will also work as a…

htaccess Rules to Help Protect from SQL Injections and XSS

This list of rules by no means is a sure bet to secure your web services, but it will help in preventing script-kiddings from doing some basic browsing around. MySQL injection…

How to install a Linux partition on a Windows 10 PC

In spite of a past we could say almost confronted, the approach between Windows and Linux is accelerating more and more, drawing a story closer to love than to hate.…

Matrix. An open network for secure and decentralized communication that you can install in your Ubuntu server

Imagine to have an open platform that is as independent, vibrant and evolving as the Web itself, but for communication. As of June 2019, Matrix is out of beta, and the protocol…

WSL2 is released to run Linux distributions on Windows

If you are reading about this for the first time, the Windows Subsystem for Linux is a kind of virtual machine that allows you to run the Linux terminal on…

Linux For Dummies: Permissions

In the previous articles I made a short introduction to the Unix world and in the following article I have dealt with the basic commands for the file system management. Today we are…

Linux for Dummies: Ubuntu Terminal

I introduced in the previous article, available here, the basic concepts concerning the Linux world. Today we are going to have a look to some basic operations that we can perform…

Linux for Dummies: Introduction

If you have thought about migrating from Windows to a Unix operating system, or Linux specifically there are things you should know. The goal is to give essential information (and…

How to setup Free Let’s Encrypt SSL certificates with ISPConfig 3

Let’s Encrypt is an initiative to provide a better way of enabling encryption on websites. It is open, automated and above all: it offers free SSL certificates. Obtaining SSL certificates was always…

Must-Have htaccess Tips for you to Avoid Duplicate Content on Your Site

In order to be able to implement these tips it is necessary that your Apache server already has the mod_rewrite module activated. mod_rewrite and .htaccess are used together so that…

The Best RSS Readers for Ubuntu

Even if most of the tech experts actively claim that RSS (Rich Site Summary) is dead especially after Google Reader was discontinued 5 years ago but it isn’t yet as…

Clicky