Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
    
I don't have the rep to add "arp" as a tag, so apologies for that. –  jozzas Jan 24 '11 at 7:04
    
I see in older versions of Ubuntu I could add an entry to /etc/sysconfig/network-scripts/ifup-post, but it doesn't look like this is the way things are done any more. Where would ifup-post live in 10.04? –  jozzas Jan 24 '11 at 7:06
    
can you post your script snippet here once you have it working? –  belacqua Jan 25 '11 at 15:29
    
@jgbelacqua -- done, thanks for the suggestion. –  jozzas Feb 27 '11 at 22:59

2 Answers 2

up vote 7 down vote accepted

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.

share|improve this answer
    
This worked perfectly, thanks. –  jozzas Jan 24 '11 at 22:30
1  
Make sure your scripts don't have a ".sh" extension, otherwise they won't run. –  Mihai Capotă Jan 8 '12 at 7:46
/etc/ethers

This file must contain:

mac    ip-address
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.