Show / Hide Table of Contents

Class IPAddressExtensions

NAT extensions to the IPAddress class.

Inheritance
Object
IPAddressExtensions
Inherited Members
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Namespace: Makaretu.Nat
Assembly: Makaretu.Nat.dll
Syntax
public static class IPAddressExtensions
Remarks

IsPrivate(IPAddress) and IsPublic(IPAddress) determines if an IP address is reachable from the public internet; see RFC 1918 for more details.

Methods

| Improve this Doc View Source

IsPrivate(IPAddress)

Determines if the IP address belongs to a private internet.

Declaration
public static bool IsPrivate(this IPAddress address)
Parameters
Type Name Description
IPAddress address

The IP address to test.

Returns
Type Description
Boolean

true if the address is private; otherwise, false.

Remarks

RFC 1918 defines the following as private addresses (in CIDR notation)

  • 10/8
  • 172.16/12
  • 192.168/16

Loop back addresses are considered private.

If the address IsIPv4MappedToIPv6, then the IPv4 address is tested.

IPv6 ULA addresses are always private.

| Improve this Doc View Source

IsPublic(IPAddress)

Determines if the IP address does not belong to a private internet.

Declaration
public static bool IsPublic(this IPAddress address)
Parameters
Type Name Description
IPAddress address

The IP address to test.

Returns
Type Description
Boolean

true if the address is public; otherwise, false.

Remarks

This is the inverse of IsPrivate(IPAddress).

  • Improve this Doc
  • View Source
Back to top Generated by DocFX