How to force OS X to give a different IP lease with DHCP?

Is there a command line solution to get a different IP from a DHCP server? There are some solutions, like switching to BOOTP and back to DHCP, that will sometimes yield a new IP, but often the DHCP server will simply hand back the IP it just got back.

We're looking to create a log-out script that will change the IP of public computers at our school. We're using Websense filtering. Right now if a faculty member logs out of a computer, a student logging in right after wouldn't have to authenticate as they would get the elevated faculty member's access. Keeping the Websense timeout low minimizes this risk but is a pain for mobile users on the network.


Solution 1:

There is no way to do this from the client level, but you may be able to configure something in your router.

It's usually by design that a router will maintain a listing of the MAC addresses of the clients that it has handed out an IP address too, and when the timeout for the DHCP lease happens, it gives the same IP to the same MAC. If there has been some lapse and the client isn't connected at the point the lease expires, they will very often "reserve" the IP address (or at least put it to the back of the lease queue) it did have just in case it requests another lease, and can therefore give it the same one again, on the proviso that it doesn't run out of IP addresses to give to active clients, in which case the IP will be recycled to a new client.

Running a manual DHCP refresh before your lease expires will likely pull the same details.

One potential solution, although this is at the server end, is to run 2 DHCP servers, each with half of the range available to them to assign out. You can then write a simple client script that switches the DHCP server on the Mac, and then refreshes its lease. You would need to ensure that each single DHCP server has a range large enough for all your clients, because there is the potential to have all your clients on 1 server in certain circumstances.