Viewing DHCP information on an OS X system

If you want to determine the IP address of the DHCP server from which a Mac OS X system received its IP address, subnet mask, etc., you can obtain that information from a command-line interface (CLI), i.e., a Terminal window by using the command ipconfig getpacket interface where interface is the relevant network interface, which will usually be en0 or en1. You can issue the command ifconfig -a in a Terminal window to see the network interfaces on the system and which have IP addresses assigned to them.

getpacket interface-name
Prints to standard output the DHCP/BOOTP packet that the client accepted from the DHCP/BOOTP server. This command is useful to check what the server provided, and whether the values are sensible. This command outputs nothing if DHCP/BOOTP is not active on the interface, or the attempt to acquire an IP address was unsuccessful.

When you issue the command, you will see output similar to that shown below:

$ ipconfig getpacket en0
htype = 1
flags = 0
hlen = 6
hops = 0
xid = 0xceb36b13
secs = 0
ciaddr =
yiaddr =
siaddr =
giaddr =
chaddr = ac:bc:32:ce:d3:f5
sname = 
file = 
Options count is 7
dhcp_message_type (uint8): ACK 0x5
server_identifier (ip):
lease_time (uint32): 0x15180
subnet_mask (ip):
router (ip_mult): {}
domain_name_server (ip_mult): {}
end (none): 

Some of the values displayed include the following:

yiaddr: The IP address assigned to the specified network interface on the system from which the command was issued.
server_identifier (ip): The DHCP server's IP address.
chaddr: The Media Access Control (MAC) address associated with the specified network interface.
subnet_mask (ip): The subnet mask.
router (ip_mult): The router to which network packets destined for systems outside the subnet should be sent, aka, the gateway address.
lease_time (uint32): The lease time in seconds as a hexadecimal value. You can convert the hexadecimal value to a decimal value using a hexadecimal to decimal converter. In the example above hex 15180 equals decimal 86400, which is 1 day, since there are 86,400 seconds in a day.

You can also use the ipconfig's getoption parameter to get specific values individually.

getoption interface-name (option-name | option-code)
Prints the BOOTP/DHCP option with the given name or option code integer value. See bootpd(8) for option code names. If an option has multiple values e.g. domain_name_server, only the first value is printed.

E.g., the commands below get the DHCP server IP address, the router's IP address, the subnet mask, and the domain name server's IP address. In this case the router is also functioning as the DHCP server and DNS server. You can also get the lease time in seconds and the domain name, if one has been assigned, though in the example below none has been assigned. The value below of 86,400 seconds for the lease time means the lease of the IP address is good for 1 day, since 86400 / 24 / 60 / 60 = 1. When the lease time expires, a system has to query the DHCP server again for an IP address and associated information. It may get the same IP address again.

Save on a Computer: Run Windows, Mac, and Linux with VirtualBox
Save on a Computer: Run Windows,
Mac, and Linux with VirtualBox
1x1 px

$ ipconfig getoption en0 server_identifier
$ ipconfig getoption en0 router
$ ipconfig getoption en0 subnet_mask
$ ipconfig getoption en0 domain_name_server
$ ipconfig getoption en0 lease_time
$ ipconfig getoption en0 domain_name