tags:

views:

167

answers:

2

Using Hyper-V I built a private windows domain which is fenced off from our main network. Ultimately I want to provision this domain for others to use for dev and test, so they can be domain admin.

The domain controller is running the dhcp service (other systems in my domain have dependencies on dhcp). The problem is, if some idiot (i.e. me) accidently connects the domain controller to the main network it will respond to dhcp requests (this is an assumption) and hand out invalid ip configurations.

So, I would like to write a .NET windows service which starts the local dhcp service only when no other dhcp servers are available. Ideally, this would be capable of periodically checking in the background, so if you change your virtual network config while the machine is running, dhcp can be stopped automatically and potential damage is limited.

I'm a bit stuck on how to detect remote dhcp servers. So far I have considered writing a wrapper for the dhcploc command line tool, but is there is a better/simpler alternative that would acheive the objective? Are there any caveats I should be aware of?

Thanks

A: 

Someone has written a C# network sniffer you could adapt to your purposes, but this would seem overly complicated. There is no built-in DHCP support in the framework, so there is no simple method you can just call. I think for your purposes you are probably best just sticking with wrapping the command line tool as you say you are doing.

Jon Grant
Thanks, I also found <a href="http://www.codeproject.com/KB/IP/tiny_DHCP_server.aspx">this</a> tiny dhcp server on codeproject - probably a useful reference if I try to intercept dhcp packets.
Alex Peck
+1  A: 

As suggested by Shay Erlichmen I posted the question on server fault here. It turns out you can specify the DHCP server only assign IP addresses to known MACs. Given that my VMs (can) all have known MACs, I can use this to lockdown the private domain DHCP server.

Alex Peck