How to keep a list of permanent ARP entries

Keep a list of permanent ARP entries using the arp utility.

Install net-tools package.

$ sudo apt install net-tools

Store permanent ARP entries in a /etc/ethers file.

$ cat <<EOF | sudo tee /etc/ethers 01:00:00:02:00:0a 01:00:00:02:00:0b 01:00:00:02:00:0c

Create a service file to load these entries.

$ cat <<EOF | sudo tee /etc/systemd/system/permanent-arp.service
Description=Load permanent ARP entries

ExecStart=/usr/bin/bash -c "/usr/bin/sleep 5; /usr/sbin/arp -f /etc/ethers"


Reload systemd manager configuration.

$ sudo systemctl daemon-reload

Start and enable service.

sudo systemctl enable --now permanent-arp

Inspect service status.

$ sudo systemctl status permanent-arp
‚óŹ permanent-arp.service - Load permanent ARP entries
     Loaded: loaded (/etc/systemd/system/permanent-arp.service; enabled; vendor preset: enabled)
     Active: active (exited) since Fri 2021-07-23 07:37:57 UTC; 18s ago
    Process: 313 ExecStart=/usr/bin/bash -c /usr/bin/sleep 5; /usr/sbin/arp -f /etc/ethers (code=exited, status=0/SUCCESS)
   Main PID: 313 (code=exited, status=0/SUCCESS)
        CPU: 4ms

Jul 23 07:37:52 bullseye systemd[1]: Starting Load permanent ARP entries...
Jul 23 07:37:57 bullseye systemd[1]: Finished Load permanent ARP entries.

Display ARP entries.

$ sudo arp -a
? ( at 52:54:00:12:35:02 [ether] on eth0
? ( at 01:00:00:02:00:0a [ether] PERM on eth0
? ( at 52:54:00:12:35:03 [ether] on eth0
? ( at 01:00:00:02:00:0c [ether] PERM on eth0
? ( at 01:00:00:02:00:0b [ether] PERM on eth0