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.
On your Mac, choose Apple menu > System Preferences, then click Network . Select the network connection you want to use (such as Ethernet) in the list. Click the Configure IPv4 pop-up menu, then choose an option: If your address will be assigned automatically, choose Using DHCP.
Right-click Local Area Connection and select Properties. Highlight the Internet Protocol (TCP/IP) option and click the Properties button. If you want to enable DHCP, make sure Obtain an IP address automatically is selected, and Obtain DNS server address automatically.
You may use
networksetup -listallnetworkservices
networksetup -getinfo <networkservice>
networksetup -setdhcp <networkservice> [clientid]
networkservice is something like Ethernet (all availabe listed by the first command)
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With