Project

dnslookup

0.0
Low commit activity in last 3 years
A long-lived project that still receives updates
A Ruby CLI tool to query DNS records from multiple public or custom name servers, providing fast and flexible DNS lookups.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

dnslookup — A simple Ruby CLI tool for querying DNS records

License: MIT Ruby Issues Last Commit Gem Version

dnslookup is a Ruby CLI for querying A, MX, CNAME, and TXT records from default or custom DNS servers. It wraps dig with a small command-line interface that is useful for quick troubleshooting, scripting, and day-to-day DNS checks.

Please use GitHub Issues to report bugs.

Requirements

  • Ruby 3.0 or newer
  • The dig executable available on your PATH

If dig is not already installed, common package names are:

brew install bind
sudo apt-get install dnsutils

Installation

To add dnslookup to an existing project, add this line to your project's Gemfile:

gem 'dnslookup'

And then execute:

bundle install

Or to install the CLI locally:

gem install dnslookup

Usage

Lookup DNS records for a domain:

dnslookup example.com -a

If you omit a record-type option, dnslookup queries A records by default:

dnslookup example.com

By default, dnslookup queries Google's public resolvers: 8.8.8.8 and 8.8.4.4. Use -s to query a specific resolver.

Options

Option Description
-m, --mx Return only MX records
-a, --aname Return only A records
-c, --cname Return only CNAME records
-t, --txt Return only TXT records
-A, --all Return A, MX, CNAME, and TXT records
-s, --server=IP Query a specific name server IP
-h, --help Show help message
-v, --version Show gem version

Examples

Lookup the default A record:

dnslookup example.com

Lookup a CNAME record explicitly:

dnslookup ftp.victorkeenan.com -c

Query a specific name server:

dnslookup example.com -a -s1.1.1.1

Query all supported record types at once:

dnslookup example.com --all

If dig cannot complete the lookup, dnslookup reports the query as failed instead of showing an empty result:

dnslookup example.com -a -s203.0.113.53

Depending on the failure, the output will include either (query failed) or (query failed: ...).

Help with usage and options:

dnslookup -h

Contributing

Bug reports and pull requests are welcome on GitHub. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the terms specified in the CODE OF CONDUCT.

License

dnslookup is copyright © 2016-2026 Victor S. Keenan. It is free software and may be redistributed under the terms specified in the LICENSE file.

Coded With Love

Code crafted by me, Victor S. Keenan. Find me on Twitter @VictorSK or hire me to design, develop, and grow your product or service.