---
name: "Net::ARP"
section: "3pm"
platform: "linux"
package: "libnet-arp-perl"
version: "1.0.12-1+b4"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Net::ARP"
---

# Net::ARP(3pm)

Perl extension for creating ARP packets

## NAME

ARP - Perl extension for creating ARP packets

## SYNOPSIS

```
  use Net::ARP;
  Net::ARP::send_packet('lo',                 # Device
                        '127.0.0.1',          # Source IP
                              '127.0.0.1',          # Destination IP
                                    'aa:bb:cc:aa:bb:cc',  # Source MAC
                              'aa:bb:cc:aa:bb:cc',  # Destinaton MAC
                              'reply');             # ARP operation
```

`$mac` = Net::ARP::get\_mac("enp3s0f1");

print "$mac\\n";

`$mac` = Net::ARP::arp\_lookup($dev,"192.168.1.1");

print "192.168.1.1 has got mac `$mac`\\n";

### IMPORTANT

Version 1.0 will break with the API of PRE-1.0 versions,  because the return value of **arp\_lookup()** and **get\_mac()** will no longer be passed as parameter, but returned! I hope this decision is ok as long as we get a cleaner and more perlish API.

### DESCRIPTION

This module can be used to create and send ARP packets and to get the mac address of an ethernet interface or ip address.

- **send\_packet()**

  ```
    Net::ARP::send_packet('lo',                 # Device
                          '127.0.0.1',          # Source IP
                                '127.0.0.1',          # Destination IP
                                      'aa:bb:cc:aa:bb:cc',  # Source MAC
                                'aa:bb:cc:aa:bb:cc',  # Destinaton MAC
                                'reply');             # ARP operation
    I think this is self documentating.
    ARP operation can be one of the following values:
    request, reply, revrequest, revreply, invrequest, invreply.
  ```

- **get\_mac()**

  ```
    $mac = Net::ARP::get_mac("enp3s0f1");
    This gets the MAC address of the enp3s0f1 interface and stores
    it in the variable $mac. The return value is "unknown" if
    the mac cannot be looked up.
  ```

- **arp\_lookup()**

  ```
    $mac = Net::ARP::arp_lookup($dev,"192.168.1.1");
    This looks up the MAC address for the ip address 192.168.1.1
    and stores it in the variable $mac. The return value is
    "unknown" if the mac cannot be looked up.
  ```

## SEE ALSO

```
 man -a arp
```

## AUTHOR

```
 Bastian Ballmann [ balle@codekid.net ]
 http://www.codekid.net
```

## COPYRIGHT AND LICENSE

Copyright (C) 2004-2022 by Bastian Ballmann

License: GPLv2
