Class IPAddress
Provided as a type-safe alternative to passing raw IP strings into resource builders
(for example Network Edge BGP peering local/remote IPs, VPN peer/tunnel IPs, device
system IPs, and route-aggregation prefixes). Construct one from a literal address with
parse(String):
IPAddress peer = IPAddress.parse("203.0.113.10");
IPAddress network = IPAddress.parse("203.0.113.0/24");
String cidr = network.toCidr(); // "203.0.113.0/24"
parse(String) accepts literals only - a strict IPv4 dotted-quad or an
IPv6 address - and never performs a DNS lookup. Hostnames, legacy inet_addr
shorthand (e.g. "203.0.113") and malformed addresses are rejected with an
EquinixClientException.
- Author:
- ianjones
-
Method Details
-
parse
Parses a literal IPv4/IPv6 address, optionally in CIDR form (e.g."203.0.113.0/24").Validation is strict and purely local: IPv4 must be a full dotted-quad (four decimal octets, each 0-255) and IPv6 must be a valid RFC 4291 literal (including
::compression and embedded IPv4 forms). No DNS resolution is ever attempted, so a hostname such as"example.com"fails immediately. When a/<prefixLength>suffix is present it must be within0-32for IPv4 or0-128for IPv6.- Parameters:
value- the literal IP address, optionally suffixed with/<prefixLength>- Returns:
- a populated
IPAddress - Throws:
EquinixClientException- if the value is null/blank, not a literal IP address, or has an out-of-range subnet prefix
-
getHostAddress
- Returns:
- the numeric host address
-
toString
-
toCidr
Returns the address in CIDR notation (host/subnet), or just the host if no subnet is set.- Returns:
- the CIDR (or host) string
-
equals
-
hashCode
-