status R build
status Coverage

ipaddress provides data classes and functions for working with IP addresses and networks. Its interface is inspired by the Python ipaddress module.

Here are some of the features:

For data visualization of IP addresses and networks, check out the ggip package.


You can install the released version of ipaddress from CRAN with:


Or you can install the development version from GitHub:

# install.packages("remotes")


Use ip_address() and ip_network() vectors either standalone or as columns in a data frame.


  address = ip_address(c("", "2001:db8::8a2e:370:7334")),
  network = ip_network(c("", "2001:db8::/80"))
#> # A tibble: 2 × 2
#>                   address          network
#>                 <ip_addr>       <ip_netwk>
#> 1   
#> 2 2001:db8::8a2e:370:7334    2001:db8::/80

Input character vectors are validated as they are parsed. Invalid inputs raise a warning and are replaced with NA.

ip_address(c("", ""))
#> Warning: Problem on row 2:
#> <ip_address[2]>
#> [1] <NA>

A variety of functions are provided to enable common tasks.

tibble(network = ip_network(c("", "2001:db8::/80"))) %>%
    first = network_address(network),
    last = broadcast_address(network),
    ipv6 = is_ipv6(network)
#> # A tibble: 2 × 4
#>            network         first                     last ipv6 
#>         <ip_netwk>     <ip_addr>                <ip_addr> <lgl>
#> 1 FALSE
#> 2    2001:db8::/80    2001:db8:: 2001:db8::ffff:ffff:ffff TRUE

Related work

Please note that the ipaddress project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Try the ipaddress package in your browser

Any scripts or data that you put into this service are public.

ipaddress documentation built on Aug. 12, 2022, 9:06 a.m.