Go Back   MacRumors Forums > Apple Applications > Mac Applications and Mac App Store

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 13, 2004, 07:13 PM   #1
sonofslim
macrumors 6502a
 
sonofslim's Avatar
 
Join Date: Jun 2003
terminal: get IP address

is there a terminal command that will display your external IP address? ifconfig and netstat only seem to report my local/network address, so i've been using curl and awk to parse http://checkip.dyndns.org. but i'd prefer a way that doesn't rely on an http call. not to mention that my method will fail if/when dyndns changes the format of that page.

any ideas?
sonofslim is offline   0 Reply With Quote
Old Mar 13, 2004, 07:24 PM   #2
edesignuk
Moderator emeritus
 
edesignuk's Avatar
 
Join Date: Mar 2002
Location: London, England
if all you want to know is your WAN IP address http://www.whatismyip.com should do the job for you, it has been online for an age, and I can't see anyone changing it anytime soon.
__________________

Last edited by edesignuk; Mar 13, 2004 at 07:35 PM.
edesignuk is offline   0 Reply With Quote
Old Mar 13, 2004, 07:32 PM   #3
Westside guy
macrumors 601
 
Westside guy's Avatar
 
Join Date: Oct 2003
Location: The soggy part of the Pacific NW
Quote:
Originally Posted by sonofslim
is there a terminal command that will display your external IP address? ifconfig and netstat only seem to report my local/network address
I'm a bit confused - are you behind a NAT firewall? ifconfig should report your IP address just fine.

I realize this is just nit-picking, but if your NAT-ted then what you're probably looking for is the IP of the router/firewall rather than your own. If that's the case you can usually get it from the router's Web interface (assuming it has one, and most do).
__________________
Your post count is insufficient to view signature
Westside guy is offline   0 Reply With Quote
Old Mar 14, 2004, 02:55 PM   #4
sonofslim
Thread Starter
macrumors 6502a
 
sonofslim's Avatar
 
Join Date: Jun 2003
Quote:
Originally Posted by Westside guy
but if your NAT-ted then what you're probably looking for is the IP of the router/firewall rather than your own.
yes, that's the case. is there any way to get my router's external IP address from the terminal?
sonofslim is offline   0 Reply With Quote
Old Mar 14, 2004, 06:24 PM   #5
saabmp3
macrumors 6502a
 
Join Date: Jul 2002
Location: Tacoma, WA
Send a message via AIM to saabmp3
I think your best bet is to do a traceroute of a packet ping (so it sends back to you). This will report both the outgoing (not too helpful) and return trip (where you will find your IP).

BEN
saabmp3 is offline   0 Reply With Quote
Old Mar 14, 2004, 07:05 PM   #6
GigaWire
macrumors 6502
 
Join Date: Dec 2001
try ifconfig

yes ifconfig, not ipconfig

Here is a more detailed look at network commands for UNIX, LINUX, and DOS.
GigaWire is offline   0 Reply With Quote
Old Mar 14, 2004, 08:30 PM   #7
sonofslim
Thread Starter
macrumors 6502a
 
sonofslim's Avatar
 
Join Date: Jun 2003
Quote:
Originally Posted by GigaWire
try ifconfig
see above: ifconfig gives me my local network IP. but the link you sent was pretty helpful -- thanks.

Quote:
Originally Posted by saabmp3
do a traceroute of a packet ping
sorry, i can't figure out how to combine traceroute & ping... any clues?
sonofslim is offline   0 Reply With Quote
Old Feb 5, 2010, 06:30 PM   #8
sajaki
macrumors newbie
 
Join Date: Feb 2010
try this in a console window (ensure that cURL is installed) :

Code:
curl -s http://checkip.dyndns.org | sed 's/[a-zA-Z/<> :]//g'
sajaki is offline   0 Reply With Quote
Old Feb 5, 2010, 07:45 PM   #9
JNB
macrumors 604
 
JNB's Avatar
 
Join Date: Oct 2004
Location: In a Hell predominately of my own making
Send a message via Skype™ to JNB
Quote:
Originally Posted by sajaki View Post
try this in a console window (ensure that cURL is installed) :

Code:
curl -s http://checkip.dyndns.org | sed 's/[a-zA-Z/<> :]//g'
Six year old thread. You win!
__________________

JNB is offline   0 Reply With Quote
Old Jul 1, 2010, 12:34 AM   #10
tcarroll2
macrumors newbie
 
Join Date: Sep 2008
Help

Quote:
Originally Posted by JNB View Post
Six year old thread. You win!
Yes, it is six years old, but as the original poster asked, is there a way, from behind an Airport Extreme, Express, or Time Capsule, to determine your WAN IP address, without relying on an external source, such as checkip.dyndns.org or whatsmyip.com?

It has been six years and maybe something has come around that will now help us to do this?

I appreciate any suggestions on accomplishing this locally as originally asked.
tcarroll2 is offline   0 Reply With Quote
Old Jul 10, 2010, 06:03 AM   #11
markadley
macrumors newbie
 
Join Date: Jul 2010
External IP address via Terminal

Try this:


curl ifconfig.me/all/json
markadley is offline   0 Reply With Quote
Old Aug 5, 2010, 11:25 PM   #12
tcarroll2
macrumors newbie
 
Join Date: Sep 2008
Quote:
Originally Posted by markadley View Post
Try this:


curl ifconfig.me/all/json
Perfect! Now I can create a shell script to parse the external address and compare it to a saved address without having to bother whatismyip.com with unnecessary calls. I appreciate it!
tcarroll2 is offline   0 Reply With Quote
Old Aug 6, 2010, 08:50 AM   #13
chrfr
macrumors 68030
 
Join Date: Jul 2009
Quote:
Originally Posted by tcarroll2 View Post
Perfect! Now I can create a shell script to parse the external address and compare it to a saved address without having to bother whatismyip.com with unnecessary calls. I appreciate it!
Instead, you're "bothering" ifconfig.me as it's a website too. What's the difference?
chrfr is offline   0 Reply With Quote
Old Aug 6, 2010, 09:27 AM   #14
tcarroll2
macrumors newbie
 
Join Date: Sep 2008
Quote:
Originally Posted by chrfr View Post
Instead, you're "bothering" ifconfig.me as it's a website too. What's the difference?
I did not realize that. I thought the ifconfig.me was just a function of the ifconfig command.

That still doesn't do what I want then, nor the original poster. I'll keep looking. Thank you for your response.
tcarroll2 is offline   0 Reply With Quote
Old Aug 6, 2010, 11:00 AM   #15
tcarroll2
macrumors newbie
 
Join Date: Sep 2008
Quote:
Originally Posted by chrfr View Post
Instead, you're "bothering" ifconfig.me as it's a website too. What's the difference?
Ok, after doing some more research, I have found a way to get the external IP address from an Airport Extreme or Time Capsule (which is what I have) and I don't see why this wouldn't work for any other router that supports SNMP.

From the terminal do this:

prompt$ snmpwalk -Os -c {community name assigned to your device} -v 1 {private ip i.e. 192.168.1.1} ipAdEntAddr

The result for me is:
ipAdrEnt.xxx.xxx.xxx.xxx = IpAddress: xxx.xxx.xxx.xxx
ipAdrEnt.127.0.0.1 = IpAddress: 127.0.0.1
ipAdrEnt.127.0.0.2 = IpAddress: 127.0.0.2
ipAdrEnt.169.254.12.117 = IpAddress: 169.254.12.117
ipAdrEnt.192.168.1.1 = IpAddress: 192.168.1.1

Now all I need to do is parse this the way I want it and I no longer have to ping an external web site to determine my own external IP address.

I believe this answers the original posters question.
tcarroll2 is offline   0 Reply With Quote
Old Oct 22, 2011, 04:07 AM   #16
darkhan
macrumors newbie
 
Join Date: Oct 2011
The reply to this question is there are no such terminal command and/or software of OS that can tell your external IP address (i.e. your "location" in internet) without using external resources (e.g. some other computers).

The reason is simple. It's like asking from your computer where it's located without plugging it in to the internet..
When the computer was just manufactured in the factory and OS was just clean installed on it, it doesn't know your IP address, before you buy this particular computer.. what if someone else bought this particular computer? that would mean that any picked computer has to know all existing external IP addresses and intelligently decide which IP belongs to which guy and also keep in mind that that guy's ISP also changes it from time to time...

That's why you use another server to "bounce" your IP address from as in:
http://www.whatismyip.com
or
curl ifconfig.me/all/json

You also can write a program, which you will be able to run in terminal by just one word, but it still will have to use "external" resources to find out about your external ip address..
darkhan is offline   0 Reply With Quote
Old Oct 23, 2011, 11:04 AM   #17
tcarroll2
macrumors newbie
 
Join Date: Sep 2008
Quote:
Originally Posted by darkhan View Post
The reply to this question is there are no such terminal command and/or software of OS that can tell your external IP address (i.e. your "location" in internet) without using external resources (e.g. some other computers).
You are partially correct in that you do need an external resource other than the computer. In my case it is my SNMP compatible router.

What the original poster wanted to do was similar to what I have been successful at. I wanted/needed my router's external IP address and I need to check the IP periodically because my router does not support the dynamic IP service I use. Rather than using http calls and creating traffic (albeit minimal) I wanted something internal to my network that would be able to determine whether or not my dynamic IP address has changed and if so I then reach out to my registrar and update the DNS with the new IP address.

I don't think (my assumption) the OP was asking how to determine the Internet IP address (location) of a computer that has been purchased, set up, and turned on for the first time without connecting it to the Internet.
tcarroll2 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Applications > Mac Applications and Mac App Store

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
New AirPort Extreme: Dedicate IP address by MAC address? hipnetic Mac Peripherals 5 Feb 8, 2014 11:01 AM
Why can't you add an email address to your account's address book in the mail app? TH55 iPhone 30 Jan 15, 2014 01:10 PM
General: FIX "Error opening terminal: xterm-256color" for Terminal Commands (e.g., "top") iOS7 thelatinist Jailbreaks and iOS Hacks 9 Jan 10, 2014 08:46 PM
Change shipping address UPS? AT&T billing address requirement Iphone5preorder iPhone 6 Sep 23, 2013 10:25 PM
Printing return address labels in Address Book?? maestrocasa Mac Applications and Mac App Store 0 Dec 29, 2012 10:58 AM

Forum Jump

All times are GMT -5. The time now is 07:44 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC