Home > OS >  Use ReactJS to get IP inside VPN
Use ReactJS to get IP inside VPN

Time:04-27

I got some client computers inside a VPN network who, when calling a ReactJS website, should get different data depending on their IP address (static IP from VPN).

So the problem is, I can not use 3rd Party services like ipinfo since they do not have internet access. My question is, is there a "local" option to do get the IP or some other ID that uniquely identifies the client in the VPN that calls the ReactJS. I looked at the webRTC option: https://ourcodeworld.com/articles/read/257/how-to-get-the-client-ip-address-with-javascript-only but is seems that this is not working (at least not in Fiddler)

I am happy for any clue or ides

CodePudding user response:

ReactJS is just a User-Interface-JavaScript-Library. So in the end you could use everything the JavaScript-Ecosystem provides you with. Unfortunately there is no API-call to get the local ip-address with just JavaScript.

The WebRTC-method of obtaining the IP-address was actually considered leaking the IP-adress. For that reason, the IP-address is now being obfuscated when trying to get the local-ip-lookup with POCs like this. If you have full control over the computers in question you can explicitly turn off this obfuscation in the chrome browser.

  1. Open chrome://flags
  2. Set Anonymize local IPs exposed by WebRTC to false

Another approach could be to host an own "whats-my-ip"-Lookup-Server on the same network. There are a couple of docker-images available in the docker-hub for that purpose. Like this one, this one or this one. You could then query the local-network-docker-container instead of an actual third-party-service.

  • Related