Kick mobile phones off DHCP scope lease

Kick mobile phones off DHCP scope lease

DHCP scope
This DHCP scope issue came out to scene when I was working in Tech Support.

In one customer’s office, users began complaining that their computers loose network connection. Investigation shown they were kicked out by DCHP controller with excuse that “no IP available in this range”.

Initial reason for that issue was lack of planning of network infrastructure in the office. It’s turned out they had two wireless networks, one for mobile devices and other one for laptops.  But access to both networks wasn’t much regulated, so many mobile devices were automatically connecting to same WiFi network which was planned for laptops only. Initially that wireless network  was only WiFi network available, so users’ smartphones just were connecting to WiFi they used to know.

As result, that network was out of free IP range for all devices presented and was kicking out some devices randomly, usually laptop users for sake of someone who just came in with his iPhone on. 🙂

Unfortunately it took time to arrange network engineer to change infrastructure, and quick crutch-fix was required.  Quickest solution was log into that server and kick of all mobile network devices from scope manually. It would help only for a few hours though. 🙂

So more logical solution in this case would be to schedule the script which does it for you from time to time. And here is this simple one line script. What it does is it gets list of “iphone” and “android” devices from DHCP scope (defined as 192.168.2.0 in our case) and kick these devices off from DHCP scope lease.

netsh dhcp server scope 192.168.2.0 show clients 1 | findstr "iphone android" | %{$_.split(' ')[0]} | %{netsh dhcp server scope 192.168.2.0 delete lease $_}

As I said, it was just a crutch. But saved us a lot of time on unnecessary calls from users until the day when network engineer has finally made permanent fix.