I created the following scripts to mimic the ipconfig /all functionality found in the Windows NT operating system. In the unix world, all of the info is available, but not in one place which is where this script comes in handy. It concatenates all of the various pieces of IP configuration into one easy-to-read display. The bonus is all of the functions used are contained in a separate file, which can be sourced into your shell environment and used individually.
Download the scripts (4KB download), and install them wherever you like. The first script, functions.sh, contains the functions that I use in the second file, ipinfo.sh. Be sure to alter the second line of the ipinfo.sh file to point to the correct location of functions.sh.
When you run ipinfo.sh from the command line, you will receive output similar to the following:
--------------------------------------------------------
Public: xxx.xxx.xxx.xxx
Loopback: 127.0.0.1 / 255.0.0.0
Airport: 10.2.0.168 / 255.255.255.0
Gateway: 10.2.0.1
Domain: yourdomain.com
Nameserver: 10.1.0.50
Nameserver: 192.168.1.16
--------------------------------------------------------
I split the functions out of the main script to I could use them in my bashrc file individually. The functions are as follows:
get_public, get_ip, get_mask, get_gateway, get_dns, get_domain
The get_ip and get_mask functions take a single argument of an interface name (lo0, en0, en1, fw0, etc.). After these are added to my shell environment, I can do things like ping $(get_gateway) or get_ip en1.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20060901055801748