Hi, For the last ten years or so, I've defined the short hostname in /etc/hostname and the FQDN in /etc/hosts. Now I wanted to double-check this information, which eventually led me to this page: * https://serverfault.com/questions/331936/setting-the-hostname-fqdn-or-short-name Now I admit I'm even more confused than before. Is there some reliable piece of information on this subject for CentOS ? Cheers, Niki -- Microlinux - Solutions informatiques durables 7, place de l'?glise - 30730 Montpezat Site : https://www.microlinux.fr Mail : info at microlinux.fr T?l. : 04 66 63 10 32 Mob. : 06 51 80 12 12
How I do it ( and always done it): hostnamectl set-hostname foobar.localdomain echo 127.0.0.1 foobar.localdomain foobar >> /etc/hosts echo ::1 foobar.localdomain foobar >> /etc/hosts -- Sent from the Delta quadrant using Borg technology! Nux! www.nux.ro ----- Original Message -----> From: "Nicolas Kovacs" <info at microlinux.fr> > To: "CentOS mailing list" <centos at centos.org> > Sent: Wednesday, 10 April, 2019 08:21:11 > Subject: [CentOS] Short or long hostname ?> Hi, > > For the last ten years or so, I've defined the short hostname in > /etc/hostname and the FQDN in /etc/hosts. Now I wanted to double-check > this information, which eventually led me to this page: > > * > https://serverfault.com/questions/331936/setting-the-hostname-fqdn-or-short-name > > Now I admit I'm even more confused than before. > > Is there some reliable piece of information on this subject for CentOS ? > > Cheers, > > Niki > -- > Microlinux - Solutions informatiques durables > 7, place de l'?glise - 30730 Montpezat > Site : https://www.microlinux.fr > Mail : info at microlinux.fr > T?l. : 04 66 63 10 32 > Mob. : 06 51 80 12 12 > _______________________________________________ > CentOS mailing list > CentOS at centos.org > https://lists.centos.org/mailman/listinfo/centos
> Hi, > > For the last ten years or so, I've defined the short hostname in > /etc/hostname and the FQDN in /etc/hosts. Now I wanted to double-check > this information, which eventually led me to this page: > > * > https://serverfault.com/questions/331936/setting-the-hostname-fqdn-or-short-name > > Now I admit I'm even more confused than before. > > Is there some reliable piece of information on this subject for CentOS ?IMHO for those having proper DNS in place, the hostname should be set to the FQDN in whatever place it is supposed to be set. I quite feel there is something wrong if the only place where the FQDN is listed is the /etc/hosts file. I'm not very happy with how the issue was handled in Linux and the different distributions in the last decades. Not to mention the inconsistency in the relevant man pages. I found the info mentioned in the FreeBSD man pages quite helpful even if it has to be "translated" to Linux. See the excerpt of the mentioned man pages below. If you believe this is heresy to be posted here, please don't read it :-) Regards, Simon ----%>------------------------------- root at freebsd:~ # man hostname HOSTNAME(1) FreeBSD General Commands Manual HOSTNAME(1) NAME hostname - set or print name of current host system SYNOPSIS hostname [-f] [-s | -d] [name-of-host] DESCRIPTION The hostname utility prints the name of the current host. The super-user can set the hostname by supplying an argument; this is usually done in the initialization script /etc/rc.d/hostname, normally run at boot time. This script uses the hostname variable in /etc/rc.conf. ... root at freebsd:~ # man rc.conf RC.CONF(5) FreeBSD File Formats Manual RC.CONF(5) NAME rc.conf - system configuration information DESCRIPTION The file rc.conf contains descriptive information about the local host ... hostname (str) The fully qualified domain name (FQDN) of this host on the network. This should almost certainly be set to something meaningful, even if there is no network connection. If dhclient(8) is used to set the hostname via DHCP, this variable should be set to an empty string. Within a jail(8) the hostname is generally already set and this variable may absent. If this value remains unset when the system is done booting your console login will display the default hostname of "Amnesiac".
On 4/10/19 8:23 AM, Simon Matter via CentOS wrote:>> Hi, >> >> For the last ten years or so, I've defined the short hostname in >> /etc/hostname and the FQDN in /etc/hosts. Now I wanted to double-check >> this information, which eventually led me to this page: >> >> * >> https://serverfault.com/questions/331936/setting-the-hostname-fqdn-or-short-name >> >> Now I admit I'm even more confused than before. >> >> Is there some reliable piece of information on this subject for CentOS ? > > IMHO for those having proper DNS in place, the hostname should be set to > the FQDN in whatever place it is supposed to be set. I quite feel there is > something wrong if the only place where the FQDN is listed is the > /etc/hosts file. > > I'm not very happy with how the issue was handled in Linux and the > different distributions in the last decades. Not to mention the > inconsistency in the relevant man pages.Well, I am unhappy for about as long about /etc/hosts and how name resolution "should" happen which it doesn't, namely, if /etc/nsswitch.conf says hosts: files dns then ideally /etc/hosts should be used first, then nameservers. However (and this is true both for Linux and FreeBSD), some commands never look into /etc/hosts (e.g., command host), whereas some do use /etc/hosts (e.g., command ping). Valeri> > I found the info mentioned in the FreeBSD man pages quite helpful even if > it has to be "translated" to Linux. See the excerpt of the mentioned man > pages below. If you believe this is heresy to be posted here, please don't > read it :-) > > Regards, > Simon > > ----%>------------------------------- > root at freebsd:~ # man hostname > HOSTNAME(1) FreeBSD General Commands Manual > HOSTNAME(1) > > NAME > hostname - set or print name of current host system > > SYNOPSIS > hostname [-f] [-s | -d] [name-of-host] > > DESCRIPTION > The hostname utility prints the name of the current host. The > super-user > can set the hostname by supplying an argument; this is usually done in > the initialization script /etc/rc.d/hostname, normally run at boot time. > This script uses the hostname variable in /etc/rc.conf. > ... > > > root at freebsd:~ # man rc.conf > RC.CONF(5) FreeBSD File Formats Manual > RC.CONF(5) > > NAME > rc.conf - system configuration information > > DESCRIPTION > The file rc.conf contains descriptive information about the local host > ... > hostname (str) The fully qualified domain name (FQDN) of this host on > the network. This should almost certainly be set to > something meaningful, even if there is no network connection. > If dhclient(8) is used to set the hostname via DHCP, this > variable should be set to an empty string. Within a jail(8) > the hostname is generally already set and this variable may > absent. If this value remains unset when the system is done > booting your console login will display the default hostname > of "Amnesiac". > > _______________________________________________ > CentOS mailing list > CentOS at centos.org > https://lists.centos.org/mailman/listinfo/centos >-- ++++++++++++++++++++++++++++++++++++++++ Valeri Galtsev Sr System Administrator Department of Astronomy and Astrophysics Kavli Institute for Cosmological Physics University of Chicago Phone: 773-702-4247 ++++++++++++++++++++++++++++++++++++++++
On Apr 10, 2019, at 09:23, Simon Matter via CentOS <centos at centos.org> wrote:> IMHO for those having proper DNS in place, the hostname should be set to > the FQDN in whatever place it is supposed to be set. I quite feel there is > something wrong if the only place where the FQDN is listed is the > /etc/hosts file.If you ever plan on using Kerberos, you want the host name to use FQDN, otherwise some krb5 stuff can break. ? Jonathan Billings <billings at negate.org>