node-dhcp icon indicating copy to clipboard operation
node-dhcp copied to clipboard

Detect when local IP change

Open fpasxos opened this issue 7 years ago • 1 comments

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

fpasxos avatar Apr 04 '18 14:04 fpasxos

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();

mStirner avatar Mar 28 '19 12:03 mStirner