How to find out the internal IP?

4

I'm looking for a solution to know the% internal% of a machine.

The idea is that through a website, when the user accesses it, find out what the internal ip of it, and then search all other ip , and find which machine has an application installed. / p>

So far you can do this with RTCPeerConnection but it does not work on all browsers.

    
asked by anonymous 23.01.2014 / 10:43

3 answers

2

An answer to this has been posted to User StackOverflow in English nodyou : link

var os=require('os');
var ifaces=os.networkInterfaces();
for (var dev in ifaces) {
  var alias=0;
  ifaces[dev].forEach(function(details){
    if (details.family=='IPv4') {
      console.log(dev+(alias?':'+alias:''),details.address);
      ++alias;
    }
  });
}

If more details are needed, the documentation is at link

    
23.01.2014 / 15:14
0

Michel Melo says his client will have "a machine with a server". In this case, it means that, for example, you have a WAMP or a MAMP on the machine. Using this server, locally, the client will put data, using client software (for example Firefox) Example: Main site with Linux is a web server Local site with WAMP Client using Firefox in WAMP

Michel's problem does not seem to be "As my Linux server will know the user's IP address of Firefox", because its user will not connect in Linux. Michel's problem is "How my Linux server can know the IP of the WAMP server that will connect". And this?

If this is the answer, it can not be "Uses JS" because WAMP will not use JS.

The other problem is that if the client's internet connection is disturbed, your local network may receive another IP address. And in this case, the client's "server" will not be recognized by the "global" server anymore.

By analyzing this, I think the best option is to transmit a connection code to the local server. And every time this local server will connect in the "global" served, it will transmit the code. IP does not seem to be a reliable enough option.

    
07.10.2014 / 16:26
0
var object_ip = function(){
    return new Promise( function( resolve, reject ){
        let Ips = {};
        let counter = 1;
        let os=require('os');
        let ifaces=os.networkInterfaces();
        for( let i = 0; i < Object.keys(ifaces).length; i++){
            ifaces[Object.keys(ifaces)[i]].forEach(el=>{
                if(!!el.address){
                    Ips['Ipv'+counter.toString()] = el.address;
                    counter++;
                }
            })
        }

        if(!!Object.keys(Ips).length){
            resolve(Ips);
        }else{
            reject("Dont Have IP");
        }
    })
}

object_ip()

    .then( function(result){ 
        console.log(result); 
    })
    .catch( function(error){ 
        console.error(error);
    })
    
08.01.2019 / 18:46