You are not logged in.

#1 2021-10-01 13:54:01

duyinthee
Member
Registered: 2015-06-14
Posts: 222
Website

localdomain in hosts and hosts in nsswitch.conf

Hello everyone!

This question may be stupid and old but I can't figure out myself even after I read many times this pages: https://wiki.archlinux.org/title/Networ … e_hostname and https://man.archlinux.org/man/hosts.5

my /etc/hosts

127.0.0.1	localhost
::1		localhost
127.0.1.1	myhostnamehere.localdomain	myhostnamehere

what is localdomain? I know what is domain. But, in case of /etc/hosts file, I don't know exactly what is localdomain?
I don't have any domain. This machine is my just desktop using for my work and it is not associated with any domain.
So, in this case, how should I set localdomain in /etc/hosts file correctly?

And I am trying to set up hostname resolution by avahi. I set /etc/nsswitch.conf as in wiki page.

hosts: files mymachines myhostname mdns_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] dns

In that case, should I set myhostname to my real hostname? If so, also should I replace mymachines with what?

Thanks.

Last edited by duyinthee (2021-10-01 13:54:31)

Offline

#2 2021-10-01 14:40:10

seth
Member
Registered: 2012-09-03
Posts: 49,974

Re: localdomain in hosts and hosts in nsswitch.conf

should I set myhostname to my real hostname? If so, also should I replace mymachines with what?

No and neither.

"localdomain" rubb… a "gentlemen's agreement"
https://bbs.archlinux.org/viewtopic.php?id=156064
https://wiki.archlinux.org/title/Talk:I … ocaldomain

Joe Shmoe user doesn't have to worry about network domains, it's perfectly fine to only resolve "localhost" and your actual hostname (whatever is in /etc/hostname - and that should™ not be generic nonsense like "hostname" or "localhost" because it can cause collisions in domain name resolution and therefore gets replaced by network managers what causes more issues down the road) to 127.0.0.1 and ::1

It is technically not wrong to resolve localhost.localdomain (even this way) but is usually not what you want and not required.

Ie. tl;dr: in doubt simply skip the "myhostnamehere.localdomain" field.

Online

#3 2021-10-04 01:32:12

duyinthee
Member
Registered: 2015-06-14
Posts: 222
Website

Re: localdomain in hosts and hosts in nsswitch.conf

Thanks for reply and the links.

Offline

Board footer

Powered by FluxBB