You are viewing our old blog site. For latest posts, please visit us at the new space. Follow our publication there to stay updated with tech articles, tutorials, events & more.

DNS Resolution in PERL

0.00 avg. rating (0% score) - 0 votes

DNS, which stands for domain name system, controls your domain name’s website and email settings. When visitors go to your domain name, its DNS settings control which company’s server it reaches out to.

Benefits of DNS:

  1. Domain Names are alphabetic, they’re easier to remember.
  2. Capable of providing security. Companies that make use of DNS server are able to protect the company related data from being accessed by unwanted people.
  3. DNS servers are quite flexible to use. A single DNS server is capable of managing multiple Internet sub domains and domains.

How DNS resolver works? 

The client side of the DNS is called a DNS resolver. A resolver is responsible for initiating and sequencing the queries that ultimately lead to a full resolution (translation) of the resource sought, e.g., translation of a domain name into an IP address. An individual DNS query may be either non-recursive, recursive, or iterative, or a combination of these.

The resolution process starts with a query to one of the root servers. In typical operation, the root servers will not answer directly, but will respond with a referral to more authoritative servers, e.g. a query for “” will be referred to the “.com” servers. The resolver will then query the servers it finds itself referred to, and iteratively repeat this process until it receives a concrete answer. The diagram illustrates this process for the host [1]


Above mechanism would place a large traffic burden on the root servers, as every resolution on the Internet would require them. In practice caching is used in DNS servers to off-load the root servers, and as a result, root name servers actually are involved in only a fraction of all requests.

Application in Naukri:-

Every time there is any change in ip’s or port to which our databases are connected we need to replicate the change everywhere in our application and have to give fresh deployments.

So, for smooth movement of applications across servers at Naukri, or even for changes in network settings for the same server, it is imperative that we centralize the control of IP configurations at one place. DNS fulfils this requirement. With DNS there’s no need to go from PC to PC, setting up static addresses every time your network infrastructure changes.

DBI (Database Interface) is used to interact with databases in number of Applications written in Perl which accepts ip’s and ports for its connection. In php we have ‘dns_get_record’ function that provides us with required information.  However, there is no such direct function in Perl which can get this information from DNS. But, it provides us with the library NET::DNS and various functions to get ip’s and port.

How NET::DNS works?

Before knowing how this lib works we need to know about types of resource records, which are the basic information elements of the domain name system. Each record has a type (name and number), an expiration time (time to live), a class, and type-specific data.

  1.  Service record (SRV record) is a specification of data in the Domain Name System defining the location, i.e. the hostname and port number


  • Service: the symbolic name of desired service.
  • Protocol: transport protocol of desired service. e.g. TCP


  1. ‘A’ Record: The A in A record stands for Address. Simply put, an A record is used to find the address of a computer connected to the internet from a name. Whenever you visit a web site, send an email or do almost anything on the Internet, the address you enter is a series of words connected with dots. like localhost is name however is connected to an ip address

Net::DNS is a DNS resolver implemented in Perl. It allows the programmer to perform nearly any type of DNS query from a Perl script.


$res = Net::DNS::Resolver->new;

Represents Default resolver object. A program can have multiple resolver objects, each maintaining its own state information.



With the above solution, we are able to move our applications written in Perl on to DNS easily

Keep Learning!!