Skip to content

ciccio0476/dns-reverse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dns-reverse

A simple Go utility for performing reverse DNS (PTR) lookups, both in single and batch mode.

Features

  • Single IP lookup: dns-reverse <ip> [dns-server]
  • Batch mode: Process a file of IP addresses (plain text or CSV) and output results to CSV.
  • Custom DNS server: Specify an alternative DNS server for lookups.
  • Configurable timeout: Set the timeout for each DNS query.
  • Parallel processing: Batch mode uses a worker pool for concurrent lookups (configurable number of workers).
  • Verbose output: Optional logging for debugging.
  • Version information: Print the version with -version.
  • Robust input handling: Accepts plain text (one IP per line) or CSV (first column), ignores empty lines and comments (lines starting with #).

Installation

go install github.com/yourusername/dns-reverse@latest

Or build from source:

go build -o dns-reverse

Usage

Single Mode

dns-reverse 8.8.8.8
dns-reverse 8.8.8.8 8.8.4.4   # Use 8.8.4.4 as the DNS server

Batch Mode

dns-reverse -batch -i input.txt -o output.csv
dns-reverse -batch -i input.txt -o output.csv -s 1.1.1.1 -w 20 -t 30s

Input File Formats

The tool automatically detects the format based on file extension:

  • .csv files are parsed as CSV (first column = IP)
  • All other files are treated as plain text (one IP per line)

Plain text (examples/example_ips.txt):

8.8.8.8
8.8.4.4
1.1.1.1

CSV (examples/example_ips.csv):

IP,Description
8.8.8.8,Google Public DNS
8.8.4.4,Google Public DNS Secondary

Lines starting with # are treated as comments and ignored. Empty lines are also ignored.

Output CSV

The output CSV always has three columns:

  • IP: The input IP address.
  • Hostname: The PTR record(s) found, separated by ; if multiple.
  • Status: OK for success, No hostname if no PTR record, or Error: <description> for failures.

Flags

Flag Description Default
-batch Run in batch mode (requires -i and -o) false
-i Input file path (batch mode) ""
-o Output file path (batch mode) ""
-s Custom DNS server (IP address) "" (system default)
-t Timeout for each DNS query (e.g., 30s, 1m30s) 10s
-w Number of concurrent workers (batch mode) 10
-v Verbose output (logs progress and debug info) false
-version Print version and exit false

Examples

Single lookup with custom DNS and timeout

dns-reverse -t 5s 9.9.9.9 8.8.8.8

Batch processing with 15 workers and verbose logging

dns-reverse -batch -i ips.csv -o results.csv -w 15 -v

Using example files

# Using plain text input
dns-reverse -batch -i examples/example_ips.txt -o examples/output.csv

# Using CSV input
dns-reverse -batch -i examples/example_ips.csv -o examples/output.csv

See the examples/ directory for sample input files:

  • example_ips.txt - Plain text format
  • example_ips.csv - CSV format
  • example_output.csv - Expected output format

Testing

Run the unit tests:

go test ./...

License

MIT

About

Programma Go per eseguire reverse DNS lookup

Resources

Stars

Watchers

Forks

Contributors

Languages