DHCP Lease Renew ONLY Via Terminal

We are replacing our DHCP server with a new applicance. I would like to create a script that would do the exact same thing as the "Renew DHCP Lease" button does in network preferences. I have used Instraments, top, etc to try to isolate the command but have not had any success. My biggest concern is to not interupt the network connection when renewing the DHCP lease. When the "Renew DHCP Lease" button is clicked, my network connection is not dropped.


The only solution I have found for this is to run "ipconfig set enx BOOTP ; ipconfig set enx DHCP" which drops the network.


Does anyone know what command the "Renew DHCP Lease" button preforms or a good way to renew a DHCP lease without dropping the connection.

Posted on Nov 7, 2012 2:30 PM

Reply
3 replies

Nov 7, 2012 4:31 PM in response to jbNco

networksetup -setdhcp <networkservice> [clientid]



<networkservice> is the name of your interface, usually something like "Wi-Fi", "Ethernet", "Built-in Ethernet" or so on.

[clientid]
is usually optional, unless your ISP or IT section actually requires them (in which case you can always just get it from the Pane in the first place). You can find the proper names for the interfaces using



networksetup -listallnetworkservices



And find all the info about a given network service using



networksetup -getinfo <networkservice>



networksetup is the command line tool for which the Network Preference Pane is the front-end. If scripting, you need to be aware that networksetup will need administrator privileges to renew the DHCP lease (in the Preference Pane, you need to unlock the Pane before you can use the advanced preferences, so it isn't necessarily obvious).

Nov 8, 2012 7:24 AM in response to g_wolfman

Thanks Wolfman for responding.


I have tried the command networksetup -setdchp <networkservice> and it has not been updating my lease. The files located at /var/db/dhcpclient/leases do not update for the interface I specify.


Our admin of the current system just updated our lease time to 7200 seconds down from 604800 seconds and this is not updating as well.


Is anyone aware of where I can find a dhclient for Mac OS X?

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

DHCP Lease Renew ONLY Via Terminal

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.