I'm trying to set Google DNS server 8.8.8.8
in Node.js resolve query.
What is the correct way to do so? In command line usually we can do the following:
$ nslookup stackoverflow.com 8.8.8.8
Server: 8.8.8.8
Address: 8.8.8.8#53
Non-authoritative answer:
Name: stackoverflow.com
Address: 151.101.1.69
Address: 151.101.65.69
Address: 151.101.129.69
Address: 151.101.193.69
But its not quite clear how to make same approach in Node.js
require('dns').resolve('stackoverflow.com', function (err, addresses) {
console.log(err, addresses);
});
// => null [ '151.101.1.69', '151.101.65.69', '151.101.129.69', '151.101.193.69' ]
From nodejs doc: https://nodejs.org/api/dns.html#dns_dns_setservers_servers
dns.setServers([
'4.4.4.4',
'[2001:4860:4860::8888]',
]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With