Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > Terminal command for finding you IP address?

Terminal command for finding you IP address?
Thread Tools
Tyre MacAdmin
Mac Elite
Join Date: Feb 2002
Status: Offline
Reply With Quote
Dec 10, 2003, 04:58 PM
 
I'm looking for a way to find the local IP address of the computer from the command line... anybody know how?
     
EnVoy
Mac Enthusiast
Join Date: Dec 2002
Location: Newport Beach, CA
Status: Offline
Reply With Quote
Dec 10, 2003, 05:06 PM
 
ifconfig en0 | awk '/inet /{print $2}'
     
Tyre MacAdmin  (op)
Mac Elite
Join Date: Feb 2002
Status: Offline
Reply With Quote
Dec 10, 2003, 05:35 PM
 
Originally posted by EnVoy:
ifconfig en0 | awk '/inet /{print $2}'
Thanks!
     
Detrius
Professional Poster
Join Date: Apr 2001
Location: Asheville, NC
Status: Offline
Reply With Quote
Dec 10, 2003, 11:05 PM
 
Or you could just type ifconfig and look for the address. It would probably be more useful to be aware of the ifconfig command, vs. just getting your ip address on the built in ethernet.
ACSA 10.4/10.3, ACTC 10.3, ACHDS 10.3
     
gatorparrots
Dedicated MacNNer
Join Date: Dec 2002
Location: someplace
Status: Offline
Reply With Quote
Dec 11, 2003, 12:32 AM
 
Originally posted by EnVoy:
ifconfig en0 | awk '/inet /{print $2}'
You can avoid the pipe:
ipconfig getifaddr en0

To get an external WAN-side address:
curl -s http://www.showmyip.com/simple/ | awk '{print $1}'
     
K++
Senior User
Join Date: Jan 2002
Location: NYC
Status: Offline
Reply With Quote
Dec 11, 2003, 01:40 AM
 
OR:
Code:
nslookup `hostname`
     
Tyre MacAdmin  (op)
Mac Elite
Join Date: Feb 2002
Status: Offline
Reply With Quote
Dec 11, 2003, 06:14 AM
 
Thanks everybody... the new system preferences panel I no like...

You have to dig for an IP address, and even in some configurations it has proved not to even show one. Time to remember my UNIX!

That and the new way to get to the CPU meter. I can't find the expanded window... so I just copied over the old cpu meter app from a backup of one of my systems before panther. What a bummer dudes.

Other than that... things are pretty good besides having to update all my apps with the newest versions.
     
K++
Senior User
Join Date: Jan 2002
Location: NYC
Status: Offline
Reply With Quote
Dec 11, 2003, 01:28 PM
 
Originally posted by Tyler McAdams:
Thanks everybody... the new system preferences panel I no like...

You have to dig for an IP address, and even in some configurations it has proved not to even show one. Time to remember my UNIX!

That and the new way to get to the CPU meter. I can't find the expanded window... so I just copied over the old cpu meter app from a backup of one of my systems before panther. What a bummer dudes.

Other than that... things are pretty good besides having to update all my apps with the newest versions.
Umm... the new Network preferences Pane is much easier to find what your looking for in. by default it goes to the status screen that tells you link activity, configuration and ip address all in one little blurb.

As for the CPU monitor, it is part of activity monitor where it belongs. Just open that and in the menus it has opetions to show the activity monitor as a graph in a window, personally I keep mine a s a graph in my dock, but to each his own.
     
chris v
Addicted to MacNN
Join Date: Jan 2001
Location: The Sar Chasm
Status: Offline
Reply With Quote
Dec 13, 2003, 12:38 PM
 
Here's a slight twist on the same questin-- How to find the ip addresses of other computers on my LAN in terminal? I'm running a DHCP server to my kid's computer, with a range of 20 ip addresses, so I'm always having to guess when ssh'ing in to her machine. How can I discover the ip so I don't have to flail around from .1.100 to .1.120?

CV

When a true genius appears in the world you may know him by this sign, that the dunces are all in confederacy against him. -- Jonathan Swift.
     
Gary Kerbaugh
Dedicated MacNNer
Join Date: Jul 2001
Location: NC
Status: Offline
Reply With Quote
Dec 13, 2003, 01:38 PM
 
Originally posted by K++:
As for the CPU monitor, it is part of activity monitor where it belongs.
   I might agree that it belonged there if using only that "feature" put no more drain on the system than CPU Monitor. However, it uses almost 10% of my CPU in any configuration. Thus, when all I want is a CPU Monitor, I think I'll stick with the old one.
Gary
A computer scientist is someone who, when told to "Go to Hell", sees the
"go to", rather than the destination, as harmful.
     
Moonray
Mac Elite
Join Date: May 2001
Status: Offline
Reply With Quote
Dec 13, 2003, 03:39 PM
 
Originally posted by chris v:
Here's a slight twist on the same questin-- How to find the ip addresses of other computers on my LAN in terminal? I'm running a DHCP server to my kid's computer, with a range of 20 ip addresses, so I'm always having to guess when ssh'ing in to her machine. How can I discover the ip so I don't have to flail around from .1.100 to .1.120?

CV
You could configure the addresses manually

-
     
Moonray
Mac Elite
Join Date: May 2001
Status: Offline
Reply With Quote
Dec 13, 2003, 03:47 PM
 
Originally posted by Tyler McAdams:
That and the new way to get to the CPU meter. I can't find the expanded window... so I just copied over the old cpu meter app from a backup of one of my systems before panther. What a bummer dudes.
If you're talking about Apples little CPU-Monitor it's pretty the same. You won't get the expanded window though if you have the expanded view in the dock already.

-
     
chaldean oracle
Junior Member
Join Date: Nov 2003
Status: Offline
Reply With Quote
Dec 13, 2003, 05:25 PM
 
Originally posted by chris v:
Here's a slight twist on the same questin-- How to find the ip addresses of other computers on my LAN in terminal? I'm running a DHCP server to my kid's computer, with a range of 20 ip addresses, so I'm always having to guess when ssh'ing in to her machine. How can I discover the ip so I don't have to flail around from .1.100 to .1.120?

CV
Use the Rendezvous name? That's what it's there for...

e.g. ssh [email protected]
     
ae77
Forum Regular
Join Date: Aug 2001
Location: CA, USA & Bangkok, Thailand
Status: Offline
Reply With Quote
Dec 13, 2003, 10:33 PM
 
Originally posted by chaldean oracle:
Use the Rendezvous name? That's what it's there for...

e.g. ssh [email protected]l
that's a good solution.
^_^
     
chris v
Addicted to MacNN
Join Date: Jan 2001
Location: The Sar Chasm
Status: Offline
Reply With Quote
Dec 14, 2003, 11:30 PM
 
Originally posted by chaldean oracle:
Use the Rendezvous name? That's what it's there for...

e.g. ssh [email protected]l
Hadn't thought of that. (obviously) thanks!

Still curious if there's a way to discover the actual ip adresses of other machines on the LAN, just because I'd likke to know if there's a simple command to do that.

CV

When a true genius appears in the world you may know him by this sign, that the dunces are all in confederacy against him. -- Jonathan Swift.
     
chaldean oracle
Junior Member
Join Date: Nov 2003
Status: Offline
Reply With Quote
Dec 15, 2003, 02:00 AM
 
Originally posted by chris v:
Hadn't thought of that. (obviously) thanks!

Still curious if there's a way to discover the actual ip adresses of other machines on the LAN, just because I'd likke to know if there's a simple command to do that.

CV
glad to help, cheers.

As for discovering other machines:
It's not foolproof, but you can do a broadcast ping:

ping 255.255.255.255

which will often get you replies from any other machines in your LAN.
     
cwagar
Junior Member
Join Date: Aug 2001
Location: Atlanta, Georgia, USA
Status: Offline
Reply With Quote
Dec 15, 2003, 07:45 PM
 
255.255.255.255 will not work, nor should it.

The poster is correct in saying that a broadcast ping is the most effective way to search other hosts on the LAN. Depending on the IP stack of the other machine, you should get a response. Most types of stacks will, indeed, respond.

My LAN at home is 172.16.12.0/24, so I:

ping 172.16.12.255
then -
arp -a

This will show you the information you're looking for.

If you are in doubt about the broadcast address of your LAN, you can find that information in the "ifconfig -a" command discussed above.
     
   
 
Forum Links
Forum 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 On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 10:45 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,