= Adsl Check =
This guide explain how to configure your router for automatic delete/insert the 0.0.0.0/0.0.0.0 and the static default route if your adsl is temporarily fault.

== Create adsl_check script ==
Create the file /bin/adsl_check and insert the follow script

(Please find here the latest version https://github.com/ninuxorg/misc_tools/tree/master/adsl_check )

{{{#!bash
#!/bin/sh

# Release under the GPLv3 Licence
#
# @AUTHORS: Clauz (clauz@ninux.org), Hispanico (marco.giuntini@gmail.com), Stefano (stefano@ninux.org)
# 

IP_PING=8.8.8.8 #Address to check ADSL Connection
ADSL_GW='192.168.1.254' #Address of ADSL Gateway
RT_TABLE=check #Name of the new routing table for check
RT_TABLE_NUM=201 #Number of the routing table for check

grep $RT_TABLE /etc/iproute2/rt_tables || (echo $RT_TABLE_NUM $RT_TABLE >> /etc/iproute2/rt_tables)
ip route add table $RT_TABLE default via $ADSL_GW

(ip rule show | grep -F $IP_PING) || ip rule add to $IP_PING table $RT_TABLE 

while [ 1 ]; do
if ping -q -c 1 $IP_PING >/dev/null 2>/dev/null; then
	(ip r s |grep -F $ADSL_GW >/dev/null) || ip route add default via $ADSL_GW
else
	(ip r s |grep -F $ADSL_GW >/dev/null) && ip route del default via $ADSL_GW
fi
sleep 50
done
}}}

Create the init script /etc/init.d/adsl_check
{{{#!bash
#!/bin/sh /etc/rc.common
START=50

start() {

adsl_check &

}

stop() {

killall adsl_check

}
}}}

Set files permissions 
{{{#!bash
chmod +x /bin/adsl_check
chmod +x /etc/init.d/adsl_check
}}}

== Install and Configure olsr_dyn_gw Plugin ==
Install olsr_dyn_gw plugin
{{{
opkg update
opkg install olsrd-mod-dyn-gw
}}}

Add the follow line in olsrd.conf
{{{
config	LoadPlugin
	option	library	olsrd_dyn_gw.so.0.5
        option  Interval 50
        option	Ping  78.47.48.238
}}}

== Enable and Start ==
Reload olsrd
{{{
/etc/init.d/olsrd stop
/etc/init.d/olsrd start
}}}

Enable and start adsl_check script
{{{
/etc/init.d/adsl_check enable
/etc/init.d/adsl_check start
}}}