开发者

Get and assign link-local IP addresses in .NET C#, implementation of APIPA

开发者 https://www.devze.com 2023-04-01 02:01 出处:网络
I need to make in .NET c# a functionality which is an implementation of IPv4LL as defined in RFC3927, a technology for assigning link-local IP addresses without DHCP server. The same functionality has

I need to make in .NET c# a functionality which is an implementation of IPv4LL as defined in RFC3927, a technology for assigning link-local IP addresses without DHCP server. The same functionality has been available on Windows under the name APIPA. On linux there's such plugin :avahi , avahi-autoipd. But on windows haven't found yet sth similar.

Till now I have only one so开发者_运维知识库lution: to send ARP packets on network with link-local IP address within a range, and test them if are free, once I find one free it is assigned as current IP address.

Any suggestion regarding my problem would be much appreciated.


If I were you I would investigate Avahi a little closer, mainly because you can view the source code if you want, but also to see how it works with Mono.

Having said that, I suspect that you need a service quite separate from your application(s) and therefore there is no need to limit yourself to .Net as a technology.

Is that helpful at all ?


According to the RFC that defines IPv4 link-local addressing, http://www.ietf.org/rfc/rfc3927.txt you really do need to send ARP to verify that your randomly selected 169.254.XXX.YYY address is not in use already.

To use ARP in C#, check out the IPHLPAPI.DLL, and call it via P/Invoke. http://www.pinvoke.net/default.aspx/iphlpapi.SendARP

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号