views:

1814

answers:

3

Are there any command line interfaces to the DHCP settings in Mac OS X? I have found that inside System Profiler, the Network tab provides a lot of useful information, but I have not found any documentation about any command line equivalents.

A: 

You should look at:

ifconfig(8)
netstat(1)
netintro(4)

The most important of these (netintro isn't actually a utility but rather introductory information on unix networking) is ifconfig which is the command line tool used to configure the various network interfaces you may have installed on your machine (like your ethernet card and your airport card) as well as any virtual interfaces (like your loopback address and things like parallels).

Jason Coco
neintro is not on my Mac, and I have used ifocnfig and netstat extensively, they don't appear to do anything w/ DHCP.
benc
netintro is not a program, it's in section 4 of the manual, it's information about how to configure your network. I made that clear in my response.
Jason Coco
+3  A: 

You may use

networksetup -listallnetworkservices
networksetup -getinfo <networkservice>
networksetup -setdhcp <networkservice> [clientid]

networkservice is something like Ethernet (all availabe listed by the first command)

Arne Burmeister
I finally had time to look at this command, and it gets the job done!
benc
+2  A: 

You can also use:

ipconfig getpacket `interface`

where interface would be en0, en1 etc.

ie:

ipconfig getpacket en1
op = BOOTREPLY
htype = 1
flags = 0
hlen = 6
hops = 0
xid = 215448168
secs = 3
ciaddr = 0.0.0.0
yiaddr = 192.168.15.121
siaddr = 0.0.0.0
giaddr = 0.0.0.0
chaddr = 0:19:e3:6:70:95
sname = 
file = 
options:
Options count is 8
dhcp_message_type (uint8): ACK 0x5
server_identifier (ip): 192.168.15.1
lease_time (uint32): 0xa8c0
subnet_mask (ip): 255.255.255.0
router (ip_mult): {192.168.15.1}
domain_name_server (ip_mult): {192.168.15.249, 192.168.15.240}
domain_name (string): domain.com
end (none):

You can also do:

ipconfig getoption en0 optionname

ie: ipconfig getoption en1 router

192.168.15.1
tegbains
"The IPConfiguration agent implements the client side of the DHCP and BOOTP protocols described in RFC951, RFC1542, RFC2131, and RFC2132. Italso assigns and maintains static IP addresses."I don't know why this could not be found by google or man -k, but many thanks.
benc