When IP address conflict happens, both host sends ARP packet claiming the IP address, creating a race condition. This article shows a simple method of how to configure a Linux host to automatically win the race without user interaction. Readers are supposed to rely on their own ethics to decide when this should be used.
Yuri Volobuev's reputable artice on the topic of ARP and security
ARP and ICMP redirection games provided a short program source code
send_arp.c for generating arp packets, we need to use this
program to win the race.
Written more than a decade ago, the same source code work almostly the same way today. The first step is to copy send_arp.c source code from the referred article and compile the executable to /usr/local/sbin/send_arp. I found on my Ubuntu 10.04 I had to remove this line to get it correctly compiled:
#include <linux/in.h>
Upon IP address conflict, you can run send_arp with your IP address and your MAC address to win the race:
send_arp <YOUR IP ADDRESS> <YOUR MAC ADDRESS> 255.255.255.255 FF:FF:FF:FF:FF:FF
This command is effective for our need only when IP address conflict happens, thus we should run it from a script that is called when this happens.
ipwatchd is a daemon that can be configured to run a given script when it detectes its own IP address conflict with someone else's. Download and install the software and check this file:
/usr/sbin/ipwatchd-script
It is the default script to run on IP address conflict.
Add two lines of source code to an approprate place in the script so that it invokes send_arp a while later after IP address conflict. We do it "a while later", because by then the other host is likely not trying to win the race, perhaps thinking it has won.
sleep 3
/usr/local/sbin/send_arp $IP `ifconfig $1 | grep -o HWaddr.* | cut -d ' ' -f 2`\
255.255.255.255 FF:FF:FF:FF:FF:FF
This method is a fall-back technical measurement on failing to convince local network administrator to do their work. Fixing a mis-behaving computer with another mis-behaving computer is not the best way to solve a problem.