wanderings/content/posts/local-name-resolution.md

63 lines
3.0 KiB
Markdown
Raw Normal View History

2020-10-08 23:07:35 +02:00
+++
title = "Local Name Resolution in Arch"
date = 2020-09-26
tags = ["admin"]
+++
It's quite handy to be able to access clients connected at the same Access Point
as you using their hostname. There are a few technologies to do that : mostly,
Apple's Bonjour translates as mDNS in the Linux world, then there is Microsoft's
NetBIOS protocol, that is provided by samba under Linux but not running as a
default. And Microsoft also created the LLMNR resolution protocol, that ships
with Windows starting at Vista (and with 7, 8 and 10).
To have local name resolution, your best option is probably `systemd-resolved`,
since it does both mDNS and LLMNR. On the other side, avahi does mDNS and lets
you advertise specific services on the network. If you're interested in this you
might want to go for it ; check [Archwiki's page on network
configuration][aw-net-conf]. Here we will deal with `systemd-resolved`.
The first thing to do is to disable avahi services, since they interfere with
`systemd-networkd`. Go on and
```
# systemctl disable avahi-daemon
```
Now we need to check how you do domain resolution on your computer. Under Linux
this is dependent on who manages `/etc/resolv.conf`. If it's a symlink to some
NetworkManager folder, it's NetworkManager. If it's linked to some Systemd
folder, then it's `systemd-resolved`. If it is NetworkManager and you want to
switch to `systemd-resolved` and keep NetworkManager to manage connections, just
do :
```
# ln -sf /run/systemd/resolve/stub-resolve.conf /etc/resolv.conf
```
It may also be a real file, meaning your computer uses static IP addresses for
DNS servers. In this case you can do the same (back it up if you will).
Edit `/etc/systemd/resolved.conf` so that inside of the `[Resolve]` section, you
have `MulticastDNS=yes` and `LLMNR=yes`. After that, you will have to
```
# systemctl enable systemd-resolved
```
And reboot.
Now run `resolvectl` to see how it goes. If your network interface doesn't
specifically allow MulticastDNS, you will have to tell the network manager to do
it. If it's `systemd-networkd`, you will need to add the very same option in the
relevant `.network` files in `/etc/systemd/network/`. If it's NetworkManager, no
luck, you will have to update each and every connection by adding `mdns=2` to
the `[connection]` section of the connection definition in
`/etc/NetworkManager/system-connections`.
If you changed anything, you might want to reboot again. Then try
```
$ resolvectl query SOMEHOSTNAME.local
```
SOMEHOSTNAME being the name of a device you know is connected. It should answer
through mDNS. You may also try `resolvectl query SOMEHOSTNAME`, skipping the
`.local` extension ; it should answer with LLMNR. Do note that Android devices
don't seem to show up on the local network. But they do see declared neighbours
; I suspect they ship with LLMNR since they're only able to `ping` names without
the `.local` extension.
[aw-net-conf]: https://wiki.archlinux.org/index.php/Network_configuration#Local_network_hostname_resolution