Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DHCP Setting in Mac OS X [closed]

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.

like image 643
benc Avatar asked Nov 25 '08 07:11

benc


People also ask

How do I turn on DHCP on Mac?

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.

Why is my DHCP not enabled?

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.


2 Answers

You may use

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

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

like image 144
Arne Burmeister Avatar answered Oct 26 '22 16:10

Arne Burmeister


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
like image 22
tegbains Avatar answered Oct 26 '22 17:10

tegbains