- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Node.js - dnsPromises.resolve6() Method
The dnsPromises.resolve6() method uses the DNS protocol to resolve the IPv6 addresses (AAAA records) for the hostname. The promise is resolved with an array of IPv6 addresses.
Syntax
dns.resolve6(hostname, [options])
Parameters
hostname – This parameter takes input for hostname to be resolved.
options – It can have the following options −
ttl – It defines the Time-To-Live (TTL) for each record.
Example 1
Create a file with the name "resolve6.js" and copy the following code snippet. After creating the file, use the command "node resolve6.js" to run this code as shown in the example below −
// dns.resolve6() Demo Example // Importing the dns module const dns = require('dns'); const dnsPromises = dns.promises; // Passing a single dns to get values dnsPromises.resolve6('tutorialspoint.com').then((response) => { console.log("Resolved address is:", response); })
Output
C:\home
ode>> node resolve6.js Resolved address is: undefined
Example 2
// dns.resolve6() Demo Example // Importing the dns module const dns = require('dns'); const dnsPromises = dns.promises; // Setting ttl as true const options={ ttl:true, }; // Calling dnsPromises.resolve6() method // asynchronously (async function() { const records = await dnsPromises.resolve6('google.com', options); // Printing records console.log(records); })();
Output
C:\home
ode>> node resolve6.js [ { address: '2404:6800:4002:81d::200e', ttl: 30 } ]
Advertisements