Go Back   The macosxhints Forums > OS X Help Requests > UNIX - General



Reply
 
Thread Tools Rate Thread Display Modes
Old 07-25-2003, 12:03 AM   #1
momerath
Triple-A Player
 
Join Date: Feb 2003
Posts: 59
Get wide-area IP address for localhost on command-line?

First, a brief explanation of what I'm trying to do. I'm playing with the tcpflow utility and I want to run a single command (which I will later store as an alias) to write all of the tcp traffic to and from my machine.

The utility tcpflow will look at all of the traffic it can see (regardless of whether it's to one's own computer or not). There is a way to exclude one IP address or only show traffic to one IP address. I have everything worked out except for how to get my own IP address from the command line:

mkdir -p ~/Desktop/output; cd ~/Desktop/output; sudo tcpflow -i en0 host `get_the_ip_command`

Basically, all I need is a UNIX command to output my computer's IP address that is visible to the internet.

And no, using "localhost" does not work.
momerath is offline   Reply With Quote
Old 07-25-2003, 12:17 AM   #2
yellow
Moderator
 
Join Date: Jan 2002
Posts: 10,652
It'll require some grepping in your command (or perl, or awk), but I think this is what you're looking for:
Code:
ifconfig en0 inet
Unless you trust the output of
Code:
hostname
__________________
Chameleon's Consignment Loft]
yellow is offline   Reply With Quote
Old 07-25-2003, 12:26 AM   #3
momerath
Triple-A Player
 
Join Date: Feb 2003
Posts: 59
Super! Thanks a lot.

I'll see what I can whip up from the ifconfig stuff.

With Rendezvous, hostname gives the rendezvous address (my-computer.local). So, why shouldn't / wouldn't I trust the hostname command? Easy to spoof or something?
momerath is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


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


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Site design © Mac Publishing LLC; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of Mac Publishing LLC.