Learn R Programming

iptools (version 0.7.2)

ip_in_range: check if IP addresses fall within particular IP ranges

Description

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

Usage

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

Run this code
# NOT RUN {
#Is this in the range? Yes!
ip_in_range("172.18.0.1","172.18.0.0/28")
#[1] TRUE

# }

Run the code above in your browser using DataLab