Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

ip_to_hostname

Translate address to/from hostname


Description

Perform reverse and forward DNS resolution.

Note: These functions are significantly slower than others in the ipaddress package.

Usage

ip_to_hostname(x, multiple = FALSE)

hostname_to_ip(x, multiple = FALSE)

Arguments

x
  • For ip_to_hostname(): An ip_address vector

  • For hostname_to_ip(): A character vector of hostnames

multiple

A logical scalar indicating if all resolved endpoints are returned, or just the first endpoint (the default). This determines whether a vector or list of vectors is returned.

Details

These functions require an internet connection. Before processing the input vector, we first check that a known hostname can be resolved. If this fails, an error is raised.

If DNS lookup cannot resolve an input, then NA is returned for that input. If an error occurs during DNS lookup, then a warning is emitted and NA is returned for that input.

DNS resolution performs a many-to-many mapping between IP addresses and hostnames. For this reason, these two functions can potentially return multiple values for each element of the input vector. The multiple argument control whether all values are returned (a vector for each input), or just the first value (a scalar for each input).

Value

  • For ip_to_hostname(): A character vector (multiple = FALSE) or a list of character vectors (multiple = TRUE)

  • For hostname_to_ip(): A ip_address vector (multiple = FALSE) or a list of ip_address vectors (multiple = TRUE)

See Also

The base function nsl() provides forward DNS resolution to IPv4 addresses, but only on Unix-like systems.

Examples

## Not run: 
hostname_to_ip("r-project.org")

ip_to_hostname(hostname_to_ip("r-project.org"))

## End(Not run)

ipaddress

Tidy IP Addresses

v0.5.1
MIT + file LICENSE
Authors
David Hall [aut, cre] (<https://orcid.org/0000-0002-2193-0480>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.