Skip to content

Super1Windcloud/domaininfo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

domaininfo

domaininfo is a Rust CLI tool that resolves a domain to its server IP addresses and prints geolocation details for each IP.

It accepts plain domains and full URLs:

domaininfo example.com
domaininfo "https://example.com/path"

For http and https URLs, domaininfo follows redirects first and resolves the final URL host.

Features

  • Resolves A and AAAA DNS records.
  • Shows country, region, city, and ISP for each IP.
  • Accepts domains, URLs, domains with ports, and IPv6 URLs.
  • Follows HTTP redirects before resolving URL hosts.
  • Uses DoH by default to avoid TUN / VPN / proxy fake-IP DNS results.
  • Selects the default resolver from the device locale.
  • Supports --dns to manually use a UDP DNS server.

DNS Selection

The default resolver is selected from the system locale:

Chinese locale: AliDNS 223.5.5.5 (DoH)
Other locales:  Google Public DNS 8.8.8.8 (DoH)

Locale detection checks common environment variables first:

LC_ALL
LC_MESSAGES
LANG
LANGUAGE
PreferredUILanguages

If those values do not identify a Chinese locale, the tool falls back to sys_locale::get_locale().

Usage

Install from crates.io:

cargo install domaininfo

Upgrade to the latest published version:

cargo install domaininfo --force

Uninstall:

cargo uninstall domaininfo
domaininfo [--dns <DNS_SERVER_IP>] <domain-or-url>

Examples:

domaininfo baidu.com
domaininfo "https://httpsgood.abrdns.com/console"
domaininfo --dns 1.1.1.1 example.com
domaininfo --dns=8.8.8.8 example.com

Example output:

域名: httpsgood.abrdns.com
DNS: AliDNS 223.5.5.5 (DoH)
解析到 1 个唯一 IP

IP                                      类型     地理位置                                     ISP
--------------------------------------------------------------------------------------------------------------
38.12.22.15                             IPv4   United States, California, San Jose      Cogent Communications

Redirect Handling

When the input is an http or https URL, the tool sends a request with redirects enabled and resolves the final host:

domaininfo "https://short.example/link"

If the URL redirects to https://www.example.com/page, domaininfo resolves www.example.com.

Plain domains and non-HTTP targets do not trigger network redirect checks.

TUN / Fake-IP Notes

Many proxy or VPN tools use fake-IP DNS in TUN mode and return addresses from the reserved 198.18.0.0/15 range:

198.18.15.69

That is not the target domain's real public IP. It is an internal virtual address used by the proxy.

domaininfo uses DoH by default, which usually avoids system DNS and UDP port 53 interception. If you pass --dns, the tool switches to UDP DNS queries, and the result may still be affected by TUN, local proxy rules, or firewall policy.

Build

Install from crates.io for normal use:

cargo install domaininfo

Build from source for local development:

cargo build

Run the compiled binary:

.\target\debug\domaininfo.exe example.com

Test

cargo fmt --check
cargo test

Current unit tests cover:

  • CLI argument parsing.
  • Domain and URL host extraction.
  • IPv6 URL parsing.
  • Redirect target classification.
  • Automatic DNS resolver selection.
  • DNS query packet construction.
  • DNS A / AAAA response parsing.
  • DoH answer filtering.
  • IP geolocation field handling.
  • Output table formatting.

Project Layout

src/main.rs      Program entry point and workflow orchestration
src/cli.rs       CLI parsing and domain / URL host extraction
src/dns.rs       DNS resolver selection, DoH / UDP DNS queries, DNS response parsing
src/geo.rs       IP geolocation lookup and result model
src/output.rs    Table output formatting
src/redirect.rs  HTTP redirect resolution for URL inputs

Publishing

Package validation:

cargo package --list
cargo package

Publish to crates.io:

cargo publish

Make sure the repository URL, license, README, and package metadata in Cargo.toml are correct before publishing.

Caveats

  • IP geolocation is approximate and usually city-level.
  • CDN, Anycast, and geo-DNS can return different IPs from different networks.
  • UDP DNS via --dns depends on the local network, ISP, proxy, and firewall behavior.
  • DNS records may change over time.

中文说明

安装:

cargo install domaininfo

使用:

domaininfo example.com
domaininfo "https://example.com/path"

该工具用于查询域名解析到的服务器 IP,并显示 IP 地理位置和运营商信息。中文系统默认使用 AliDNS 223.5.5.5 的 DoH;其他语言环境默认使用 Google Public DNS 8.8.8.8 的 DoH。开启 TUN 模式时,默认 DoH 通常可以避免代理软件返回 198.18.0.0/15 fake-ip。

About

A Rust CLI tool that resolves a domain to its server IP addresses and prints geolocation details for each IP

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages