How to tell if a URL is an intranet url?

you cannot implicitely know. if your intranet urls look like fully qualified domain names then it's difficult to tell. the only way to tell is to query two different DNS-servers (your own and a public one). If both return the same result, then it's an internet domain. if the public DNS-server isn't able to resolve the address, then it's most likely an intranet domain.


Do you know the internal subnets (in terms of IP addresses)? If so, I'd just resolve the host name and see if it's internal that way.


if the url resolves to a tcpIp address which is one of the IP addresses set aside as a private IPAddress, then it is definitely on your Intranet. these are

  1. 10.xxx.xxx.xxx,
  2. 172.16.xxx.xxx through 172.31.xxx.xxx, and
  3. 192.168.xxx.xxx

if it resolves to any other IP address it might still be on your intranet, but it has a public IP address so it is potentially accessible from outside the Intranet

Tags:

C#

.Net