Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Node.js – dnsPromises.resolveSoa() Method
The dnsPromises.resolveSoa() method uses the DNS protocol to resolve the Start of Authority records (SOA Records) for the hostname. On success, the promise is resolved with the following properties
nsname
hostmaster
serial
refresh
retry
expire
minttl
Syntax
dnsPromises.resolveSoa( hostname )
Parameters
hostname - This parameter takes the input for the hostname to be resolved.
Example 1
Create a file with the name "resolveSoa.js" and copy the following code. 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');
const dnsPromises = dns.promises;
// Passing IP to find the hostname TXT records
dnsPromises.resolveSoa('tutorialspoint.com').then((response) => {
console.log("SOA Records: ", response);
})
Output
It will produce the following output −
C:\home\node>> node resolveSoa.js
SOA Records: { nsname: 'pdns13.domaincontrol.com',
hostmaster: 'dns.jomax.net',
serial: 2021051700,
refresh: 28800,
retry: 7200,
expire: 604800,
minttl: 600 }
Example 2
Let's take another example −
// dns.resolveSoa() Demo Example
// Importing the dns module
const dns = require('dns');
const dnsPromises = dns.promises;
// Setting ttl as true
const options={
ttl:true,
};
// Calling dnsPromises.resolveSoa() method asynchronously
(async function() {
const records = await dnsPromises.resolveSoa( 'google.com', options);
// Printing records
console.log("SOA Records: ", records);
})();
Output
It will produce the following output −
C:\home\node>> node resolveSoa.js
SOA Records: { nsname: 'ns1.google.com',
hostmaster: 'dns-admin.google.com',
serial: 379680302,
refresh: 900,
retry: 900,
expire: 1800,
minttl: 60 } Advertisements
