c# - Get and reserve an available IP address from a dhcp server to use for my ip camera

07
2014-07
  • Andrew Simpson

    I have a c# desktop app.

    I have an ip camera and I want to assign a static ipaddress to it. I need to be able to get a 'free/available' ip address from my dhcp server, reserve it and assign it to my ip camera. I can assign the ip address to my camera easily enough. But how do I get an available ip address and reserve it before it is allocated to another device 'plugged' into my network?

    I have seen api calls to get client ipaddresses but do not see if I can use it for what I want.

    I could ping each ip address on the subnet in order to find if an address is available but that seems inefficient as i would be waiting for a time out from pinging that address. Besides, it would not 'reserve' it.

    I hope I making this clear?

    NB. I want to assign a static ip address to my ip camera. I have the sdk to do that. It is just that I need to assign a free ip address that is on the same subnet

  • Answers
  • Alexander

    You can't get a 'free/available' addresses list from DHCP server, it simple have no protocol to inform you. It can give you one IP from its pool.

    May I suggest to go to the roots and read some about DHCP, at least Overview?

    The best thing you can do is to set a static DHCP reservation via your DHCP server configuration so every time your camera ask for an IP it will get the same IP, and then set that IP in your app.

    I also suggest you to have some "static reservation" range within your DHCP range. Say, DHCP will work with 192.168.100.0...255 IPs, take a good habbit to let it use IPs not from .1 octet, but from, say, .32 instead. This way, you may static assign IP in DHCP within .2-.31 range (I used to use .1 for the router itself) so it will not cross with dynamic IP range. Or you may simple set up static IP within the same .2-.31 range via camera control panel and do not bother with DHCP reservation.

  • becomingwisest

    DHCP does not support this. Either your camera will need to support running a DHCP client, or your software will need to ask the user for the static ip that should get assigned to the camera. They may need to reach out to their network admin to find out the proper address.


  • Related Question

    ip address - Can no longer reach DHCP server
  • NogginTheNog

    I've read some of the other DHCP questions here, but my problem is a little different. I have a home laptop that has been working fine for ages. I brought my work laptop home at the weekend to finish a couple of tasks and connected it to my cable modem via ethernet cable - everything worked fine. Then I reconnected my home laptop, and it suddenly cannot find the dhcp server anymore. The IP address is (on both laptops) dynamically set, but even when I define a static IP address on my home laptop as being the dynamically assigned one on my work laptop (which worked OK), it still cannot get a connection.

    I've tried ipconfig /flushdns, ipconfig /release and ipconfig /renew but it makes no difference. I suppose my network card on my home laptop could be defective, but would like to exhaust all other possibilities before I go down that route. Any ideas?


  • Related Answers
  • Josh K

    Have you tried resetting your cable modem? That would be my first recommendation. My second would be to reset your laptop if you haven't done so already.

  • techie007

    If you have any anti-virus/firewall/Internet protection programs loaded, ensure they haven't been set to block all traffic.

    You may also want to try Safe Mode with Networking, as that should help rule out running software applications as a cause.