Joined: 06 Mar 2008 Posts: 92 Location: South East Asia
Posted: Thu Sep 04, 2008 8:43 Post subject: Help needed how to renew DHCP every 25 or 20minutes
Hi i got some problem here. My router connected to my ISP through wifi connection. Lease time is 30minutes. But the problem is after 30minutes it takes time to update the ip lease time. so after 3ominutes i always get disconnected then after 1-2minutes connection will be ok again.
how do i write a custom script so that it auto DHCP re-new every 20 or 25minutes so that i wont get disconnected after 3omin.
My Spec:
Buffalo WHR-G54S
Repeater mode
V24 SP1 final
currently using this script. but no luck so far :(
ME=`basename $0`
RUNNING=`ps | awk '/'"$ME"'/ {++x}; END {print x+0}'`
if [ "$RUNNING" -gt 3 ]; then
echo "Another instance of \"$ME\" is running"
exit
fi
My Copperjet 816-2P runs in ZipB-mode (Alcatel calls it DHCP-spoof) and gives its WAN-IP to a local host.
Somehow it doesn't work after a restart of the modem, so I wrote a cronjob to check my Internet acces and if it fails, it will login to the modem using telnet and reconfigure my modem.
My scripting improved in the mean time, but it still works:
Code:
# cat /tmp/custom.sh
#!/bin/sh
pingip=66.249.93.99
result=`ping -c 1 172.19.3.1 | grep -c from`
if [ $result == 0 ]; then
logger -t 'ModemCheck' 'No modem.. restart WAN'
echo 'No modem.. restart WAN' | tee -a /jffs/zipB.log
stopservice wan
startservice wan
else
if [ ! -f /tmp/fail_count ]; then
echo "" >/tmp/fail_count
fi
result=`grep -c x /tmp/fail_count`
if [ $result -ge 3 ]; then
date >>/jffs/zipB.log
echo "tried $result times" | tee -a /jffs/zipB.log
logger -t 'ModemCheck' 'After $result tries the modem is not functioning... will reboot'
(sleep 1; echo -e "admin\r"; sleep 1; echo -e "admin\r"; sleep 1; echo -e "system restart\r") | telnet 172.19.3.1
echo "" > /tmp/fail_count
else
result=`ping -c 1 $pingip | grep -c from`
if [ $result == 0 ]; then
date >>/jffs/zipB.log
echo "rewriting zipB.." | tee -a /jffs/zipB.log
echo "x" >>/tmp/fail_count
logger -t 'ModemCheck' 'Modem not functioning... rewrite ZipB'
(sleep 1; echo -e "admin\r"; sleep 1; echo -e "admin\r"; sleep 1; echo -e "zipb set public device WAN\r"; sleep 1; echo -e "user logout\r") | telnet 172.19.3.1
stopservice wan
startservice wan
else
echo "Modem alright"
logger -t 'ModemCheck' 'Modem alright'
echo -n "" > /tmp/fail_count
fi
fi
fi
_________________ Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge
In Administration -> Commands
paste the following and press "Save Custom Script"
Code:
#!/bin/sh
pingip=66.249.93.99
result=`ping -c 1 $pingip | grep -c from`
if [ $result == 0 ]; then
date >>/jffs/zipB.log
echo "$pingip not reachable.. DHCP renew" | tee -a /jffs/dhcp.log
stopservice wan
startservice wan
fi
_________________ Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge