LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 08-29-2006, 10:12 AM   #1
lucktsm
Member
 
Registered: May 2004
Location: Atlanta, GA USA
Distribution: Redhat ES4, FC4, FC5, slax, ubuntu, knoppix
Posts: 155

Rep: Reputation: 30
Question How can I determine my WAN IP via Command line?


Hey all,

I need to be able to determine my WAN ip address (dynamic) via a command line cron job. Does anyone have any recommendations?
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 08-29-2006, 10:30 AM   #2
Lenard
Senior Member
 
Registered: Dec 2005
Location: Indiana
Distribution: RHEL/CentOS/SL 5 i386 and x86_64 pata for IDE in use
Posts: 4,790

Rep: Reputation: 58
See; man ifconfig
 
Old 08-29-2006, 11:30 AM   #3
isuck@linux
Member
 
Registered: Jun 2006
Distribution: messed up debian
Posts: 250

Rep: Reputation: 30
it's probably ifconfig ppp0 but just write down ifconfig and it will show you all interfaces
 
Old 08-30-2006, 07:49 AM   #4
lucktsm
Member
 
Registered: May 2004
Location: Atlanta, GA USA
Distribution: Redhat ES4, FC4, FC5, slax, ubuntu, knoppix
Posts: 155

Original Poster
Rep: Reputation: 30
Question

ifconfig gives me great information about my LAN but not my WAN. I am behind a router that I have no access to (This is an ISP managed router). I can only see the gateway IP.

Here's what I came up with....

I use curl to query whatsmyipaddress.com and then grep out whois. It works ok...

If anyone has a better idea please let me know.

Last edited by lucktsm; 08-30-2006 at 07:50 AM.
 
Old 08-30-2006, 09:05 AM   #5
~=gr3p=~
Member
 
Registered: Feb 2005
Location: ~h3av3n~
Distribution: RHEL 4, Fedora Core 3,6,7 Centos 5, Ubuntu 7.04
Posts: 227

Rep: Reputation: 30
try tracepath

for example

tracepath -n google.com
 
Old 08-31-2006, 12:27 AM   #6
isuck@linux
Member
 
Registered: Jun 2006
Distribution: messed up debian
Posts: 250

Rep: Reputation: 30
in my case i telnet my router from my linux box query for the ip and put it in a file in my linux box.
 
Old 08-31-2006, 12:48 PM   #7
lucktsm
Member
 
Registered: May 2004
Location: Atlanta, GA USA
Distribution: Redhat ES4, FC4, FC5, slax, ubuntu, knoppix
Posts: 155

Original Poster
Rep: Reputation: 30
Tracepath works pretty good. The nice thing is in it's output it's the second node listed and has a 1: next to it.
 
Old 06-24-2015, 07:29 AM   #8
JHServices
LQ Newbie
 
Registered: Jun 2015
Posts: 1

Rep: Reputation: Disabled
Wink Using dig

Another way of determening your external ip from the commandline is using dig:

dig +short myip.opendns.com @resolver1.opendns.com

this gives your public IP address
 
2 members found this post helpful.
Old 06-24-2015, 09:37 AM   #9
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Did we really need to resurrect a 9 year old thread for that?
 
Old 09-30-2015, 09:31 AM   #10
drgibbon
Senior Member
 
Registered: Nov 2014
Distribution: Slackware64 15.0
Posts: 1,220

Rep: Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942
Quote:
Originally Posted by suicidaleggroll View Post
Did we really need to resurrect a 9 year old thread for that?
Why does that matter? The 'dig' line from JHServices is the only one that works cleanly and returns nothing but the public ip address. It helped me.
 
Old 09-30-2015, 10:12 AM   #11
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Quote:
Originally Posted by drgibbon View Post
Why does that matter? The 'dig' line from JHServices is the only one that works cleanly and returns nothing but the public ip address. It helped me.
This is a topic as old as the internet itself. It has been solved literally hundreds of different ways, almost all of which can be found with a 5 second search on ANY search engine or this forum or any other Linux forum.

Throwing out a suggestion in an active discussion is one thing, but resurrecting a decade-old thread to provide yet another solution to something that has been solved a hundred times before is just a waste of time and bandwidth.

I'm glad it solved your problem, but if that post wasn't here, you would have found an equally useful solution in the very next link on whatever search brought you here (the other link probably would have been the first anyway, if this thread hadn't been resurrected).

Last edited by suicidaleggroll; 09-30-2015 at 10:14 AM.
 
Old 09-30-2015, 10:19 AM   #12
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
And since it is now timestamped as newer and likely to be referenced - here is a simple easy-to-remember solution:

Code:
curl ifconfig.me
 
Old 09-30-2015, 09:07 PM   #13
drgibbon
Senior Member
 
Registered: Nov 2014
Distribution: Slackware64 15.0
Posts: 1,220

Rep: Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942
Quote:
Originally Posted by suicidaleggroll View Post
This is a topic as old as the internet itself. It has been solved literally hundreds of different ways, almost all of which can be found with a 5 second search on ANY search engine or this forum or any other Linux forum.

Throwing out a suggestion in an active discussion is one thing, but resurrecting a decade-old thread to provide yet another solution to something that has been solved a hundred times before is just a waste of time and bandwidth.

I'm glad it solved your problem, but if that post wasn't here, you would have found an equally useful solution in the very next link on whatever search brought you here (the other link probably would have been the first anyway, if this thread hadn't been resurrected).
I don't know, I think people get too concerned about thread dates sometimes, I hardly look at them myself, but obviously old threads can still be found since the guy managed to find (and answer) this one at the ripe old age of 9. Now it at least has a decent answer, so great. I looked at a few other pages before this one, and I didn't find anything as easy as the dig line. The waste of time and bandwidth stuff is a side issue that seems pretty negligible to me (aren't we wasting time and bandwidth even talking about it? )

Last edited by drgibbon; 09-30-2015 at 09:08 PM. Reason: edit
 
  


Reply



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
unable to access WAN fromm comman line trelos Linux - Networking 1 06-20-2006 04:52 PM
Is there a way to determine distribution from the command line? alienmagic Linux - Newbie 11 02-21-2006 07:44 AM
FreeS/Wan Vs. OpenS/Wan Vs. StrongS/Wan bkankur Linux - Security 1 03-01-2005 09:27 AM
Command to output file content line by line aznluvsmc Programming 2 09-12-2004 07:45 PM
Can someone tell me a command to determine the hostname of an IP on the network? brow27 Linux - Newbie 4 05-20-2004 03:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 04:03 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
Open Source Consulting | Domain Registration