<?xml version="1.0" encoding="utf-8"?><!DOCTYPE article  PUBLIC '-//OASIS//DTD DocBook XML V4.4//EN'  'http://www.docbook.org/xml/4.4/docbookx.dtd'><article><articleinfo><title>adsl_check</title><revhistory><revision><revnumber>7</revnumber><date>2016-12-01 20:38:28</date><authorinitials>BornAgain</authorinitials><revremark>quell'indirizzo di prima non funziona più</revremark></revision><revision><revnumber>6</revnumber><date>2016-11-05 17:55:29</date><authorinitials>BornAgain</authorinitials></revision><revision><revnumber>5</revnumber><date>2016-11-05 17:53:07</date><authorinitials>BornAgain</authorinitials></revision><revision><revnumber>4</revnumber><date>2012-07-29 12:16:47</date><authorinitials>ZioPRoTo</authorinitials></revision><revision><revnumber>3</revnumber><date>2011-11-25 12:16:36</date><authorinitials>Marco</authorinitials></revision><revision><revnumber>2</revnumber><date>2011-11-25 12:13:59</date><authorinitials>Marco</authorinitials></revision><revision><revnumber>1</revnumber><date>2011-11-25 12:12:11</date><authorinitials>Marco</authorinitials><revremark>Script ADSL Check</revremark></revision></revhistory></articleinfo><section><title>Adsl Check</title><para>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. </para><section><title>Create adsl_check script</title><para>Create the file /bin/adsl_check and insert the follow script </para><para>(Please find here the latest version <ulink url="https://github.com/ninuxorg/misc_tools/tree/master/adsl_check"/> ) </para><screen><![CDATA[#!/bin/sh
]]><![CDATA[
# Release under the GPLv3 Licence
#
# @AUTHORS: Clauz (clauz@ninux.org), Hispanico (marco.giuntini@gmail.com), Stefano (stefano@ninux.org)
# 
]]><![CDATA[
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
]]><![CDATA[
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
]]><![CDATA[
(ip rule show | grep -F $IP_PING) || ip rule add to $IP_PING table $RT_TABLE 
]]><![CDATA[
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]]></screen><para>Create the init script /etc/init.d/adsl_check </para><screen><![CDATA[#!/bin/sh /etc/rc.common
START=50
]]><![CDATA[
start() {
]]><![CDATA[
adsl_check &
]]><![CDATA[
}
]]><![CDATA[
stop() {
]]><![CDATA[
killall adsl_check
]]><![CDATA[
}]]></screen><para>Set files permissions  </para><screen><![CDATA[chmod +x /bin/adsl_check
chmod +x /etc/init.d/adsl_check]]></screen></section><section><title>Install and Configure olsr_dyn_gw Plugin</title><para>Install olsr_dyn_gw plugin </para><screen><![CDATA[opkg update
opkg install olsrd-mod-dyn-gw]]></screen><para>Add the follow line in olsrd.conf </para><screen><![CDATA[config  LoadPlugin
        option  library olsrd_dyn_gw.so.0.5
        option  Interval 50
        option  Ping  78.47.48.238]]></screen></section><section><title>Enable and Start</title><para>Reload olsrd </para><screen><![CDATA[/etc/init.d/olsrd stop
/etc/init.d/olsrd start]]></screen><para>Enable and start adsl_check script </para><screen><![CDATA[/etc/init.d/adsl_check enable
/etc/init.d/adsl_check start]]></screen></section></section></article>