# Hostname on FreeBSD installation



## badbrain (Aug 4, 2019)

Unlike any previous time I just hit enter when the installer ask for hostname since I'm install it on a VirtualBox VM. This time I decided to give a hostname, blackdog. The installation goes smoothly but after boot up it said "Unqualified hostname" and refused to boot. This made me confused. On other BSDs I usually set hostname to blackdog and domain name to bsd.local and it just fine. Does FreeBSD expect hostname to be domain name on other BSDs? I think they're clearly different thing.


----------



## badbrain (Aug 4, 2019)

It seemed it really expect hostname to be domain name on other bsd. I reinstall it with hostname set to blackdog.dom and it boot up happily. Isn't it somewhat strange?


----------



## getopt (Aug 4, 2019)

blackdog said:


> Isn't it somewhat strange?


So a *fully qualified domain name* (*FQDN*) is expected.
See rc.conf(5) :


> _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.


----------



## PMc (Aug 4, 2019)

blackdog said:


> It seemed it really expect hostname to be domain name on other bsd.



No it doesn't. Puuhh...

For many years I was telling people that the hostname and a domain name are two entirely different things (mostly to no avail).
And yes, the hostname traditionally did not have a domain extension. It's a bit strange that FreeBSD requires such. Probably people have just given up to explain the difference, like me.

But even as FreeBSD seems to require the hostname to have a domain extension, this is NOT a domain name in regard to networking! It is still a fully independent name that only suits as a label for the machine or the OS instance (even if it would not have any networking attached). Whereas the usual domain names are labels for a network address (and there can be none or many on a certain machine).


----------



## Phishfry (Aug 5, 2019)

Great topic. I do not use FQDN for my hostnames.
x9srl
x10sri
E6420
These are a short sample. I use motherboard/computer model as hostname. No Extention used ever.
The domain extension always confused me for a computer (host)name.


----------



## SirDice (Aug 5, 2019)

blackdog said:


> I reinstall it with hostname


You really don't need to _reinstall_ to change the hostname, just edit /etc/rc.conf and edit `hostname="<something>"`. That's all that needs to be done.


----------



## badbrain (Aug 5, 2019)

SirDice said:


> You really don't need to _reinstall_ to change the hostname, just edit /etc/rc.conf and edit `hostname="<something>"`. That's all that needs to be done.


If it ever allow me to log in  It said I've an "Unqualified hostname" and refused to boot. If having to choose between messing with single user mode, import zpool, mount,... and a clean reinstall I would choose the later


----------



## moridin (Aug 6, 2019)

The warning comes from sendmail as it wants FQDN and the one that can be resolved.  However, it doesn't actually refuse to boot, saying it's "sleeping", and simply pressing Ctrl+C would allow the startup to continue, and then you can disable it (sendmail) completely in rc.conf.


----------



## gpw928 (Aug 6, 2019)

blackdog said:


> This made me confused.


You're not alone.  To preserve my sanity (as opposed to my purity) in dealing with unadorned host names (UHN) and fully qualified domain names (FQDN) I have a few simple rules:

FreeBSD hosts get "hostname=FQDN" in /etc/rc.conf.  Don't fight it...
Debian (derived) hosts get an unadorned host name (UHN) in /etc/hostname.
Other Linux hosts generally get a FQDN in /etc/hostname.
Any entries added to /etc/hosts always have "IP FQDN UHN [alias ...]" meaning that the canonical name is the FQDN.
The internal DNS resolver is configured to resolve UHN to FQDN (at home, it's actually dnsmasq on the firewall configured to resolve from the local /etc/hosts file first).
Debian systems will install with "127.0.1.1 FQDN UHN in /etc/hosts" which gets commented out after 5 above (mainly to eliminate surprise for the uninitiated).
Cheers,


----------



## Phishfry (Aug 6, 2019)

gpw928 said:


> FreeBSD hosts get "hostname=FQDN" in /etc/rc.conf. Don't fight it...


I don't know where this is coming from. This is all I use:
/etc/rc.conf
sendmail_enable="NONE"
hostname="E6420"


----------



## SirDice (Aug 6, 2019)

You've completely disabled sendmail(8) which, to the best of my knowledge, is the only service that requires an actual FQDN for the hostname. It doesn't need to exist (as long as it resolves locally) but it does require a hostname with at least one dot in it.


----------



## getopt (Aug 6, 2019)

This is great entertainment. I really enjoy.

We already have the option in /etc/src.conf for not getting seduced to read the documentation.

```
WITHOUT_MAN
```

But there really should be a knob in /etc/rc.conf for those wanting more fun:

```
stop_parsing=YES
```


----------



## olli@ (Aug 6, 2019)

Personally I always set the hostname to be the same as the FQDN, even if they don't _have_ to be the same, from a theoretical point of view. Apart from making sendmail happy from the start, it also avoids potential problems later on. And it avoids an additional resolver query (possibly including a DNS round-trip, depending on setup) each time a program wants to get the FQDN.


----------



## CraigHB (Aug 6, 2019)

I've always been a little confused between hostname and FQDN.  In any case I just use the configuration as previously noted and I don't use sendmail so I guess I shouldn't worry about it.


----------



## gpw928 (Aug 7, 2019)

Phishfry said:


> This is all I use:
> /etc/rc.conf
> sendmail_enable="NONE"
> hostname="E6420"


I monitor software and hardware health, and report issues with sendmail.

There is no better example of this than smartd.

So a typical physical build for me has:

In /etc/rc.conf:

```
hostname="somehost.my.domain"
smartd_enable="YES"
sendmail_enable="YES"
```
In /etc/mail/sendmail.cf:

```
DS=mailhost.my.domain
```
In /usr/local/etc/smartd.conf:

```
DEVICESCAN -a -o on -S on -n standby,q -s (S/../.././02|L/../../6/03) -W 4,50,50  -m root
```
In ~/root/.forward:

```
my.name@mailhost.my.domain
```

Just two days ago, I picked up a failing disk on my main virtualisation server


----------



## Deleted member 30996 (Aug 7, 2019)

I've never used anything but my chosen machine name and set /etc/alias to deliver to me as root:


```
hostname="unmei"
sendmail_enable="NO"


root:    jitte@unmei
```

I need to be root to open my security report but get it daily like clockwork.


----------

