C# determining if an IP address represents a real host -
Problem: In an input field there is an input field where the user can enter the host name or IP address. I need to tell if the entered address matches the actual host. I'm not talking about a simple regular expression check or an IPAddress.TryParse or Uri.CheckHostName. I do not have difficulty checking a hostname: If it can not be resolved on an IP address, then DNS.GetHostEntry will throw an exception. This is a piece of cake though . If I get an IP address input, then if I call a Dns.GetHostAddresses, it will always be successful, even if I enter a stupid IP, like "1.1.1.1" ("1.1.1.1" is an IANA reserved IP Address, our DNS server reports "non-existent hosts / domains") DCS. GetHostAdWords immediately leaves the IP immediately, which I just pass, like everything will be fine. Ahh. I can not use DNS.GetHostEntry, because some IP addresses (like my virtual machines on the local network), do not have any DNS host names associated with them. But they still have valid IP addresses, and DNS.GetHostEntry will leave those exceptions (I think that tries to solve a hostname for them?). I need a method call that actually tells me whether it is a fake IP or not, even if it looks for a good IP address (Uy. checkhostname), but it does not have the same DNS host name. The only appropriate investigation you can do if the IP has some reserved IP otherwise you can not do much - Safe as: For more information on special categories / IP, check RFC and link.
Comments
Post a Comment