Fundamentals 8 min read

How to Install and Use the Dog DNS Command-Line Tool on Ubuntu

This guide walks you through installing the Rust‑based Dog DNS client on Ubuntu, configuring faster crate mirrors, building the binary, and using its rich query features—including A, NS, MX lookups, custom DNS servers, JSON output, and command‑completion support.

Liangxu Linux
Liangxu Linux
Liangxu Linux
How to Install and Use the Dog DNS Command-Line Tool on Ubuntu

Overview

Dog is a Rust‑written command‑line DNS client similar to dig. It supports DNS‑over‑TLS, DNS‑over‑HTTPS, and can output results in JSON format.

System Environment

Ubuntu 20.04.1 LTS

Installation

Dog requires rustc version ≥ 1.45.0. The default apt version is too old, so install the necessary tools and a newer Rust toolchain manually. sudo apt install -y cargo libssl-dev Set Rust mirror to a faster source and install Rust:

export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
curl https://sh.rustup.rs -sSf | sh

Load the Cargo environment and verify the Rust compiler:

source $HOME/.cargo/env
rustc --version

Download and Build Dog

Fetch the source archive from GitHub and extract it:

wget https://github.com/ogham/dog/archive/v0.1.0.tar.gz
tar xvf v0.1.0.tar.gz

Enter the source directory and compile:

cd dog-0.1.0/
cargo build
cargo test

To speed up crate downloads, create ~/.cargo/config with a faster mirror (example for TUNA, USTC, SJTU, etc.):

[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"
replace-with = 'sjtu'

[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"

[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"

[source.sjtu]
registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"

[source.rustcc]
registry = "git://crates.rustcc.cn/crates.io-index"

Re‑run the build after editing the config:

cargo build
cargo test

Copy the resulting binary to a directory in $PATH so it can be run from anywhere:

sudo cp -p ~/dog-0.1.0/target/debug/dog /usr/local/bin

Verify Installation

dog --version

Output shows the version and build date, confirming the tool works.

Command Completion

Enable Bash completion by sourcing the provided script:

source ~/dog-0.1.0/completions/dog.bash

Using Dog

Query an A record (e.g., www.baidu.com): dog www.baidu.com Result includes CNAME and A records with TTLs.

Query NS records for a domain: dog aliyun.com NS Query with a specific DNS server (e.g., Google’s 1.1.1.1) and request MX records: dog google.com MX @1.1.1.1 JSON output for an A record query: dog A www.baidu.com -J The command returns a JSON object containing answers, authorities, and queries.

Help

dog --help

Displays all available options and sub‑commands.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

RustDNSUbuntunetwork-toolsDog
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.