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 10.0.2.10 01:00:00:02:00:0a 10.0.2.11 01:00:00:02:00:0b 10.0.2.12 01:00:00:02:00:0c EOF
Create a service file to load these entries.
$ cat <<EOF | sudo tee /etc/systemd/system/permanent-arp.service [Unit] Description=Load permanent ARP entries ConditionPathExists=/etc/ethers After=network-online.target [Service] Type=oneshot ExecStart=/usr/bin/bash -c "/usr/bin/sleep 5; /usr/sbin/arp -f /etc/ethers" RemainAfterExit=yes [Install] WantedBy=multi-user.target EOF
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
? (10.0.2.2) at 52:54:00:12:35:02 [ether] on eth0 ? (10.0.2.10) at 01:00:00:02:00:0a [ether] PERM on eth0 ? (10.0.2.3) at 52:54:00:12:35:03 [ether] on eth0 ? (10.0.2.12) at 01:00:00:02:00:0c [ether] PERM on eth0 ? (10.0.2.11) at 01:00:00:02:00:0b [ether] PERM on eth0