LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Find IP location (https://www.linuxquestions.org/questions/linux-newbie-8/find-ip-location-4175436049/)

karthilin 11-07-2012 05:36 AM

Find IP location
 
Hi,
I am a linuxuser I want to find my IP location,so I tried this(ipaddress or ifconfig) in command prompt .These returned
[
eth0 Link encap:Ethernet HWaddr 5c:26:0a:69:2b:e2
inet addr:192.168.29.5 Bcast:192.168.31.255 Mask:255.255.252.0
inet6 addr: fe80::5e26:aff:fe69:2be2/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1299245 errors:0 dropped:0 overruns:0 frame:0
TX packets:150147 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:438541699 (438.5 MB) TX bytes:26697520 (26.6 MB)
Interrupt:20 Memory:e6700000-e6720000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:65620 errors:0 dropped:0 overruns:0 frame:0
TX packets:65620 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:23871063 (23.8 MB) TX bytes:23871063 (23.8 MB)
]
I think inet addr:192.168.29.5 is IP address.
After I give IP address to http://www.ipligence.com/geolocation
But It returns "Invalid address or IP not found".
why?IP address is correct or not?and what is inet addr:127.0.0.1?

acid_kewpie 11-07-2012 05:39 AM

192.168.29.5 is a private IP address, there will be literally thousands and thousands of instances of that address in private networks globally. It can't have a location. Maybe you want to go to http://whatismyip.com to see what your public facing IP is..?

127.0.0.1 is the loopback interface. http://en.wikipedia.org/wiki/Loopback

Habitual 11-07-2012 06:51 AM

Code:

curl icanhazip.com

David the H. 11-07-2012 02:48 PM

As said, there are actually two ip addresses you could be interested in, the one for your internal network, and the external one that lets other computers find you.

The first is what you get from ifconfig, etc. and most commonly begins with "192.168.". The external address cannot be determined locally; you need to query an external server such as icanhazip.com, as mentioned above.


I wrote a simple script a while back that queries random servers for your external address. It's a simple procedure to add or remove server entries, but make sure they give mostly plain text output first.

Code:

#!/bin/bash

declare ip re
declare -i i xc
declare -a ipsite

#Add servers to the array here:
ipsite=(
        "http://automation.whatismyip.com/n09230945.asp"
        "http://icanhazip.com/"
        "http://wooledge.org/myip.cgi"
        "http://ifconfig.me/ip"
        "http://ipecho.net/plain"
        "http://api.externalip.net/ip/"
        "http://checkip.dyndns.org/"                #outputs a text prefix
        "http://ipogre.com/linux.php"                #outputs simple html
        "http://externalip.com/"                #outputs simple html
        #"http://www.showmyip.com/simple/"        #down as of 20120614
        #"http://cfaj.freeshell.org/ipaddr.cgi" #down as of 20121107
      )

#query random servers until you get a successful outcome
xc=1
while (( xc )) ; do
        (( i = RANDOM % ${#ipsite[@]} ))
        ip=$( wget -t 1 -T 2 -q -O- "${ipsite[i]}" )
        xc=$?
done

#some sites may include trailing newlines or extra text, so extract the ip from the output.
re='\<([[:digit:]]{1,3}([.][[:digit:]]{1,3}){3})\>'
[[ $ip =~ $re ]] && ip=${BASH_REMATCH[1]}

printf "%s" "$ip"

exit 0


freelinuxtutorials 11-08-2012 12:14 AM

127.0.0.1 is localhost
192.168.29.5 is a class C private IP (IP range from 192.168.0.0 - 192.168.255.255), meaning it's not routable to the internet. So you will not get any results on that geolocation.
Maybe can elaborate more why you need to know your IP location?

karthilin 11-08-2012 12:37 AM

Hi freelinuxtutorials It's only for my reference and my manager asked to me.That's why I am asking this.

chrism01 11-08-2012 12:40 AM

As per Post#2 http://whatismyip.com sounds like what you want if want to be able to geo-locate yourself.

jsaravana87 11-08-2012 01:51 AM

Quote:

I am a linuxuser I want to find my IP location
Since you in private address .Do the post#2.You will find your static interface ipaddress .Put the static interface in below link to find the location of your ip

http://www.ipaddresslocation.org/ip-address-locator.php

mandyapenguin 11-08-2012 02:43 AM

ifconfig shows the (private)IPs assigned to your PC. You can also use below commands to find out your public IP(which is given by ISP).
Code:

lynx -dump http://whatismyip.com | grep "Your IP Address Is:"
lynx -dump http://cfaj.freeshell.org/ipaddr.cgi
curl icanhazip.com

etc, etc, etc........

find your public IP location from this link

Habitual 11-08-2012 06:36 AM

Quote:

Originally Posted by mandyapenguin (Post 4824780)
...find your public IP location from this link

Love it. :)
It's a little smoke-and-mirrors but it's more-or-less kind of accurate. You know how data 'goes'. :)

freelinuxtutorials 11-09-2012 03:50 AM

if your LAN is in NAT, then if you want to know your public IP. you can try ping.eu. It will show you your public IP and proxy address if your ISP uses cache mechanism


All times are GMT -5. The time now is 12:40 AM.