Thursday 17 November 2011

DHCP info from your Mac OSX



A handy way of finding DHCP information on your Mac OSX is to use the ipconfig command. In your terminal simply type the following;

ipconfig getpacket en0

"en0" can be substituted with any interface name. i.e. en1 for wireless/airport NIC.


The output displayed provides the DHCP/BOOTP packet that is received from the DHCP server. A sample output is below:

$ ipconfig getpacket en0
op = BOOTREPLY
htype = 1
flags = 0
hlen = 6
hops = 0
xid = 824055788
secs = 0
ciaddr = 0.0.0.0
yiaddr = 192.168.1.10
siaddr = 0.0.0.0
giaddr = 0.0.0.0
chaddr = c4:2c:1:1:68:cd
sname =
file =
options:
Options count is 12
dhcp_message_type (uint8): ACK 0x5
renewal_t1_time_value (uint32): 0xa8c0
rebinding_t2_time_value (uint32): 0x12750
lease_time (uint32): 0x15180
server_identifier (ip): 192.168.1.5
subnet_mask (ip): 255.255.255.192
router (ip_mult): {192.168.1.1}
domain_name_server (ip_mult): {4.2.2.2}
domain_name (string): test.com

nb_over_tcpip_name_server (ip_mult): {4.2.2.2}
nb_over_tcpip_node_type (uint8): 0x8
end (none):

 

This can be handy if you want to quickly identify your DHCP server or find DHCP information.
The output shows the option name followed by the value.
From the output we can tell that the my iMac ip address is: 192.168.1.10.
   yiaddr = 192.168.1.10


Your hardware/MAC address is: c4:2c:1:1:68:cd
  chaddr = c4:2c:1:1:68:cd


The DHCP server is: 192.168.1.5
 server_identifier (ip): 192.168.1.5


Another way is to use the ipconfig command to obtain the server address is to use the getoption parameter.


ipconfig getoption en0 server_identifier


This will simply display the DHCP server address.


If you don't get any output, just simply means you haven't received a successful response from the DHCP server. i.e. you're using a static address or you aren't getting an ip address from the server.


As always, if you want to dig deeper, use go to the man page for ipconfig.









No comments:

Post a Comment