You are not logged in.

#1 2018-01-02 22:21:44

esuhl
Member
From: UK
Registered: 2009-09-16
Posts: 140

[SOLVED] LAN hostname resolution fails (hosts file issue?)

I can ping machines on my home LAN via IP address, but not by hostname.  (Actually, I can ping the local machine I'm actually using by hostname.)

The wiki page on Network Configuration says: (https://wiki.archlinux.org/index.php/Ne … resolution):

To allow other machines to address the host by name, it is necessary to either:

    - Configure the hosts(5) file, or
    - Enable a service which resolves the hostname.

Note: systemd provides hostname resolution via the myhostname nss module, enabled by default in /etc/nsswitch.conf. However, clients may still rely on /etc/hosts, see [2] [3] for examples.

On both i7pc and ee901, I'm using systemd, and have nss enabled in /etc/nsswitch.conf, like this:

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

However, my /etc/hosts files are quite different on the two machines.  I suspect they may be the root of the problem, but I don't quite understand what entries the hosts files should have...  :-/

127.0.0.1	localhost.localdomain	localhost
127.0.0.1	i7pc.localdomain	i7pc
::1		localhost.localdomain	localhost
127.0.0.1	eee901.localdomain	eee901 localhost
::1		eee901.localdomain	eee901 localhost

Can anyone help?  :-)

Last edited by esuhl (2018-01-03 21:31:59)

Offline

#2 2018-01-02 22:54:09

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: [SOLVED] LAN hostname resolution fails (hosts file issue?)

In each machines hosts file you need to add an entry for all of the machines you wish it to resolve, so on i7pc you need to add the line...

192.168.1.10          ee901

And on ee901 you need to add the line...

192.168.1.11          17pc

Obviously replacing the IP's with their correct value.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#3 2018-01-02 23:58:07

esuhl
Member
From: UK
Registered: 2009-09-16
Posts: 140

Re: [SOLVED] LAN hostname resolution fails (hosts file issue?)

slithery wrote:

In each machines hosts file you need to add an entry for all of the machines you wish it to resolve...

Ah, right -- thanks!

Is there a way to do this without using static IPs?  The wiki seems to imply that hostname resolution should happen automatically...?

systemd provides hostname resolution via the myhostname nss module, enabled by default in /etc/nsswitch.conf

Last edited by esuhl (2018-01-02 23:58:35)

Offline

#4 2018-01-03 00:58:26

loqs
Member
Registered: 2014-03-06
Posts: 19,113

Re: [SOLVED] LAN hostname resolution fails (hosts file issue?)

See https://bugs.archlinux.org/task/56684? and man nss-myhostname
If you have in /etc/nsswitch.conf

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

Then in theory a blank /etc/hosts should work for all executables that use nsswitch at least as a fallback you could add
/etc/hosts

# Static table lookup for hostnames.
# See hosts(5) for details.
127.0.0.1       localhost.localdomain   localhost
::1             localhost.localdomain   localhost

Offline

#5 2018-01-03 21:31:37

esuhl
Member
From: UK
Registered: 2009-09-16
Posts: 140

Re: [SOLVED] LAN hostname resolution fails (hosts file issue?)

Thanks I didn't know about that bug. :-)

I followed those suggestions and, after a lot of playing around, I found that starting the systemd-resolved service fixed the problem!

Cheers all :-)

Offline

#6 2018-01-03 21:54:57

loqs
Member
Registered: 2014-03-06
Posts: 19,113

Re: [SOLVED] LAN hostname resolution fails (hosts file issue?)

It should have worked without the need to change to systemd-resolved provided you adjusted the hosts to move myhostname before resolve glad the issue is resolved anyway.

Offline

Board footer

Powered by FluxBB