The setServers() function is an inbuilt function in node.js Resolver class which is used to set the IP address and port of servers to be used when performing DNS resolution. The argument of the servers is an array of RFC 5952 formatted addresses. An error will be thrown if an invalid address is provided with the help of the callback function.
dns.setServers([ '18.104.22.168', '[2001:4860:4860::8888]' ]);
Parameters:This function accept one parameter as an array string of format rfc5952.
Return Value: This function returns undefined object on success.
Example 1: With Callback function
Example 2: Without Callback Function
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.