How to set the domain name on GNU/Linux?
Set FQDN
I'm using Debian 7 and this is what worked for me; thanks to Fernando Ribeiro.
sudoedit /etc/hostname
server # here's where you put the server's host name
activate hostname
sudo hostname -F /etc/hostname
add domain name and address to the server
sudoedit /etc/hosts
192.168.1.2 server.domain server
VERIFY
> hostname --short
server
> hostname --domain
domain
> hostname --fqdn
server.domain
> hostname --ip-address
192.168.1.2
When you use redhat-base
systems, linux uses /etc/sysconfig/network
file and you should set variable HOSTNAME
to FQDN
, when you use FQDN
, linux
itself determines domain name.
For example:
HOSTNAME=web.mydomain.com
But when you use debian-base
systems, you should fill /etc/hostname
file with FQDN
:
web.mydomain.com
NOTE: if you want to set domain name
be sure set FQDN
(Fully Qualyfied Domain Name)
When you set, hostname -d
shows you the domain name
.