Query DNS Server with Ruby
DNS (Domain Name System) is ubiquitous to any website or application operating over the internet, as people find it easier to remember the website by the domain names rather than their IP addresses. The DNS system can store data for a variety of services for a domain like MX (Mail Exchanger record) which specifies the servers that'd be handling the mails for this domain, SRV (Service record) which holds the definitions for the hostnames & ports for specific services for a specific domain, and most import & frequently used is the A (Address record) which host the destination IP address for any hostname.
In this article we will see how to query DNS servers for various DNS records using Ruby, for which we'll be look at 2 Ruby gems namely Resolv & dnsruby.
Resolv is a thread-safe Ruby gem which can query DNS for all known record types, let us look at the code snippet below to get a working idea of the gem & it's methods.
DNS Ruby is very similar to Resolv, but it gives a complete DNS implementation including DNSSEC (Domain Name System Security Extensions) using which you can validate the response so that the response can be authenticated.
|All times are GMT +5.5. The time now is 17:39.|