1

I am new to Node.js and using the node.js I want to get the DNS server IP address of my connected interface.During searching I got on the node.js documentation that the 'DNS' module can be used for it and its function

dns.getServers() will return the address,

dns.setServers(servers) will set it.

when I call these functions and check it on console I show correct result but my problem is that I want to update it on the network interface setting in my Desktop PC system preference settings.

I also search that for getting the interfaces information in node.js,the 'OS' Module will be used and its function os.networkInterfaces()gives the interface details.

I think that there should be relation between these two modules to update the DNS server address to the interface.

Is it possible to do it or am I using a wrong approach.. please give some guidance and help.

Thanks

  • problems: 1 - `dns.getServers` gets a list of servers being used for name resolution, has nothing to do with YOUR address. 2 - your network interface may be a private IP address, so DNS lookup wont help – Jaromanda X Jan 25 '16 at 07:49
  • So Is there any other way to get the DNS Server address of my network interface like LAN using node.js ?? –  Jan 25 '16 at 07:57
  • are you looking for an IP address of the network interface? - http://stackoverflow.com/questions/3653065/get-local-ip-address-in-node-js – Jaromanda X Jan 25 '16 at 08:03
  • i just want to get the DNS server address set on the specific connected interface and update it.like I have two interface one is LAN and other is Wifi then both interface have different DNS server address.I want to access them and get them and update them –  Jan 25 '16 at 08:13
  • your terminology confuses me ... it's probably my problem, you're probably saying things that make perfect sense, I just don't get it – Jaromanda X Jan 25 '16 at 08:18
  • @TSiddiqui dns.setServers(servers) will set the IP addresses of the servers to be used when resolving, but it does not affect OS settings. And, as far as I can see, all of the 'OS' module functions are read-only, so you can not change OS settings with them. – Dusan Bajic Jan 25 '16 at 10:58
  • @dusan.bajic thanks very much :) –  Feb 08 '16 at 10:00

1 Answers1

0

You will need to update the DNS of your network interface through the OS rather than Node.js

Any variables set in Node.js will not persist outside of that environment.

ZZ9
  • 2,177
  • 2
  • 27
  • 38
  • I want to do it programmatically and I already did it using objective c but I want to do it through node.js if it is possible –  Feb 01 '16 at 13:56