https://github.com/taketo1113/ddig
DNS lookup utility for Ruby
https://github.com/taketo1113/ddig
ddr dns doh dot ruby
Last synced: 5 months ago
JSON representation
DNS lookup utility for Ruby
- Host: GitHub
- URL: https://github.com/taketo1113/ddig
- Owner: taketo1113
- License: mit
- Created: 2024-01-17T08:48:58.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-08-03T06:44:49.000Z (10 months ago)
- Last Synced: 2024-12-13T00:31:59.073Z (5 months ago)
- Topics: ddr, dns, doh, dot, ruby
- Language: Ruby
- Homepage:
- Size: 63.5 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# ddig
ddig is DNS lookup utility for Ruby.
## Features
- DNS Resolvers
- UDP (Do53)
- DoT (DNS over TLS)
- https://www.rfc-editor.org/rfc/rfc7858.html
- DoH (DNS over HTTPS)
- Support only HTTP/1.1
- https://www.rfc-editor.org/rfc/rfc8484.html
- ~~DoQ (DNS over QUIC)~~
- Not Supported
- https://www.rfc-editor.org/rfc/rfc9250.html
- DDR (Discovery of Designated Resolvers)
- https://www.rfc-editor.org/rfc/rfc9462.html## Installation
Install the gem and add to the application's Gemfile by executing:
$ bundle add ddig
If bundler is not being used to manage dependencies, install the gem by executing:
$ gem install ddig
## Usage
### Ruby```ruby
ddig = Ddig.lookup('dns.google', nameservers: ['8.8.8.8', '2001:4860:4860::8888'])ddig[:do53][:ipv4]
=> #
ddig[:do53][:ipv6]
=> #ddig[:ddr]
=> [#>,
#>,
...
]
```- Do53
```ruby
do53 = Ddig::Resolver::Do53.new(hostname: 'dns.google', nameservers: '8.8.8.8').lookup
=> #, @nameservers=["8.8.8.8"]>do53.a
=> ["8.8.4.4", "8.8.8.8"]
do53.aaaa
=> ["2001:4860:4860::8844", "2001:4860:4860::8888"]
```- DoT
```ruby
dot = Ddig::Resolver::Dot.new(hostname: 'dns.google', server: '8.8.8.8').lookup
=> #dot.a
=> ["8.8.4.4", "8.8.8.8"]
dot.aaaa
=> ["2001:4860:4860::8844", "2001:4860:4860::8888"]
```- DoH (HTTP/1.1)
```ruby
doh = Ddig::Resolver::DohH1.new(hostname: 'dns.google', server: 'dns.google', dohpath: '/dns-query{?dns}').lookup
=> #doh.a
=> ["8.8.4.4", "8.8.8.8"]
doh.aaaa
=> ["2001:4860:4860::8844", "2001:4860:4860::8888"]
```### CLI
- Usage
```
$ ddig --help
Usage: ddig [options] hostname
-d, --dns-type={all|do53|dot} resolve type (default: all)
--udp use resolve type of udp(do53)
--dot use resolve type of dot
--doh-h1 use resolve type of doh (http/1.1)
--doh-path=doh-path doh service path
--ddr discover designated resolvers via ddr (discovery of designated resolvers)
-4, --ipv4 use IPv4 query transport only
-6, --ipv6 use IPv6 query transport only
-@ipaddress|doh-hostname, nameserver
--nameserver
-p, --port=port port
--format={text|json} output format (default: text)-v, --verbose run verbosely
-h, --help show this help message.
--version show version.
``````sh
$ ddig --nameserver 8.8.8.8 dns.google
# Do53 (IPv4)
dns.google A 8.8.4.4
dns.google A 8.8.8.8
dns.google AAAA 2001:4860:4860::8844
dns.google AAAA 2001:4860:4860::8888# SERVER: 8.8.8.8
# DDR
## DDR (#0) - dot: dns.google:853 (8.8.4.4), unencrypted_resolver: 8.8.8.8, verify cert: true
dns.google A 8.8.4.4
dns.google A 8.8.8.8
dns.google AAAA 2001:4860:4860::8844
dns.google AAAA 2001:4860:4860::8888# SERVER(Address): 8.8.4.4
# PORT: 853...
# SERVER(Address): 2001:4860:4860::8888
# PORT: 853## DDR (#6) - h2: dns.google:443 (2001:4860:4860::8888), path: /dns-query{?dns}, unencrypted_resolver: 8.8.8.8, verify cert: true
dns.google A 8.8.8.8
dns.google A 8.8.4.4
dns.google AAAA 2001:4860:4860::8844
dns.google AAAA 2001:4860:4860::8888# SERVER(Hostname): 2001:4860:4860::8888
# SERVER(Path): /dns-query{?dns}
# PORT: 443
...
```- UDP(Do53)
```sh
$ ddig --udp --nameserver 8.8.8.8 dns.google
dns.google A 8.8.8.8
dns.google A 8.8.4.4
dns.google AAAA 2001:4860:4860::8844
dns.google AAAA 2001:4860:4860::8888# SERVER: 8.8.8.8
```- DoT
```sh
$ ddig --dot --nameserver 8.8.8.8 dns.google
dns.google A 8.8.8.8
dns.google A 8.8.4.4
dns.google AAAA 2001:4860:4860::8888
dns.google AAAA 2001:4860:4860::8844# SERVER(Address): 8.8.8.8
# PORT: 853
```- DoH (HTTP/1.1)
```sh
$ ddig --doh-h1 --nameserver dns.google --doh-path /dns-query{?dns} dns.google
dns.google A 8.8.8.8
dns.google A 8.8.4.4
dns.google AAAA 2001:4860:4860::8888
dns.google AAAA 2001:4860:4860::8844# SERVER(Hostname): dns.google
# SERVER(Path): /dns-query{?dns}
# PORT: 443
```- DDR (Discovery of Designated Resolvers)
```sh
$ ddig --ddr --nameserver 8.8.8.8
dot: dns.google:853 (8.8.8.8), unencrypted_resolver: 8.8.8.8, verify cert: true
dot: dns.google:853 (8.8.4.4), unencrypted_resolver: 8.8.8.8, verify cert: true
dot: dns.google:853 (2001:4860:4860::8844), unencrypted_resolver: 8.8.8.8, verify cert: true
dot: dns.google:853 (2001:4860:4860::8888), unencrypted_resolver: 8.8.8.8, verify cert: true
h2: dns.google:443 (8.8.8.8), path: /dns-query{?dns}, unencrypted_resolver: 8.8.8.8, verify cert: true
h2: dns.google:443 (8.8.4.4), path: /dns-query{?dns}, unencrypted_resolver: 8.8.8.8, verify cert: true
h2: dns.google:443 (2001:4860:4860::8844), path: /dns-query{?dns}, unencrypted_resolver: 8.8.8.8, verify cert: true
h2: dns.google:443 (2001:4860:4860::8888), path: /dns-query{?dns}, unencrypted_resolver: 8.8.8.8, verify cert: true
h3: dns.google:443 (8.8.4.4), path: /dns-query{?dns}, unencrypted_resolver: 8.8.8.8, verify cert: true
h3: dns.google:443 (8.8.8.8), path: /dns-query{?dns}, unencrypted_resolver: 8.8.8.8, verify cert: true
h3: dns.google:443 (2001:4860:4860::8888), path: /dns-query{?dns}, unencrypted_resolver: 8.8.8.8, verify cert: true
h3: dns.google:443 (2001:4860:4860::8844), path: /dns-query{?dns}, unencrypted_resolver: 8.8.8.8, verify cert: true# SERVER: 8.8.8.8
```## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/taketo1113/ddig.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).