[BusyBox] A simple APIPA script

Tony Gaddis tony_gaddis95 at yahoo.com
Tue Mar 15 05:13:21 UTC 2005


I have implemented a simple minded version of microsoft's APIPA as a script for udhcpc, sample.leasefail. It will assign an address in the 168.254.x.x space. This can be used for systems that maybe plugged into an APIPA style network or dhcp style. Here it is:

# Sample udhcpc leasefail script

INTERFACE=eth0

IP="168.254"

ADDRESS="10"

NETMASK="netmask 255.255.0.0"

BROADCAST="broadcast 168.254.255.255"

ADD_SET=false

while [ $ADD_SET = "false" ] && [ $ADDRESS -lt 16 ]

do

arping -D -c 2 $IP.$ADDRESS.$ADDRESS

if [ $? = 0 ]

then

/sbin/ifconfig $INTERFACE $IP.$ADDRESS.$ADDRESS $BROADCAST $NETMASK

ADD_SET=true

echo "Setting APIPA style IP address"

else

ADDRESS=`expr 1 + $ADDRESS`



fi

done

#if fail to set address then set if to 0.0.0.0

if [ $ADD_SET = "false" ]

then

/sbin/ifconfig $INTERFACE 0.0.0.0

echo "Setting IP address to 0.0.0.0"

fi

echo "Setting default gw to 0.0.0.0"

/sbin/route del default gw 0.0.0.0 dev $INTERFACE

 

Thoughts, feedback, usage welcome.

Thanks

Tony


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.busybox.net/pipermail/busybox/attachments/20050314/ac7267d9/attachment.htm 


More information about the busybox mailing list