Source code upload
[framework/connectivity/dnsmasq.git] / contrib / static-arp / static-arp
1 #!/bin/sh
2
3 # Contributed by Darren Hoo <darren.hoo@gmail.com>
4
5 # If you use dnsmasq as DHCP server on a router, you may have
6 # met with attackers trying ARP Poison Routing (APR) on your
7 # local area network. This script will setup a 'permanent' entry
8 # in the router's ARP table upon each DHCP transaction so as to
9 # make the attacker's efforts less successful.
10
11 # Usage:
12 # edit /etc/dnsmasq.conf and specify the path of this script
13 # to  dhcp-script, for example:
14 #  dhcp-script=/usr/sbin/static-arp
15
16 # if $1 is add or old, update the static arp table entry.
17 # if $1 is del, then delete the entry from the table
18 # if $1 is init which is called by dnsmasq at startup, it's ignored
19
20 ARP=/usr/sbin/arp
21
22 # Arguments.
23 # $1 is action (add, del, old)
24 # $2 is MAC
25 # $3 is address
26 # $4 is hostname (optional, may be unset)
27
28 if [ ${1} = del ] ; then
29          ${ARP} -d $3
30 fi
31
32 if [ ${1} = old ] || [ ${1} = add ] ; then
33          ${ARP} -s $3 $2
34 fi
35