Get Users Local LAN IP address using php, JavaScript, ASP.net

local ip address

How to GET Local LAN IP Address of user using PHP, Javascript, ASP.net. I have also written a blog how to get real public IP of user, but my current Application is intranet based so public IP for all clients is same that is
So that is not enough to trace different activities by public IP, So we have to get Local IP. luckly WebRTC extension of HTML5 give us access to get User’s local IP address using javascript.

But how can we get this Local IP at server side at (PHP, ASP.net etc)

It is easy, just create hidden input in form and using JavaScript on pageload get IP and feed into that hidden input. that will be submitted with form to PHP or ASP.net

Step 1: Hidden Input

Create hidden input in form with id=”localIP” and name=”localIP” as shown in below form

Step 2: JavaScript Code

This is actual code which gives us the Local LAN IP Address of users, and feed it in above hidden input

Now as soon someone open this page, hidden input will get Local LAN IP Address of that user. on form submission it will be sent to server side (PHP/ASP.net)

Step 3: Process at Server-side

here i will just show getting this IP only using PHP, ASP.net and other languages will also have same easy process

This is all done, i think it was easy and I hope you will not have any issue to implement this in your own project(s).
at anytime if you need help you can write comment, i will try my best to help you out.


    Write a Reply or Comment

    Your email address will not be published. Required fields are marked *