What is the hostname format?

Hi @davidep

Did you decide what should be the content of /etc/hostname ?

The server name or its FQDN ?

Michel-André

FQDN like for NS7

how can you reach a server without the domain part

https://github.com/search?q=org%3ANethServer%20%2Fetc%2Fhostname&type=code

Salut Stéphane,

In the installation file: ns8-core/ns8-stable/core/install.sh
for the hostame, why is it using hostname -f ?

...
# You should have received a copy of the GNU General Public License
# along with NethServer.  If not, see COPYING.
#

set -e

echo "Checking machine hostname"
fqdn=$(hostname -f)  <===========================
...

And, at the end of the installation, it always display the right link to access cluster-admin even if you only use the server name (as you should) in /etc/hostname.

But if you do as it should be done and have only the server name in /etc/hostname, the link for the cluster-admin, at the end of the installation, will still be the right one but the links of alls the instances will only be the server name which is wrong.

I repeat myself but the man page of Debian-11 and 12 says I am right:

...
 THE FQDN
       The  FQDN  (Fully  Qualified  Domain  Name) of the system is the name that the re‐
       solver(3) returns for the host name, such as, ursula.example.com.  It  is  usually
       the  hostname followed by the DNS domain name (the part after the first dot).  You
       can check the FQDN using hostname --fqdn or the domain name using dnsdomainname.

       You cannot change the FQDN with hostname or dnsdomainname.

       The recommended method of setting the FQDN is to make the hostname be an alias for
       the  fully qualified name using /etc/hosts, DNS, or NIS. For example, if the host‐
       name was "ursula", one might have a line in /etc/hosts which reads

              127.0.1.1    ursula.example.com ursula

       Technically: The FQDN is the name getaddrinfo(3) returns for  the  host  name  re‐
       turned by gethostname(2).  The DNS domain name is the part after the first dot.
...

According to the man page, /etc/hostname should contain only ursula (which is the server name or an alias of the FQDN in /etc/hosts) and nothing else.

And of course, only if you have the correct entry in /etc/hosts.

Why are you not using hostname -f as in the installation file ???
If not, one day it will come back and bite you :upside_down_face:

Michel-André

EDIT:
As the installation of NS8 is done only on a fresh installation of the OS, the result of hostname -f should be store somewhere for later use as most of the time the server will have other domains later on and hostname -f might give more than only one FQDN.
The man page gives a warning about it

If  a machine has multiple network interfaces/addresses or is used in a mobile en‐
       vironment, then it may either have multiple FQDNs/domain names  or  none  at  all.
       Therefore avoid using hostname --fqdn, hostname --domain and dnsdomainname.  host‐
       name --ip-address is subject to the same limitations so it should  be  avoided  as
       well.

I am not a programmer but the best way might be as in the man page:

Technically: The FQDN is the name getaddrinfo(3) returns for  the  host  name  re‐
       turned by gethostname(2).  The DNS domain name is the part after the first dot.

Usually it contains the fully qualified domain name. From man hostname

/etc/hostname Historically this file was supposed to only contain the hostname and not the
full canonical FQDN. Nowadays most software is able to cope with a
full FQDN here. This file is read at boot time by the system initialization scripts to set the hostname.

It depends on the application implementations.

We already do it in many app. If some app is missing, we can fix it.
Still is up to the user to correctly setup the names. Also, if an app does too many assumptions, we can try to expose the name parameters directly into the UI.

2 Likes

Hi @giacomo

Thank you for your reply.

For sure SFTPgo does not use hostname -f

Just only put the server name in /etc/hostname, install NS8 and NGINX then have a look at the link.

Michel-André

2 Likes

Since the Beta 2 milestone the Debian approach to hostname setup was adopted. Hopefully this will be the definitive one!

In other words, the host name is set as a single word, like ursula and the FQDN is added to a /etc/hosts record, like the manual says:

127.0.1.1    ursula.example.com ursula

This setup is verified and fixed as necessary by the cluster-admin UI, and documented here: Installation — NS8 documentation. No more manual commands are required!

1 Like