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 key features:

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


Install the released version from CRAN with:


Install the development version from GitHub with:

# install.packages("remotes")


Use ip_address() and ip_network() to create standalone vectors or data frame columns.


address <- ip_address(c("", "2001:db8::8a2e:370:7334"))
network <- ip_network(c("", "2001:db8::/80"))

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

It looks like we’ve simply stored the character vector, but we’ve actually validated each input and stored its native bit representation. When the vector is displayed, the print() method formats each value back to the human-readable character representation. There are two main advantages to storing IP data in their native bit representation:

Read vignette("ip-data") to learn more about these vector classes. For a demonstration of common recipes using ipaddress vectors and functions, see vignette("recipes").

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 June 22, 2024, 6:54 p.m.