10

I have some pretty dumb IP devices on a subnet with my Ubuntu server, and the server receives streaming data from each device. I have run into a problem in that when an ARP request is issued to the device while it is streaming data to the server, the request is ignored, the cache entry times out and the server stops receiving the stream.

So, to prevent the server from sending ARP requests to these devices altogether, I would like to add a static ARP entry for each, something like

arp -i eth2 -s ip.of.the.device mac:of:the:device

But these "static" ARP entries are lost if networking is disabled / enabled or if the server is rebooted. Where is the best place to automatically add these entries, preferably somewhere that will re-add them every time the interface eth2 is brought up?

I really don't want to have to write a script that monitors the output of arp and re-adds the cache entries if they're missing.


Edit to add what my final script was:

Created the file

 /etc/network/if-up.d/add-my-static-arp

With the contents:

#!/bin/sh

arp -i eth0 -s 192.168.0.4 00:50:cc:44:55:55
arp -i eth0 -s 192.168.0.5 00:50:cc:44:55:56
arp -i eth0 -s 192.168.0.6 00:50:cc:44:55:57

And then obviously add the permission to allow it to be executed:

chmod +x /etc/network/if-up.d/add-my-static-arp

And these arp entries will be manually added or re-added every time any network interface is brought up.

John Lyon
  • 1,041

2 Answers2

12

Take a look at the scripts in /etc/network/if-up.d. Those are called every time an interface goes to up state. You can create a script with the needed commands and put it there.

5
/etc/ethers

This file must contain:

mac    ip-address
Seth
  • 59,332
crester
  • 51