Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Default DNS lookup command?

286 views
Skip to first unread message

Reiner Buehl

unread,
Oct 21, 2023, 11:40:08 AM10/21/23
to
Hi all,

is there a DNS lookup command that is installed by default on any Debian
Bullseye or Bookworm install? Something that doesn't require as much
dependencies as bind9-utils (which provides dig and nslookup) or bind9-host?

Best regards,

Reiner

David Wright

unread,
Oct 21, 2023, 12:00:06 PM10/21/23
to
On Sat 21 Oct 2023 at 17:35:21 (+0200), Reiner Buehl wrote:
> is there a DNS lookup command that is installed by default on any
> Debian Bullseye or Bookworm install? Something that doesn't require as
> much dependencies as bind9-utils (which provides dig and nslookup) or
> bind9-host?

nslookup is in busybox. Type:

$ busybox nslookup
$ busybox nslookup debian.org

Cheers,
David.

Greg Wooledge

unread,
Oct 21, 2023, 12:00:07 PM10/21/23
to
On Sat, Oct 21, 2023 at 05:35:21PM +0200, Reiner Buehl wrote:
> is there a DNS lookup command that is installed by default on any Debian

getent hosts NAME
getent ahostsv4 NAME

That said, you get much finer control from dedicated tools.

Juri Grabowski

unread,
Oct 21, 2023, 12:10:06 PM10/21/23
to
Hello,

it's not really answer to your question, but for simple things like
IP-Addresses you can use getent ahosts, getent hosts or ping directly.

Best Regards,
Juri Grabowski

reiner...@gmail.com

unread,
Oct 21, 2023, 4:10:06 PM10/21/23
to
Perfect! Then I just need to add an alias to my profile and can use nslookup :-)

Max Nikulin

unread,
Oct 22, 2023, 12:10:06 AM10/22/23
to
On 21/10/2023 22:58, David Wright wrote:
> On Sat 21 Oct 2023 at 17:35:21 (+0200), Reiner Buehl wrote:
>> is there a DNS lookup command that is installed by default on any
>> Debian Bullseye or Bookworm install?
>
> nslookup is in busybox.

busybox is an optional package, so it may be absent. "getent hosts" from
Greg's message is better in this sense. If systemd-resolved is
configured on a particular instance then

resolvectl query debian.org

may be an option.

Richard Hector

unread,
Oct 22, 2023, 7:50:07 AM10/22/23
to
That is a useful tool I should remember.

But not strictly a DNS lookup tool:

richard@zircon:~$ getent hosts zircon
127.0.1.1 zircon.lan.walnut.gen.nz zircon

That's from my /etc/hosts file, and overrides DNS. I didn't see an
option in the manpage to ignore /etc/hosts.

I haven't found a way to get just DNS results, without pulling in extra
software.

Richard

David Wright

unread,
Oct 23, 2023, 10:00:06 AM10/23/23
to
AFAICT, if you don't have busybox installed, then I think it's likely
that you removed it yourself. The d-i initrd has busybox already installed,
and most people will see something like this in its log:

# head -n2 /var/log/installer/syslog
Jul 26 19:17:07 syslogd started: BusyBox v1.35.0
Jul 26 19:17:07 kernel: klogd started: BusyBox v1.35.0 (Debian 1:1.35.0-4+b3)
#

If the following file is still available (the one with the highest
generation number), you can see that busybox is typically the third
package to be installed by APT. (If the file has been rotated away,
just search for "busybox" in the file above.)

# zcat /var/log/apt/history.log.2.gz | head

Start-Date: 2023-07-26 19:30:49
Commandline: apt-get -o APT::Status-Fd=4 -o APT::Keep-Fds::=5 -o APT::Keep-Fds::=6 -q -y --no-remove install locales
Install: locales:i386 (2.36-9), libc-l10n:i386 (2.36-9, automatic)
End-Date: 2023-07-26 19:30:56

Start-Date: 2023-07-26 14:31:14
Commandline: apt-get -o APT::Status-Fd=4 -o APT::Keep-Fds::=5 -o APT::Keep-Fds::=6 -q -y --no-remove install busybox
Install: busybox:i386 (1:1.35.0-4+b3)
End-Date: 2023-07-26 14:31:16
#

I suppose preseed experts might be able to prevent that from
happening, though to what purpose, IDK.

I can only assume that its Priority is set to Optional so that
it's easily removable if not required.

I don't see many reasons that systemd-resolved would get installed
unless you specifically asked for it, so I'd hardly call it
"installed by default".

Cheers,
David.

Max Nikulin

unread,
Oct 23, 2023, 1:00:06 PM10/23/23
to
On 23/10/2023 20:52, David Wright wrote:
> AFAICT, if you don't have busybox installed, then I think it's likely
> that you removed it yourself.

Or it is a LXC container installed using the "download" template. It
uses systemd-networkd and systemd-resolved. I have never tried qemu with
kernel and initrd loaded from host, so related tools are not necessary
inside VM.

So for original requirement "on any Debian Bullseye or Bookworm install"
I would not neglect resolvectl when systemd-resolved is active.

Max Nikulin

unread,
Oct 23, 2023, 1:10:07 PM10/23/23
to
On 22/10/2023 18:39, Richard Hector wrote:
> But not strictly a DNS lookup tool:
>
> richard@zircon:~$ getent hosts zircon
> 127.0.1.1       zircon.lan.walnut.gen.nz zircon
>
> That's from my /etc/hosts file, and overrides DNS. I didn't see an
> option in the manpage to ignore /etc/hosts.

getent -s dns hosts zircon

However /etc/resolv.conf may point to local systemd-resolved server or
to dnsmasq started by NetworkManager and they read /etc/hosts by default.

> I haven't found a way to get just DNS results, without pulling in extra
> software.

Usual task for application is to resolve hostname and enough methods
besides DNS may be used: multicast DNS, LLMNR, etc. If you need a debug
tool then you should install it. On the other hand it is desperate when
a feature is implemented, but not exposed to users.

Richard Hector

unread,
Oct 30, 2023, 3:10:07 AM10/30/23
to
On 24/10/23 06:01, Max Nikulin wrote:
> On 22/10/2023 18:39, Richard Hector wrote:
>> But not strictly a DNS lookup tool:
>>
>> richard@zircon:~$ getent hosts zircon
>> 127.0.1.1       zircon.lan.walnut.gen.nz zircon
>>
>> That's from my /etc/hosts file, and overrides DNS. I didn't see an
>> option in the manpage to ignore /etc/hosts.
>
> getent -s dns hosts zircon
>
> However /etc/resolv.conf may point to local systemd-resolved server or
> to dnsmasq started by NetworkManager and they read /etc/hosts by default.

Ah, thanks. But I don't feel too bad about not finding that ...
'service' is not defined in that file, 'dns' doesn't occur, and
searching for 'hosts' doesn't give anything useful either. I guess
reading nsswitch.conf(5) is required.

Thanks,
Richard

Max Nikulin

unread,
Oct 30, 2023, 11:30:08 PM10/30/23
to
On 30/10/2023 14:03, Richard Hector wrote:
> On 24/10/23 06:01, Max Nikulin wrote:
>> getent -s dns hosts zircon
>>
> Ah, thanks. But I don't feel too bad about not finding that ...
> 'service' is not defined in that file, 'dns' doesn't occur, and
> searching for 'hosts' doesn't give anything useful either. I guess
> reading nsswitch.conf(5) is required.

Do you mean that "hosts" entry in your /etc/nsswitch.conf lacks "dns"?
Even systemd nss plugins recommend to keep it as a fallback. If you get
no results then your resolver or DNS server may not be configured to
resolve single-label names. Try some full name

getent -s dns ahosts debian.org

Richard Hector

unread,
Nov 12, 2023, 2:30:06 PM11/12/23
to
Sorry for the confusion (and delay) - I think I was referring to the
getent man page, rather than the config file.

Richard
0 new messages