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.
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 | shLoad the Cargo environment and verify the Rust compiler:
source $HOME/.cargo/env
rustc --versionDownload 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.gzEnter the source directory and compile:
cd dog-0.1.0/
cargo build
cargo testTo 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 testCopy 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/binVerify Installation
dog --versionOutput 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.bashUsing 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 --helpDisplays all available options and sub‑commands.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
