PDA

View Full Version : Get wide-area IP address for localhost on command-line?


momerath
07-24-2003, 11:03 PM
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.

yellow
07-24-2003, 11:17 PM
It'll require some grepping in your command (or perl, or awk), but I think this is what you're looking for:
ifconfig en0 inet
Unless you trust the output of
hostname

momerath
07-24-2003, 11:26 PM
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?