Node.js – dns.resolveSoa() Method


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
ode>> 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 }

Updated on: 17-Jan-2022

55 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements