2

I used to be able to ssh [email protected] between machines on my LAN but it is no longer working. I can ssh using the IP of course, but it's DHCP so it may change from time to time. Both machines run Debian 9.12, one is a VM in a Windows host, but still, it DID work ; I haven't fooled around with the config files, just regular updates.

ping hostname.local
ping: hostname.local: Name or service not known

(it might not be exactly that message as I translate from French)

ssh hostname.local
ssh: Could not resolve hostname hostname.local: Name or service not known

(ssh outputs in English)

From avahi.org :

Avahi is a system which facilitates service discovery on a local network via the mDNS/DNS-SD protocol suite

I've looked into /etc/resolv.conf, /etc/avahi/avahi-daemon.conf, /etc/nsswitch.conf but it's standard out-of-the-box config.

/etc/resolv.conf (reset by network-manager each time it starts)

# Generated by NetworkManager
search lan
nameserver xx.xx.xx.xx # DNS IPs obtained from DHCP
nameserver xx.xx.xx.xx 

man resolv.conf says that the search list contains only the local domain name by default (something like that, I translated from man page in French) ; shouldn't it be localinstead of lan ?

I tried to change it and ping or ssh another host on my lan right away (without restarting network-manager), it didn't work. And when I restart network-manager, it rewrites /etc/resolv.conf and sets search lan.

/etc/nsswitch.conf (default, I haven't made any change)

# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.

passwd:         compat
group:          compat
shadow:         compat
gshadow:        files

hosts:          files mdns4_minimal [NOTFOUND=return] dns myhostname
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

I've tried to discover hosts and services with avahi-browse and nbtscan, which rely on avahi (zeroconf / Bonjour), but they seem to find only the host on which they run.

(I know this is a possible duplicate of other questions, but I didn't find any answer and I don't have enough reputation to do anything)

Manumie
  • 51
  • 1
  • 1
  • 8
  • Is your DHCP server DNS server as well? And if it is, do its clients request hostname? – Arkadiusz Drabczyk Mar 29 '20 at 14:35
  • note that the [.local](https://en.wikipedia.org/wiki/.local) domain is special since 2013: it should be resolved by [multicast DNS](https://tools.ietf.org/html/rfc6762#section-3) rather than by DNS. On linux this is handled by [avahi](https://packages.debian.org/source/stable/avahi) & co. – A.B Mar 29 '20 at 14:39
  • @ArkadiuszDrabczyk I'm not sure ; at least I can't configure its internal DNS. It shows the hostnames of the hosts connected in its interface though. – Manumie Mar 29 '20 at 16:08
  • @A.B I've read about that, that's what `nssswitch.conf` is for, isn't it ? I'm adding its content to the post. – Manumie Mar 29 '20 at 16:11

2 Answers2

3

Found it !

It seems that my router has a DNS server indeed :

nslookup host_ip router_ip
Server:     192.168.1.254
Address:    192.168.1.254#53

69.1.168.192.in-addr.arpa   name = hostname.lan.

So that answers the .localvs .lanquestion. In recent Debian, the local domain is .lan.

Still, ping hostname.lan returns unknown host.

Thanks to https://askubuntu.com/questions/623940/network-manager-how-to-stop-nm-updating-etc-resolv-conf, I found out that /etc/resolv.conf is a symlink to /var/run/NetworkManager/resolv.conf ; so I had to replace it with my own resolv.conf :

search lan
nameserver 192.168.1.254

so that it uses the router's DNS (which will route the queries if necessary).

Restarting network-manager systemctl restart network-manager and it works like a charm :

$ ping hostname.lan
PING hostname.lan (192.168.1.69) 56(84) bytes of data.
64 bytes from hostname.lan (192.168.1.69): icmp_seq=1 ttl=64 time=2.02 ms

(ping google.fr to make sure WAN queries are processed)

Manumie
  • 51
  • 1
  • 1
  • 8
0

You should not need a FQDN; just use the host part. For instance:

`[root@darouter ~]# arping -I enp2s0f1 matilda
ARPING 192.168.100.12 from 192.168.100.254 enp2s0f1
Unicast reply from 192.168.100.12 [D0:67:E5:EB:37:25]  0.759ms
Unicast reply from 192.168.100.12 [D0:67:E5:EB:37:25]  0.801ms
Unicast reply from 192.168.100.12 [D0:67:E5:EB:37:25]  0.732ms
Sent 3 probes (1 broadcast(s))
Received 3 response(s)`

I used arping as matilda is a windoz box; that was easier than figuring out how to allow incoming ping. I would disable dns on the router. There should be a place to put in a dns server ip so you can use your internal dns. If your internal dns is not resolving by hostname, you need to figure out where your dns config is broken. I had this problem awhile back. Unfortunately that was awhile ago; and since I don't remember what I did yesterday, I can not give you a definitive answer of what I did to solve it.

Hope this helps!

Todh

ctclibby
  • 29
  • 3
  • Indeed, I don't need the domain part, but that didn't work either before the changes I made to `resolv.conf`. The so-called router is the box provided by my ISP, it provides DHCP and DNS, and it's always up. So it would be overkill to set up a DNS somewhere else on my LAN. – Manumie Mar 30 '20 at 13:49
  • Ya, keep it simple as that is the best. Does the router update dns with dhcp hosts and such? I thought about what I did and I do think it had to do with resolve.conf. I renamed it ( /var/run/NetworkManager/resolv.conf ) to resolve.conf.bak. Network Manager then did not write /etc/resolve.conf which allowed dns queries to my internal dns server. All in all, looks like configuring the router is the way to go. – ctclibby Mar 30 '20 at 14:13
  • Yup that's pretty much what I ended up doing, as I explain in my answer below ! – Manumie Mar 30 '20 at 15:22