IP Functions
IP functions provide tools for evaluating and processing IPs and their constituent parts.
The examples for each function use the following notation:
- Square brackets (
[]
) indicate arrays. - Curly braces (
{}
) indicate groups. - Arrows (
==>
) separate inputs and outputs. Inputs are shown on the left side of the arrow. Outputs are shown on the right side of the arrow.
Any cidr
argument in an IP function should have a value between 1
and 32
.
Get Host
The Get Host
function returns the host port of the specified IP as an IP. The network portion is zeroed out. The CIDR value does not change.
Usage Information
Category | Details |
---|---|
Number of Arguments | 1 |
Mandatory Argument Names and Datatypes | IP : An IP from which to retrieve the host port.
|
Optional Argument Names and Datatypes | N/A |
Modifiers | N/A |
Output Datatype(s) | IP |
Examples
getHost("45.184.155.12/8") ==> "0.184.155.12"
getHost("45.184.155.12", cidr=32) ==> "0.0.0.0"
getHost("2001:0db8:85a3:0000:0000:8a2e:0370:7334")
getHost({<ip>,{ip>,...}}) ==> {<host ip>,<host ip>}
getHost([<ip>,{ip>,...}]) ==> [<host ip>,<host ip>]
Get Network
The Get Network
function returns the network portion of the specified IP as an IP. The host port is zeroed out.
If the CIDR argument is valid and non-null, and its value is less than the CIDR in the IP, then the argument CIDR is used. The CIDR used to get the network is the CIDR of the returned IP.
Usage Information
Category | Details |
---|---|
Number of Arguments | 2 |
Mandatory Argument Names and Datatypes | IP : An IP from which to retrieve the network portion.
|
Optional Argument Names and Datatypes | cidr : An integer indicating the CIDR to use. |
Modifiers | N/A |
Output Datatype(s) | IP |
Examples
getNetwork("45.184.155.12") ==> "45.184.155.12"
getNetwork("45.184.155.12", 8) ==> "45.0.0.0"
getNetwork("45.184.155.12", 35) ==>
getNetwork("2001:0db8:85a3:0000:0000:8a2e:0370:7334", 16) ==> "2001::"
getNetwork([]) ==> []
getNetwork([],16) ==> []
getNetwork({})
getNetwork({},{})
getNetwork({[],[],[]},12)
getNetwork({[],[],[]},{})
Get Supernet
The Get Supernet
function returns the smallest subnet that would contain all the entered IPs and IP ranges.
Usage Information
Category | Details |
---|---|
Number of Arguments | 1+ |
Mandatory Argument Names and Datatypes | arg : An IP or IP array.
|
Optional Argument Names and Datatypes | N/A |
Modifiers | ignore null (Default: True ): If set to True , null values are excluded from the subnet. Otherwise, null values are included, meaning the function returns null . |
Output Datatype(s) | IP |
Examples
TBD
In Subnet
The In Subnet
function checks whether the first IP is in the same network as the second IP (network IP).
Usage Information
Category | Details |
---|---|
Number of Arguments | 2 |
Mandatory Argument Names and Datatypes |
|
Optional Argument Names and Datatypes | N/A |
Modifiers | N/A |
Output Datatype(s) | Boolean |
If either ip1
or ip2
is an array, then the other argument must be a scalar value. There cannot be two arrays as input arguments at once.
IPv4 and IPv6 cannot be compared in the same function. Mixing these IP types in input arguments will return null
.
Examples
inSubnet("192.168.2.0", "192.168.2.0/14") ==>
inSubnet("192.168.2.0/14","192.168.2.0") ==>
inSubnet("192.168.2.0/24","192.168.2.0/25") ==>
inSubnet("192.168.2.0/25","192.168.2.0/24") ==>
inSubnet("192.168.2.0","192.168.2.5") ==>
inSubnet("192.168.2.0/24","192.168.2.0/24") ==>
inSubnet("192.168.2.0","2001:0000:130F:0000:0000:09C0:876A:130B") ==>
inSubnet("192.168.2.0",null) ==> null
inSubnet(["192.168.2.0/24","192.168.2.0/25","192.168.2.0/26"],"192.168.2.0/24") ==>
inSubnet({"192.168.2.0/24","192.168.2.0/25","192.168.2.0/26"},"192.168.2.0/24") ==>
inSubnet({"192.168.1.0/24","192.168.2.0/25","192.168.2.0/26"},{"192.168.2.0/24","192.168.2.0/25","192.168.2.0/26"})
Overlaps
The Overlaps
function checks whether the first IP is in the same network as the second IP (network IP).
Usage Information
Category | Details |
---|---|
Number of Arguments | 2 |
Mandatory Argument Names and Datatypes |
|
Optional Argument Names and Datatypes | N/A |
Modifiers | N/A |
Output Datatype(s) | Boolean |
If either ip1
or ip2
is an array, then the other argument must be a scalar value. There cannot be two arrays as input arguments at once.
IPv4 and IPv6 cannot be compared in the same function. Mixing these IP types in input arguments will return null
.
Examples
overlaps("192.168.2.0","192.168.2.0/14") ==> True
overlaps("192.168.2.0/14","192.168.2.0") ==> True
overlaps("192.168.2.0/24","192.168.2.0/25") ==> True
overlaps("192.168.2.0/25","192.168.2.0/24") ==> True
overlaps("192.168.2.0","192.168.2.5") ==> False
overlaps("192.168.2.0","2001:0000:130F:0000:0000:09C0:876A:130B") ==> null
overlaps("192.168.2.0",null) ==> null
overlaps(["192.168.1.0/24","192.168.2.0/25","192.168.2.0/26"],"192.168.2.0/24") ==> [False, True, True]
overlaps({"192.168.1.0/24","192.168.2.0/25","192.168.2.0/26"},"192.168.2.0/24") ==> |False, True, True|
overlaps({"192.168.1.0/24","192.168.2.0/25","192.168.2.0/26"},{"192.168.2.0/24","192.168.2.0/25","192.168.2.0/26"}) ==> {False, True, True}