Hi there, I'm Marcos!

📇 Checking DNS records in Node

const dns = require('dns').promises;

// Resolve IPv4 record
dns.resolve4('google.com').then((record) => console.log(addr));
// This logs [ '172.217.168.174' ]

// Resolve IPv6 record
dns.resolve6('google.com').then((record) => console.log(addr));
// This logs [ '2a00:1450:4003:808::200e' ]

This is how you can resolve the DNS of a website and get the IP address under which the page rests. Node provides the dns module and in this example we are using the promises implementation so we don't have to pass callbacks to the functions.

Here we show the resolve4 function to get the IPv4 addresses and the resolve6 for the IPv6 addresses. With this module you can resolve all type of DNS records like cname, mx or txt.