ip_in_range checks whether a vector of IP addresses fall within particular IP range(s).

ip_in_range(ip_addresses, ranges)

Arguments

ip_addresses
a vector of IP addresses
ranges
either a vector of ranges equal in length to ip_addresses, or a single range. If the former, ip_in_range will compare each IP to the equivalent range. If the latter, each IP will be compared to the single range provided.

Value

a logical vector, where TRUE indicates the relevant IP is in the range, and FALSE indicates that the IP is not in the range, or is an invalid IP address.

See also

range_boundaries for identifying the minimum and maximum IPs within a range, and validate_range for validating that a range exists.

Examples

#Is this in the range? Yes! ip_in_range("172.18.0.1","172.18.0.0/28")
#> [1] TRUE #>
#[1] TRUE