How to query the computer's ip address?

yo _ exhausted01 at hotmail.com
Sun Feb 8 16:49:46 PST 2004


>Hi,
>
>Silly question, maybe, but is there a simple command to query the 
>computer's
>ip address? Something similar to 'hostname' for finding the computer's 
>hostname.
>I need the four dot-separated ip numbers.
>
>I can analyze the output of 'ifconfig', but isn't there an easier way.

For the sake of looking for a "command" that might do this, i whipped up 
this long one-liner:

ifconfig | perl -nle 'print $1 if(/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/)'

note that this will print the first ip address it finds of each line 
seperated by a newline, so be prepared to handle more than one.
-rian

_________________________________________________________________
Find great local high-speed Internet access value at the MSN High-Speed 
Marketplace. http://click.atdmt.com/AVE/go/onm00200360ave/direct/01/



More information about the freebsd-questions mailing list