Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello guys

I am trying to get Local IpAddress using following

$.getJSON("http://jsonip.com/?callback=?", function (data) {
Ip = data.ip;
});

using Jquery and i get Ipaddress
but the thing is that this ipaddress is different from the Ipaddress i got in CMD using
command ipconfig.i want same ipaddress which i get in cmd

please help me in that

Thanks in Advance

What I have tried:

$.getJSON("http://jsonip.com/?callback=?", function (data) {
Ip = data.ip;
});
Posted
Updated 23-May-18 23:41pm

1 solution

Correct.
What you think of as "the IP Address" depends on where you are asking.
The address you get with IPCONFIG is the local network address, and will (almost certainly) be "192.168.xxx.yyy"
The address you get by querying the internet is the IP Address of the router which connections your network to the internet, and will never, ever, start with "192.168" as that is absolutely reserved for local network segments.

And the internet IP address is not the address of the computer you are querying from: it is the address of the router, and is shared by all devices using the same internet connection.
 
Share this answer
 
Comments
hardy panchal 24-May-18 5:54am    
so getting Ipaddress using
$.getJSON("http://jsonip.com/?callback=?", function (data) {
Ip = data.ip;
});

it will give correct ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900