You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is so easy, first get all interface, then follow code below:
constos=require('os');constip=require('ip');// it gives you array of interfaces,// you can pick the name of that interface you wanna get IP addressconsole.log(os.networkInterfaces());ip.address("_interfaceName","ipv4")// you can now obtain the interface IP address you wanted.
or easiest way is get all your interface by this command ifconfig then find the interface that point your IP target, after all easily put that interface name in the ip.address() function. ex:
ip.address("docker")// orip.address("Wi-Fi")
it is better mention here that ip.address() retrive first interface public ip version 4 address and some time is some think like 127.0.0.1;
I am using Arch Linux, I need to retrieve the network interface ip, like 192.168.0.14.
Thanks.
The text was updated successfully, but these errors were encountered: