Node.js – dns.resolveSoa() Method

Node.jsServer Side ProgrammingProgramming

The dns.resolveSoa() method uses the DNS protocol to resolve the start of authority records for the hostname. The address argument passed to the callback function will be an object that will contain the following properties −

  • nsname
  • hostmaster
  • serial
  • refresh
  • entry
  • expire

Syntax

dns.resolveSoa(hostname, callback)

Parameters

It accepts the following parameters −

  • hostname – This parameter takes the input for the hostname to be resolved.

  • callback – This function will catch errors, if any.

    • records – Returns the start of authority records for the hostname.

Example

Create a file with the name "resolveSoa.js" and copy the following code snippet. After creating the file, use the command node "resolveSoa.js" to run this code as shown in the example below −

// dns.resolveSoa() Demo Example

// Importing the dns module
const dns = require('dns');

// Passing the argument below
dns.resolveSoa('tutorialspoint.com', (err, records) => console.log('SOA Records: %j', records));

Output

C:\home\node>> node resolveSoa.js
SOA Records: {
   "nsname":"ns-1033.awsdns-01.org",
   "hostmaster":"awsdns-hostmaster.amazon.com",
   "serial":1,
   "refresh":7200,
   "retry":900,
   "expire":1209600,
   "minttl":86400
}
raja
Published on 17-Jan-2022 11:26:39

Advertisements