https://github.com/blackstar257/dug
A modern DNS lookup utility written in Rust that serves as a drop-in replacement for the traditional dig command.
https://github.com/blackstar257/dug
cli dig dns dug rust
Last synced: about 2 months ago
JSON representation
A modern DNS lookup utility written in Rust that serves as a drop-in replacement for the traditional dig command.
- Host: GitHub
- URL: https://github.com/blackstar257/dug
- Owner: blackstar257
- License: mit
- Created: 2025-06-08T04:17:12.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2026-02-03T19:32:16.000Z (5 months ago)
- Last Synced: 2026-04-30T06:43:52.617Z (about 2 months ago)
- Topics: cli, dig, dns, dug, rust
- Language: Rust
- Homepage:
- Size: 94.7 KB
- Stars: 0
- Watchers: 0
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DUG - DNS Lookup Utility
[](https://www.rust-lang.org)
[](https://opensource.org/licenses/MIT)
[](https://github.com/blackstar257/dug/actions)
A modern DNS lookup utility written in Rust that serves as a drop-in replacement for the traditional `dig` command. DUG provides fast, reliable DNS queries with a familiar interface and enhanced features.
## ๐ Features
- **Full `dig` compatibility**: Supports the same command-line interface and output format
- **Multiple record types**: A, AAAA, MX, NS, SOA, TXT, CNAME, PTR, SRV, CAA, and more
- **Query classes**: IN (Internet), CH (Chaos), HS (Hesiod)
- **Advanced querying**:
- Trace queries (`+trace`) for step-by-step resolution
- Reverse DNS lookups (`-x`)
- Batch file processing (`-f`)
- TCP and UDP support
- **Flexible output**:
- Short format (`+short`)
- Customizable section display
- Colored output for better readability
- **Network options**:
- IPv4/IPv6 preference
- Custom timeouts and retry logic
- Source address binding
- **Performance**: Built with Rust for speed and memory safety
- **Cross-platform**: Works on Linux, macOS, and Windows
## ๐ฆ Installation
### From Source
```bash
# Clone the repository
git clone https://github.com/blackstar257/dug.git
cd dug
# Build and install
cargo build --release
cargo install --path .
```
### Using Cargo
```bash
cargo install dug
```
### Pre-built Binaries
Download the latest release from the [releases page](https://github.com/blackstar257/dug/releases).
## ๐ง Usage
### Basic Queries
```bash
# Query A record for a domain
dug example.com
# Query specific record type
dug example.com MX
# Query with specific DNS server
dug @8.8.8.8 example.com
# Short output format
dug +short example.com
```
### Advanced Queries
```bash
# Trace query path
dug +trace example.com
# Reverse DNS lookup
dug -x 8.8.8.8
# TCP query
dug +tcp example.com
# Query with timeout
dug +time=10 example.com
# IPv6 only
dug -6 example.com AAAA
```
### Batch Processing
```bash
# Process multiple queries from file
dug -f queries.txt
```
Example `queries.txt`:
```
example.com A
google.com MX
@8.8.8.8 cloudflare.com
+short reddit.com
```
### Output Control
```bash
# Hide specific sections
dug +noquestion +noauthority example.com
# Show only answers
dug +noall +answer example.com
# Disable comments
dug +nocomments example.com
```
## ๐ Command Line Options
### Flags
| Flag | Description |
|------|-------------|
| `-4` | Use IPv4 only |
| `-6` | Use IPv6 only |
| `-b ADDRESS` | Set source IP address |
| `-c CLASS` | Set query class (IN, CH, HS) |
| `-f FILENAME` | Read queries from batch file |
| `-h` | Show help information |
| `-k FILENAME` | TSIG key file |
| `-p PORT` | Set port number |
| `-q NAME` | Set query name |
| `-t TYPE` | Set query type |
| `-x ADDR` | Reverse lookup |
| `-y KEY` | TSIG key |
### Query Options
| Option | Description |
|--------|-------------|
| `+[no]tcp` | Use TCP instead of UDP |
| `+[no]short` | Short output format |
| `+[no]trace` | Trace delegation path |
| `+[no]recurse` | Enable/disable recursion |
| `+[no]dnssec` | Request DNSSEC validation |
| `+[no]question` | Show/hide question section |
| `+[no]answer` | Show/hide answer section |
| `+[no]authority` | Show/hide authority section |
| `+[no]additional` | Show/hide additional section |
| `+[no]stats` | Show/hide query statistics |
| `+[no]cmd` | Show/hide command line |
| `+[no]comments` | Show/hide comment lines |
| `+time=N` | Set timeout in seconds |
| `+tries=N` | Set number of tries |
| `+retry=N` | Set number of retries |
## ๐ Examples
### Common DNS Queries
```bash
# Check if a website is accessible
dug +short example.com A
# Find mail servers
dug example.com MX
# Check nameservers
dug example.com NS
# Get all DNS records
dug example.com ANY
# Check reverse DNS
dug -x 192.168.1.1
```
### Troubleshooting DNS
```bash
# Trace full resolution path
dug +trace example.com
# Check specific DNS server response
dug @1.1.1.1 example.com
# Test with TCP (useful for large responses)
dug +tcp example.com TXT
# Check DNSSEC validation
dug +dnssec example.com
```
## ๐ ๏ธ Development
### Prerequisites
- Rust 1.70 or later
- Cargo
### Building
```bash
git clone https://github.com/blackstar257/dug.git
cd dug
cargo build
```
### Testing
```bash
cargo test
```
### Contributing
1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
### Code Style
This project uses standard Rust formatting. Run the following before submitting:
```bash
cargo fmt
cargo clippy
```
## ๐ Dependencies
- **trust-dns-resolver**: DNS resolution library
- **trust-dns-proto**: DNS protocol implementation
- **clap**: Command-line argument parsing
- **tokio**: Async runtime
- **anyhow**: Error handling
- **chrono**: Date and time handling
- **colored**: Terminal output coloring
## ๐ Comparison with `dig`
| Feature | dig | dug | Notes |
|---------|-----|-----|-------|
| Basic queries | โ
| โ
| Full compatibility |
| Record types | โ
| โ
| All common types supported |
| Trace queries | โ
| โ
| Step-by-step resolution |
| Batch files | โ
| โ
| Process multiple queries |
| Output formats | โ
| โ
| Short and full formats |
| Performance | โก | โกโก | Rust provides better performance |
| Memory usage | ๐ | ๐ | Lower memory footprint |
| Cross-platform | โ
| โ
| Works on all major platforms |
## ๐ Known Issues
- AXFR (zone transfer) queries are not yet implemented
- Some advanced TSIG features are in development
## ๐ License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## ๐ Acknowledgments
- Inspired by the original `dig` utility from ISC BIND
- Built with the excellent Rust DNS libraries from the trust-dns project
- Thanks to the Rust community for their amazing ecosystem
## ๐ Support
- ๐ **Bug Reports**: [Issues](https://github.com/blackstar257/dug/issues)
- ๐ก **Feature Requests**: [Discussions](https://github.com/blackstar257/dug/discussions)
- ๐ง **Email**: your-email@example.com
---
**DUG** - Making DNS queries fast, reliable, and modern with Rust ๐ฆ