Вопрос

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

Это было полезно?

Решение

Your IP Camera would need to support either the DHCP Protocol, or be able to be assigned a Static IP Address. If it supports the DHCP Camera then it will handle it on your own, but if it must be assigned a static IP address, then you would need to reserve that IP addres son the router, and then enter it into the camera as it's static IP address.

Routers use the MAC Address to assign out IP's under the DHCP. Unless you have a system that can masquerade as the IP Camera using it's MAC Address, to retrieve an IP address from the DHCP router, your stuck with one of the two ways above to assign an IP.

Другие советы

Some routers will let you statically assign an ip address to a device through the admin web UI. It that's the case with your router you can just let it connect to an ip address and tell the router to always assign your device that ip.

AFAIK, the DHCP request needs to come with the MAC address that you want to assign it to. If the camera doesn't support DHCP, you can't ask for an address in its name.

The simplest thing to do for you might be to implement a poor man's NAT between the user's computer and the camera: you would forward traffic from certain ports of the user's computer to the camera, and forward responses from the camera to the person who asked for it.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top