Resolve Host Names and Addresses Safely with resolveip

When a MariaDB connection fails, resolveip tells you in seconds whether DNS or the database is to blame. You will finish with a small, repeatable check for forward and reverse name resolution: turn a host name into an IP address, turn an address back into a host name, and distinguish a lookup failure from a successful command. The examples use resolveip 2.3 from MariaDB 10.11, installed here as package mariadb-server-core 1:10.11.14-0ubuntu0.24.04.1.

Allow about ten minutes. You need a shell and the MariaDB client utilities package. The checks are read-only and do not require sudo. They query the resolver configuration used by the host, so results depend on its DNS, /etc/hosts and related name-service configuration.

1. Check the installed command

Start by confirming which executable will run and which version it reports. This is an ordinary command:

$ command -v resolveip
/usr/bin/resolveip
$ resolveip --version
resolveip Ver 2.3, for debian-linux-gnu (x86_64)

The output may include the programme's licence notice after the version line. That is normal. The local manual describes the command as resolving host names to IP addresses and vice versa, with one or more host names or IP addresses accepted after the options.

Checkpoint: if command -v prints nothing, stop there. Install or repair the package through your normal system-management process rather than copying a binary from another host.

2. Resolve a host name to an address

Pass a name as the only operand. Use a name you expect this machine to resolve:

$ resolveip localhost
IP address of localhost is 127.0.0.1

For a public or internal name, replace HOST_NAME with the exact value you want to test:

$ resolveip HOST_NAME

A successful lookup prints the resolved address and returns status 0. The command does not edit DNS, /etc/hosts or any MariaDB setting. Do not add sudo just because the result is unexpected; elevated privileges do not correct a bad resolver record.

3. Resolve an address back to a name

Give resolveip an address to perform a reverse lookup:

$ resolveip 127.0.0.1
Host name of 127.0.0.1 is localhost.localdomain, localhost

Multiple names and addresses can be checked in one invocation. The output identifies which operand produced each result:

$ resolveip localhost 127.0.0.1
IP address of localhost is 127.0.0.1
Host name of 127.0.0.1 is localhost.localdomain, localhost

Reverse lookup can return more than one name, as the local example does. Treat that list as resolver data, not as proof that one name is the only valid identity for a machine. For security-sensitive identity decisions, use the application's documented verification method as well.

4. Capture the exit status

For scripts, test the status immediately after the lookup. A status of 0 means the command completed its lookup successfully:

if resolveip HOST_NAME >/tmp/resolveip.out 2>/tmp/resolveip.err; then
    printf '%s\n' 'name resolution succeeded'
else
    status=$?
    printf 'name resolution failed, status %s\n' "$status" >&2
    sed -n '1,5p' /tmp/resolveip.err >&2
fi

This example writes temporary diagnostic files and does not change system configuration. Remove them when you no longer need them:

$ rm -f /tmp/resolveip.out /tmp/resolveip.err

Do not run that removal blindly if another process uses those exact paths. In a real script, use a private temporary directory created with mktemp -d, and clean it with a trap.

5. Investigate a failed lookup

Try a deliberately invalid name only when you want to see the failure shape. The reserved .invalid top-level domain is intended for examples:

$ resolveip definitely-not-a-real-host.invalid
resolveip: Unable to find hostid for 'definitely-not-a-real-host.invalid': no recovery
$ printf 'status=%s\n' "$?"
status=2

The wording and status are from the installed command. A real failure may mean a missing record, a resolver outage, a search-domain surprise or a local name-service problem. It is not automatically a MariaDB connection failure.

Check the exact name first, then inspect the host's resolver configuration and compare with another resolver tool already approved for the machine. Keep the tests read-only. If a service uses the same name, do not restart it or rewrite configuration until you have identified whether the failure is in name resolution, routing or the service itself.

6. Use silent mode only when less output helps

The --silent or -s option produces less output, but it does not turn a failed lookup into a successful one:

$ resolveip --silent definitely-not-a-real-host.invalid
resolveip: Unable to find hostid for 'definitely-not-a-real-host.invalid': no recovery
$ printf 'status=%s\n' "$?"
status=2

Use silent mode when a human does not need the normal success text and the script is relying on the exit status. Keep diagnostics available while troubleshooting. Avoid parsing the prose output as an API: the useful stable boundary for a shell check is the command's status, while the displayed names and addresses come from the resolver.

7. Get help without changing anything

The command has no configuration file or enable operation in this interface. Ask for its built-in help when you need the local option spelling:

$ resolveip --help
Usage: resolveip [OPTIONS] hostname or IP-address
  -?, --help          Displays this help and exits.
  -I, --info          Synonym for --help.
  -s, --silent        Be more silent.
  -V, --version       Displays version information and exits.

Help and version queries are read-only. If you need to change host records, resolver order or network configuration, use the system's documented administration workflow separately. Those changes can affect every service on the machine and are outside what resolveip itself does.

Done means