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 - dns.resolve6() Method
The dns.resolve6() method uses the DNS protocol to resolve the IPv6 addresses (AAAA records) for the hostname. The addresses argument that is passed to the callback will contain an array of IPv6 addresses.
Syntax
dns.resolve6(hostname, [options], callback)
Parameters
hostname – This parameter takes the input for the hostname to be resolved.
-
options – It can have the following options −
ttl – This 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');
// Passing a single dns to get values
dns.resolve6('tutorialspoint.com', (err, address) => console.log('address: %j', address));
Output
C:\home\node>> node resolve6.js address: undefined
Example 2
// dns.resolve6() Demo Example
// Importing the dns module
const dns = require('dns');
// Setting the ttl option as true
const options = {
ttl: true,
};
// Passing the dns address below
dns.resolve6('google.com', options, (err, address) => console.log('address: %j', address));
Output
C:\home\node>> node resolve6.js
address: [{"address":"2404:6800:4002:81d::200e","ttl":231}] Advertisements
