#! /bin/sh - # # proxy-arp Set proxy-arp settings in arp cache # # chkconfig: 2345 15 85 # description: using the arp command line utility, populate the arp # cache with IP addresses for hosts on different media # which share IP space. # # - cleaned up and commented extensively # - joined the process parsimony bandwagon, and eliminated # many unnecessary calls to ifconfig and awk # gripe () { echo "$@" >&2; } abort () { gripe "Fatal: $@"; exit 1; } CONFIG=${CONFIG:-/etc/proxy-arp.conf} [ -r "$CONFIG" ] || abort $CONFIG is not readable case "$1" in start) # -- create proxy arp settings according to # table in the config file # grep -Ev '^#|^$' $CONFIG | { while read INTERFACE IPADDR ; do [ -z "$INTERFACE" -o -z "$IPADDR" ] && continue arp -s $IPADDR -i $INTERFACE -D $INTERFACE pub done } ;; stop) # -- clear the cache for any entries in the # configuration file # grep -Ev '^#|^$' /etc/proxy-arp.conf | { while read INTERFACE IPADDR ; do [ -z "$INTERFACE" -o -z "$IPADDR" ] && continue arp -d $IPADDR -i $INTERFACE done } ;; status) arp -an | grep -i perm ;; restart) $0 stop $0 start ;; *) echo "Usage: proxy-arp {start|stop|restart}" exit 1 esac exit 0 # ]]> # - end of proxy-arp