Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 11-12-2004, 10:24 PM   #1
LQ Newbie
Registered: Jun 2003
Distribution: Vector 4.3
Posts: 2

Rep: Reputation: 0
Command to find my IP address?

Is there a command I can use in the terminal to find out what IP address I have been assigned by my ISP? ifconfig only gives me the IP of my computer on the local network (assigned by my router, I guess). I am hoping to use it in a shell script. Sorry if my question is unclear, I don't know much about networks.

Thanks for your help!
Old 11-12-2004, 10:37 PM   #2
LQ Guru
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Rep: Reputation: 58
hi there

what i now is that


will show u the ip addresss of all ur network devices

also try for
ifconfig <name of ur modem device>

Old 11-13-2004, 02:14 AM   #3
Registered: Oct 2003
Distribution: Slackware
Posts: 388

Rep: Reputation: 30
I don't think there is any command that directly finds the internet ip address of a machine behind a connections sharing system. It does not know what it's internet ip is.

The only portable way to find out the ip of a machine behind a NAT router from that machine is to make a connection to a machine out on the internet that will tell you what ip it sees the connection coming from.

There are a few websites like but they may give an incorrect result if you are using an http proxy or your ISP hijacks all port 80 connections and forces them through a transparent proxy.

The easiest option is to get a dynamic dns domain name like
You need a small piece of software running all the time to update the record when your ip changes.
Old 11-13-2004, 05:21 AM   #4
Registered: Sep 2004
Location: Texas, USA
Distribution: Fedora
Posts: 620

Rep: Reputation: 31
I'm sure there is a better way (I'm not a sed expert), but the following should get you started in the right direction:
[root@voyager scowles]# cat foo
MY_EXT_IP=`wget -q -O - | grep "Your IP is" | \
sed 's/<h1>Your IP is //' | sed 's/ <br><\/h1>//'`
echo $MY_EXT_IP

[root@voyager scowles]# ./foo
Old 11-13-2004, 09:58 AM   #5
LQ Newbie
Registered: Jun 2003
Distribution: Vector 4.3
Posts: 2

Original Poster
Rep: Reputation: 0
Wow! Three replies in no time. Thanks everyone. Dyndns looks interesting and may be the best for what I want, but I haven't quite got my head around it yet. What I am trying to do is put together a little script to check if my WAN IP has changed, and send me an email if it has. This way I can connect to my VNC server when I am on the road without having to worry about the IP changing. Anyway, I think your replies will help get me started. For the sake of completeness, here is little script I found on another thread (threadid=174534)...

by LQ user Robert0380

lynx -dump | awk '/Your/ {print $4}'
I'll let everyone know how things go.
Old 11-13-2004, 10:47 AM   #6
Registered: Aug 2002
Posts: 20,074

Rep: Reputation: 3371Reputation: 3371Reputation: 3371Reputation: 3371Reputation: 3371Reputation: 3371Reputation: 3371Reputation: 3371Reputation: 3371Reputation: 3371Reputation: 3371
With a free dynamic IP service like then email notification is not required. It is easy to setup.
Old 11-20-2004, 05:26 AM   #7
Registered: Jun 2003
Location: Charlotte NC
Distribution: Win2k pro, Damn Small Linux, Mandrake Move, Mandrake 10.1ce, xandros
Posts: 52

Rep: Reputation: 15
what is
Link encap : Local Loopback
inet addr : mask :
inet6 addr : ::1/128 Sope : Host

is that what may be resticting ip forwarding from my dsl modem through the router to my pc?

i'm trying to run a web server

the router has ports forwarded already btw

hmm. i just learned my isp has some ports blocked but i tryed port 8000 initialy with no success.

Last edited by reverendm; 11-21-2004 at 06:28 AM.


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
How to find an IP address from the MAC address of a remote machine ? jitz Linux - General 3 01-03-2006 07:55 AM
How to find IP address of a machine if I know their MAC Address dysenteryduke Linux - Networking 13 09-12-2005 10:21 AM
How to find MAC address of a specified IP address ? longtongfish Programming 1 07-12-2005 03:26 PM
How do I find my IP address?? Rosmo Linux - Networking 7 10-29-2004 03:55 PM
Command to find workstation IP address minno44 Linux - Newbie 2 10-08-2004 03:11 PM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:55 PM.

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