Skip to contents

Lists the IPv4 neighbors (other devices in the local network) that this machine has recently talked to, with their MAC addresses, as stored in the operating system ARP cache. Combined with lookup_vendor(), it helps to identify the devices in a network.

Usage

get_arp_table()

Value

A data frame with columns ip, mac (normalized, see normalize_MAC()) and interface (on Windows, the IP address of the interface). Incomplete entries are dropped. If the table cannot be read, a warning is given and a data frame with no rows is returned.

Details

Works on Linux (reads /proc/net/arp), macOS and other Unix systems (parses arp -an) and Windows (parses arp -a). Only the existing cache is read: no packets are sent, so devices that have not communicated with this machine recently are not listed.

See also

get_MAC() for the addresses of this device.

Examples

arp <- get_arp_table()
head(arp)
#>         ip               mac interface
#> 1 10.1.0.1 12:34:56:78:9A:BC      eth0

# \donttest{
# Manufacturer of each neighbor (needs an internet connection once)
oui <- try(get_oui_registry(cache_dir = tempdir()))
#> Downloading https://standards-oui.ieee.org/oui/oui.csv
#> Downloading https://standards-oui.ieee.org/oui28/mam.csv
#> Downloading https://standards-oui.ieee.org/oui36/oui36.csv
if (is.data.frame(oui)) arp$vendor <- lookup_vendor(arp$mac, oui)
# }