This shell script first checks any IP addresses marked as unusable to verify that they are not in use. If they are not, the script then reclaims the IP addresses.
#!/bin/ksh
# This shell script reclaims addresses which were marked as unusable, after
# first verifying that they're no longer in use.
if [ ${#} -eq 0 ]
then
echo "reclaim <network> ..." >&2
exit 1
fi
while [ ${#} -ne 0 ]
do
pntadm -P ${1} | awk ' $2 == 04 { printf("%s %s\n", $1, $3); }' |
while read cid addr
do
if [ ${?} -ne 0 ]
then
pntadm -M ${addr} -i 00 -f DYNAMIC -e 0 ${1}
if [ ${?} -eq 0 ]
then
echo "${addr} has been reclaimed from client ${cid}."
fi
else
echo "${addr} is in use!" >&2
fi
done
shift
done
exit 0
|