Page 1 of 1

Backup PPPoE connection

Posted: Thu Mar 23, 2006 9:55 pm
by MikroManagement
I want to switch to my backup PPPoE connection as soon as my ADSL connection drops on the one line.

Actually the setup is more complex, I use 2x ADSL PPPoE connections to differentiate between local and international traffic. There are periods where both these connection cannot connect - I have acquired a connection on a different provider and would like to use this connection as a backup.

Can someone please help me to write a script that will basically works as follows?
Every 5 min
check if default PPPoE connection ip active (Running / IP address not nil)
if nil, then
Disable my routing scripts
Enable backup PPPoE connection
else
Disable backup PPPoE connection

I don't want to use the backup PPPoE all times - more expensive than my normal connection and don't want to do any sort of load balancing between these two gateways

Posted: Thu Mar 23, 2006 11:59 pm
by RoddyZ
Create the follow script and a scheduler each 5m to run it.



:global pppoe1-interface YourPppoe1InterfaceName
:global pppoe1-name YourPppoe1ConnectionName
:global pppoe2-name YourPppoe2ConnectionName

/interface pppoe-client enable [find name=$pppoe1-name]
:delay 5

:local pppoe1-ip [ /ip address get [/ip address find interface=$pppoe1-interface] address ]

:if ([ :typeof $pppoe1-ip ] != nil ) do={
:log info ("Conected to " . $pppoe1-name)
/interface pppoe-client disable [find name=$pppoe2-name]
} else={
:log info ("Connected to " . $pppoe2 -name)
/interface pppoe-client enable [find name=$pppoe2-name]
/interface pppoe-client disable [find name=$pppoe1-name]
}



-RoddyZ

Posted: Tue Mar 28, 2006 9:07 pm
by MikroManagement
Thanks!

Posted: Sun Sep 03, 2006 12:48 am
by MikroManagement
Refer to http://forum.mikrotik.com/viewtopic.php?t=10623 for an more updated version.

Posted: Wed Jan 10, 2007 11:14 pm
by MikroManagement
:local pppoe1-name ADSL_Saol0


:local pppoe2-name IBurst


:local dns-name smtp.isdsl.net

:local dns-ip [/ip dns static get [/ip dns static find name $dns-name] address]

:local pppoe1-status ([/interface pppoe-client get [/interface pppoe-client find name $pppoe1-name] running ])


:local pppoe2-status ([/interface pppoe-client get [/interface pppoe-client find name $pppoe2-name] running ])





:local pppoe2-dg ([/interface pppoe-client get [/interface pppoe-client find name $pppoe2-name] add-default-route])


:local pppoe2-dns ([/interface ppoe-client get [/interface pppoe-client find name $pppoe2-name] use-peer-dns])



:if ($pppoe1-status = false) do {/interface pppoe-client enable [/interface pppoe-client find name $pppoe1-name]
:if ($pppoe2-dg = false) do [/interface pppoe-client set [/interface pppoe-client find name $pppoe2-name] add-default-route=yes]


:if ($pppoe2-dns = false) do [/interface pppoe-client set [/interface pppoe-client find name $pppoe2-name] use-peer-dns=yes]


:if ($pppoe2-status = false) do [/interface pppoe-client enable [/interface pppoe-client find name $pppoe2-name]]
:if ($dns-ip = 196.26.208.190) do [/ip dns static set [/ip dns static find name $dns-name] address 196.30.31.207]
:log info "Running on IBurst!"} else={:if ($pppoe2-dg = true) do [/interface pppoe-client set [/interface pppoe-client find name $pppoe2-name] add-default-route=no]


:if ($pppoe2-dns = true) do [/interface pppoe-client set [/interface pppoe-client find name $pppoe2-name] use-peer-dns=no]


:if ($pppoe2-status = false) do [/interface pppoe-client enable [/interface pppoe-client find name $pppoe2-name]]
:if ($dns-ip = 196.30.31.207) do [/ip dns static set [/ip dns static find name $dns-name] address 196.26.208.190]
}