Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Use ReactJS to get IP inside VPN

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading