You are not logged in.

#1 2020-07-18 10:32:19

Malvineous
Member
From: Brisbane, Australia
Registered: 2011-02-03
Posts: 173
Website

How to disable short hostname resolution

Does anyone know how to disable name resolution of short hostnames?  It's recently started happening and it's causing me headaches, and I can't seem to figure out how to turn it off.

The problem is that if I run "ssh otherpc" then what used to happen is a DNS search suffix like ".mydomain" was added, then "otherpc.mydomain" would resolve, and SSH would connect.

Now, "otherpc" on its own resolves to an IP address, SSH doesn't pick up the configuration I have for "*.mydomain" because there's no domain now, so then it can't connect to the machine because it doesn't know which private key to use.

After doing some research I thought this might be LLMNR, so I disabled this in /etc/systemd/resolved.conf, restarted systemd-resolved, but nothing.  I still get short names resolved.  I tried "resolvectl flush-caches" but no luck.

I'm running my own DNS server on the machine and as expected, running "host otherpc localhost" to query the DNS server directly, returns a 'not found' error for the short name so I know it's not my DNS server doing anything funny.

Does anyone know how to stop short hostnames from resolving and go back to the old behaviour of having DNS search suffixes added, so I can go back to using SSH with short hostnames?

Offline

#2 2020-07-19 11:40:57

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 8,274

Re: How to disable short hostname resolution

Could be NSS (Name Service Switch) related or conflicting resolvers. Both are described on [1] .

post /etc/nsswitch.conf and ls -lR /etc/systemd .



[1] https://wiki.archlinux.org/index.php/Do … resolution


Multi-init booting with apg Openrc and systemd coexisting
Automounting : not needed, i prefer pmount
Aur helpers : makepkg + my own local repo === rarely need them

Offline

#3 2020-07-20 13:31:11

Malvineous
Member
From: Brisbane, Australia
Registered: 2011-02-03
Posts: 173
Website

Re: How to disable short hostname resolution

Thanks for the reply!  nsswitch.conf says:

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

Does 'resolve' still call systemd-resolved even if it's not running?  I get the same behaviour after running `systemd stop systemd-resolved`.

$ ls -lR /etc/systemd
/etc/systemd:
total 68K
drwxr-xr-x   5 root root 4.0K Jul 18 19:54 .
drwxr-xr-x 102 root root 4.0K Jul 19 11:14 ..
-rw-r--r--   1 root root  615 Jun 23 21:09 coredump.conf
-rw-r--r--   1 root root  695 Jun 23 21:09 journal-remote.conf
-rw-r--r--   1 root root  672 Jun 23 21:09 journal-upload.conf
-rw-r--r--   1 root root 1.1K Jul 12 16:50 journald.conf
-rw-r--r--   1 root root 1.1K Jun 23 21:09 logind.conf
drwxr-xr-x   2 root root 4.0K May 24 13:59 network
-rw-r--r--   1 root root  584 Jun 23 21:09 networkd.conf
-rw-r--r--   1 root root  529 Jun 23 21:09 pstore.conf
-rw-r--r--   1 root root  898 Jul 18 19:54 resolved.conf
-rw-r--r--   1 root root  790 Jun 23 21:09 sleep.conf
drwxr-xr-x  10 root root 4.0K Jul 12 12:59 system
-rw-r--r--   1 root root 1.8K Jun  6 21:04 system.conf
-rw-r--r--   1 root root  669 Jun 23 21:09 timesyncd.conf
drwxr-xr-x   4 root root 4.0K May 27 15:40 user
-rw-r--r--   1 root root 1.2K Jun 23 21:09 user.conf

/etc/systemd/network:
total 24K
drwxr-xr-x 2 root root 4.0K May 24 13:59 .
drwxr-xr-x 5 root root 4.0K Jul 18 19:54 ..
-rw-r--r-- 1 root root   52 May 21 00:53 40-bond10g.network
-rw-r--r-- 1 root root  344 May 24 13:59 50-bond10g.network
-rw-r--r-- 1 root root  192 Sep 16  2018 50-static.network
-rw-r--r-- 1 root root   89 May 21 00:52 bond10g.netdev

/etc/systemd/system:
total 72K
drwxr-xr-x 10 root root  4.0K Jul 12 12:59 .
drwxr-xr-x  5 root root  4.0K Jul 18 19:54 ..
lrwxrwxrwx  1 root root    48 Sep 15  2018 dbus-org.freedesktop.network1.service -> /usr/lib/systemd/system/systemd-networkd.service
lrwxrwxrwx  1 root root    48 Sep 16  2018 dbus-org.freedesktop.resolve1.service -> /usr/lib/systemd/system/systemd-resolved.service
lrwxrwxrwx  1 root root    39 Sep 16  2018 display-manager.service -> /usr/lib/systemd/system/lightdm.service
drwxr-xr-x  2 root root  4.0K Sep 15  2018 getty.target.wants
drwxr-xr-x  2 root root  4.0K May  6  2019 multi-user.target.wants
drwxr-xr-x  2 root root  4.0K Dec  9  2018 printer.target.wants
-rw-r--r--  1 root root   225 Feb 24  2019 slock@.service
drwxr-xr-x  2 root root  4.0K Dec  9  2018 sockets.target.wants
-rw-r--r--  1 root root   539 Jul 12 12:59 stats.service
drwxr-xr-x  2 root root  4.0K Mar 22 21:23 timers.target.wants
lrwxrwxrwx  1 root root    39 May 17 19:36 zed.service -> /usr/lib/systemd/system/zfs-zed.service
drwxr-xr-x  2 root root  4.0K Sep 24  2018 zfs-import.target.wants
-rw-r--r--  1 root root   248 May 25 09:17 zfs-load-key.service
drwxr-xr-x  2 root root  4.0K May 25 09:18 zfs-mount.service.wants
drwxr-xr-x  2 root root  4.0K Jul 12 14:55 zfs.target.wants

/etc/systemd/system/getty.target.wants:
total 8.0K
drwxr-xr-x  2 root root 4.0K Sep 15  2018 .
drwxr-xr-x 10 root root 4.0K Jul 12 12:59 ..
lrwxrwxrwx  1 root root   38 Sep 15  2018 getty@tty1.service -> /usr/lib/systemd/system/getty@.service

/etc/systemd/system/multi-user.target.wants:
total 8.0K
drwxr-xr-x  2 root root 4.0K May  6  2019 .
drwxr-xr-x 10 root root 4.0K Jul 12 12:59 ..
lrwxrwxrwx  1 root root   42 Dec 19  2018 bacula-dir.service -> /usr/lib/systemd/system/bacula-dir.service
lrwxrwxrwx  1 root root   41 Dec 19  2018 bacula-fd.service -> /usr/lib/systemd/system/bacula-fd.service
lrwxrwxrwx  1 root root   41 Dec 19  2018 bacula-sd.service -> /usr/lib/systemd/system/bacula-sd.service
lrwxrwxrwx  1 root root   38 Sep 30  2018 cronie.service -> /usr/lib/systemd/system/cronie.service
lrwxrwxrwx  1 root root   38 Sep 22  2018 docker.service -> /usr/lib/systemd/system/docker.service
lrwxrwxrwx  1 root root   42 Sep 18  2018 lm_sensors.service -> /usr/lib/systemd/system/lm_sensors.service
lrwxrwxrwx  1 root root   39 Dec 19  2018 mariadb.service -> /usr/lib/systemd/system/mariadb.service
lrwxrwxrwx  1 root root   42 Sep 25  2018 nfs-server.service -> /usr/lib/systemd/system/nfs-server.service
lrwxrwxrwx  1 root root   36 Nov 10  2018 ntpd.service -> /usr/lib/systemd/system/ntpd.service
lrwxrwxrwx  1 root root   39 Nov 10  2018 ntpdate.service -> /usr/lib/systemd/system/ntpdate.service
lrwxrwxrwx  1 root root   43 Dec  9  2018 org.cups.cupsd.path -> /usr/lib/systemd/system/org.cups.cupsd.path
lrwxrwxrwx  1 root root   40 Sep 15  2018 remote-fs.target -> /usr/lib/systemd/system/remote-fs.target
lrwxrwxrwx  1 root root   35 Dec 26  2018 smb.service -> /usr/lib/systemd/system/smb.service
lrwxrwxrwx  1 root root   36 Sep 15  2018 sshd.service -> /usr/lib/systemd/system/sshd.service
lrwxrwxrwx  1 root root   33 Apr 27  2019 stats.service -> /etc/systemd/system/stats.service
lrwxrwxrwx  1 root root   48 Sep 15  2018 systemd-networkd.service -> /usr/lib/systemd/system/systemd-networkd.service
lrwxrwxrwx  1 root root   48 Sep 16  2018 systemd-resolved.service -> /usr/lib/systemd/system/systemd-resolved.service
lrwxrwxrwx  1 root root   34 Sep 24  2018 zfs.target -> /usr/lib/systemd/system/zfs.target

/etc/systemd/system/printer.target.wants:
total 8.0K
drwxr-xr-x  2 root root 4.0K Dec  9  2018 .
drwxr-xr-x 10 root root 4.0K Jul 12 12:59 ..
lrwxrwxrwx  1 root root   46 Dec  9  2018 org.cups.cupsd.service -> /usr/lib/systemd/system/org.cups.cupsd.service

/etc/systemd/system/sockets.target.wants:
total 8.0K
drwxr-xr-x  2 root root 4.0K Dec  9  2018 .
drwxr-xr-x 10 root root 4.0K Jul 12 12:59 ..
lrwxrwxrwx  1 root root   45 Dec  9  2018 org.cups.cupsd.socket -> /usr/lib/systemd/system/org.cups.cupsd.socket
lrwxrwxrwx  1 root root   47 Sep 15  2018 systemd-networkd.socket -> /usr/lib/systemd/system/systemd-networkd.socket

/etc/systemd/system/timers.target.wants:
total 8.0K
drwxr-xr-x  2 root root 4.0K Mar 22 21:23 .
drwxr-xr-x 10 root root 4.0K Jul 12 12:59 ..
lrwxrwxrwx  1 root root   53 Mar 22 21:22 zfs-auto-snapshot-daily.timer -> /usr/lib/systemd/system/zfs-auto-snapshot-daily.timer
lrwxrwxrwx  1 root root   56 Mar 22 21:23 zfs-auto-snapshot-frequent.timer -> /usr/lib/systemd/system/zfs-auto-snapshot-frequent.timer
lrwxrwxrwx  1 root root   55 Mar 22 21:23 zfs-auto-snapshot-monthly.timer -> /usr/lib/systemd/system/zfs-auto-snapshot-monthly.timer
lrwxrwxrwx  1 root root   54 Mar 22 21:22 zfs-auto-snapshot-weekly.timer -> /usr/lib/systemd/system/zfs-auto-snapshot-weekly.timer

/etc/systemd/system/zfs-import.target.wants:
total 8.0K
drwxr-xr-x  2 root root 4.0K Sep 24  2018 .
drwxr-xr-x 10 root root 4.0K Jul 12 12:59 ..
lrwxrwxrwx  1 root root   48 Sep 24  2018 zfs-import-cache.service -> /usr/lib/systemd/system/zfs-import-cache.service

/etc/systemd/system/zfs-mount.service.wants:
total 8.0K
drwxr-xr-x  2 root root 4.0K May 25 09:18 .
drwxr-xr-x 10 root root 4.0K Jul 12 12:59 ..
lrwxrwxrwx  1 root root   41 Sep 24  2018 zfs-import.target -> /usr/lib/systemd/system/zfs-import.target
lrwxrwxrwx  1 root root   40 May 25 09:18 zfs-load-key.service -> /etc/systemd/system/zfs-load-key.service

/etc/systemd/system/zfs.target.wants:
total 8.0K
drwxr-xr-x  2 root root 4.0K Jul 12 14:55 .
drwxr-xr-x 10 root root 4.0K Jul 12 12:59 ..
lrwxrwxrwx  1 root root   41 Sep 24  2018 zfs-import.target -> /usr/lib/systemd/system/zfs-import.target
lrwxrwxrwx  1 root root   41 Sep 30  2018 zfs-share.service -> /usr/lib/systemd/system/zfs-share.service
lrwxrwxrwx  1 root root   39 May 17 19:36 zfs-zed.service -> /usr/lib/systemd/system/zfs-zed.service

/etc/systemd/user:
total 16K
drwxr-xr-x 4 root root 4.0K May 27 15:40 .
drwxr-xr-x 5 root root 4.0K Jul 18 19:54 ..
drwxr-xr-x 2 root root 4.0K May 27 15:40 default.target.wants
drwxr-xr-x 2 root root 4.0K Jun  7 21:59 sockets.target.wants

/etc/systemd/user/default.target.wants:
total 8.0K
drwxr-xr-x 2 root root 4.0K May 27 15:40 .
drwxr-xr-x 4 root root 4.0K May 27 15:40 ..
lrwxrwxrwx 1 root root   50 May 27 15:40 xdg-user-dirs-update.service -> /usr/lib/systemd/user/xdg-user-dirs-update.service

/etc/systemd/user/sockets.target.wants:
total 8.0K
drwxr-xr-x 2 root root 4.0K Jun  7 21:59 .
drwxr-xr-x 4 root root 4.0K May 27 15:40 ..
lrwxrwxrwx 1 root root   36 Sep 15  2018 dirmngr.socket -> /usr/lib/systemd/user/dirmngr.socket
lrwxrwxrwx 1 root root   46 Sep 15  2018 gpg-agent-browser.socket -> /usr/lib/systemd/user/gpg-agent-browser.socket
lrwxrwxrwx 1 root root   44 Sep 15  2018 gpg-agent-extra.socket -> /usr/lib/systemd/user/gpg-agent-extra.socket
lrwxrwxrwx 1 root root   42 Sep 15  2018 gpg-agent-ssh.socket -> /usr/lib/systemd/user/gpg-agent-ssh.socket
lrwxrwxrwx 1 root root   38 Sep 15  2018 gpg-agent.socket -> /usr/lib/systemd/user/gpg-agent.socket
lrwxrwxrwx 1 root root   43 Sep 15  2018 p11-kit-server.socket -> /usr/lib/systemd/user/p11-kit-server.socket
lrwxrwxrwx 1 root root   39 Jun  7 21:59 pulseaudio.socket -> /usr/lib/systemd/user/pulseaudio.socket

Offline

#4 2020-07-21 10:02:05

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 8,274

Re: How to disable short hostname resolution

https://jlk.fjfi.cvut.cz/arch/manpages/ … -resolve.8 indicates if systemd-resolved isn't running it should fallback to nss-dns .

https://wiki.archlinux.org/index.php/Ne … resolution looks relevant, but you don't appear to be using avahi .


Maybe try forcing systemd-resolved to use your dns server, https://wiki.archlinux.org/index.php/Sy … d#Manually ?


Multi-init booting with apg Openrc and systemd coexisting
Automounting : not needed, i prefer pmount
Aur helpers : makepkg + my own local repo === rarely need them

Offline

Board footer

Powered by FluxBB