node-dhcp
node-dhcp copied to clipboard
Detect when local IP change
Hello everyone,
Is there any way to detect that the local IP Address has changed? Let's suppose that machine's IP is 192.168.150.5 and somehow the machine receives another IP and now has 192.168.150.6 from DHCP. Is there any listener which 'listens' that kind of changes?
-I have set up ONLY a dhcp client (from DHCP module) -and not a dhcp server from the module - and I receive IPs from default DCHP(router's).
Is there any way to achieve that??
Thanks in advance
You can sniff the DHCP messages and compare the assigned ip address
var dhcp = require('../lib/dhcp.js');
var s = dhcp.createBroadcastHandler();
s.on('message', function (data) {
// compare ip address for mac...
});
s.listen();