PrivateNetworks Class
Tells an address inside the deployment's own network from one on the public internet.
public static class PrivateNetworksInheritance System.Object → PrivateNetworks
Remarks
Whenever a server is made to call an address that arrived from outside, this is the question that decides whether the call is a feature or a server-side request forgery. More than one package asks it, which is why the answer lives here rather than beside any one of them: a range added to the list below has to take effect everywhere at once, and a second copy of these rules would drift silently, since neither copy fails when they disagree.
"Private" is this type's term and it is wider than the RFC 1918 ranges the phrase usually names: it covers everything a server-initiated request has no business reaching, so loopback, link-local (where a cloud's metadata service lives), carrier-grade NAT, multicast and the unspecified address count too, as do hostnames that resolve inside a network rather than on the internet.
What surrounds the question stays with each caller: which schemes are allowed, whether the check applies at all, and which destinations an operator has deliberately permitted are policy, and policy differs by feature.
Methods
PrivateNetworks.IsPrivateHostname(string) Method
Reports whether a hostname belongs to a network rather than to the internet.
public static bool IsPrivateHostname(string hostname);Parameters
hostname System.String
The host component of the address about to be reached.
Returns
System.Boolean
True when the name should not be reached from a server-initiated request.
PrivateNetworks.IsPrivateOrReservedAddress(IPAddress) Method
Reports whether an IP address is private, loopback, link-local or otherwise reserved.
public static bool IsPrivateOrReservedAddress(System.Net.IPAddress address);Parameters
address System.Net.IPAddress
The address a name resolved to, or the literal in the URI.
Returns
System.Boolean
True when the address belongs to the deployment's own network rather than the internet.