Skip to content

hostname: use dns-lookup crate to get the network address(es) of the host #6546

@lcheylus

Description

@lcheylus

On FreeBSD, MacOS and OpenBSD, hostname -i does not work:

$ target/debug/coreutils hostname -i
hostname: failed to resolve socket addresses: failed to lookup address information: no address associated with name

In src/uu/hostname/src/hostname.rs, there is a comment that proposes to use dns-lookup crate to do this DNS request (hostname -> IP addrs).

I have a local branch using dns-lookup crate for hostname -i => works on OpenBSD :)

$ uname -a
OpenBSD openbsd-dev.home.lan 7.5 GENERIC.MP#170 amd64

$ target/debug/coreutils hostname
openbsd-dev.home.lan
$ target/debug/coreutils hostname -i
10.0.2.15

Thus, I propose to use dns-lookup for hostname tool and to push a PR for it. Agree ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions