LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-07-2012, 06:36 AM   #1
karthilin
LQ Newbie
 
Registered: Sep 2012
Location: Chennai
Posts: 13

Rep: Reputation: Disabled
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?

Last edited by karthilin; 11-07-2012 at 06:39 AM.
 
Old 11-07-2012, 06:39 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
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
 
Old 11-07-2012, 07:51 AM   #3
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,159
Blog Entries: 10

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
Code:
curl icanhazip.com
 
Old 11-07-2012, 03:48 PM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
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
 
1 members found this post helpful.
Old 11-08-2012, 01:14 AM   #5
freelinuxtutorials
Member
 
Registered: Oct 2009
Posts: 70

Rep: Reputation: 21
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?
 
Old 11-08-2012, 01:37 AM   #6
karthilin
LQ Newbie
 
Registered: Sep 2012
Location: Chennai
Posts: 13

Original Poster
Rep: Reputation: Disabled
Hi freelinuxtutorials It's only for my reference and my manager asked to me.That's why I am asking this.
 
Old 11-08-2012, 01:40 AM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
As per Post#2 http://whatismyip.com sounds like what you want if want to be able to geo-locate yourself.
 
Old 11-08-2012, 02:51 AM   #8
jsaravana87
Member
 
Registered: Aug 2011
Location: Chennai,India
Distribution: Redhat,Centos,Ubuntu,Dedian
Posts: 558
Blog Entries: 5

Rep: Reputation: Disabled
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

Last edited by jsaravana87; 11-08-2012 at 02:52 AM.
 
1 members found this post helpful.
Old 11-08-2012, 03:43 AM   #9
mandyapenguin
Member
 
Registered: Nov 2011
Location: India
Distribution: RedHat, Cent OS, Fedora, Debian, Ubuntu
Posts: 106

Rep: Reputation: Disabled
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

Last edited by mandyapenguin; 11-08-2012 at 04:07 AM.
 
Old 11-08-2012, 07:36 AM   #10
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,159
Blog Entries: 10

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
Quote:
Originally Posted by mandyapenguin View Post
...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'.
 
Old 11-09-2012, 04:50 AM   #11
freelinuxtutorials
Member
 
Registered: Oct 2009
Posts: 70

Rep: Reputation: 21
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
A script is running from an unknown location.how we can find its exact location. saurav23june Linux - Newbie 5 05-15-2012 05:27 AM
[SOLVED] How to find the address location of a file? vamsi9042 Linux - Software 9 09-25-2011 12:36 PM
To Find Location Of Script aman_m03 Fedora 1 01-06-2011 09:33 AM
cant find the location of cd harshanair17 Linux - Newbie 4 08-07-2008 01:20 AM
Find location within building - something like GPS? jantman Linux - Hardware 4 03-14-2008 12:49 AM


All times are GMT -5. The time now is 06:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration