Closed richard-fairthorne closed 7 months ago
I was able to correctly get the address of the primary interface using your module like this:
const defaultGateway = require('default-gateway');
const gw = defaultGateway.v4.sync();
const address = require('address');
const ip = address.ip(gw.interface);
This should be cross platform. Not sure if I'll have time to adjust and make a pull request, but that would handle it.
no activity
This may be considered an enhancement on linux and osx, but a bug on windows.
On windows, address.ip returns the address of my docker interface instead of my default interface (which is a wifi interface).
I would like to suggest that it should, on all platforms, prefer the interface which has the default route, as that is the default interface.
On windows, route print provides the details -- the interface, it's mac address, name, and ip address.
It will always be the interface address listed by route print 0.0.0.0 on Windows.
On mac, I get it in two commands:
On linux: