TP-LINK TL-WR1043ND 3G failover / fallover

Post new topic   Reply to topic    DD-WRT Forum Index -> Atheros WiSOC based Hardware
Author Message
plazma
DD-WRT User


Joined: 22 Feb 2012
Posts: 68

PostPosted: Tue Jan 08, 2013 19:56    Post subject: TP-LINK TL-WR1043ND 3G failover / fallover Reply with quote
Hi, ive recently purchased a TL-WR1043ND and now i have a goal to provide a solution to getting a 3G usb stick/dongle working as a failover/fallover should the main wan connection stop working.

Im already aware this has been asked before and no solution was ever posted (that i can find).

Ive found a few places with scripts to run the fail over where people have been using them for dual wan configs and it should be possible to re-write them to suit.

So far ive tested the 3G dongle with manually setting the wan port to 3G and removing the wan cable and i was able to make a connection across 3G (so that worked fine).

Next as the 3g stick also supports a microsd slot ive been able to work out how to get this to mount correctly on boot time so im able to use if for the failover script.

Now this is where i need some help.

I cant get usb_modeswitch working the details are:

Vendor=12d1 ProdID=140c

Works fine when the dd-wrt calls it and the microsd keeps working, however i cant find a command that works to do the initial mode switch into modem mode (serial), although i might not need this, will come back to that later.

Forgetting this for the second, i worked around the issue for the time being and started the router with 3g on and then switch back to the wan port and deleted the default route for the wan port (leaving no default router until ppp starts), this allowed me to test a little further as the stick was in modem mode still.

It appears looking at the router when its in 3g mode that calling:

pppd /tmp/ppp/options.ppp

Brings up the ppp0 interface correctly and it even appears i can ping/traceroute out against it, but no where in the process can i see where its calling the APN and thus the internet fails to work past igmp (ping etc).

I had planned to use two scripts on my microsd mounted on jffs:

/dev/usb/tts/0
460800
lock
crtscts
modem
passive
novj
defaultroute
noipdefault
usepeerdns
noauth
hide-password
persist
holdoff 10
maxfail 0
user o2web
password password
debug
connect '/jffs/usr/sbin/chat -t3 -f /jffs/etc/ppp/peers/isp_chat'


and connect by calling the chat script :

ABORT BUSY
ABORT 'NO CARRIER'
ABORT ERROR
REPORT CONNECT
TIMEOUT 12
"" "AT&F"
OK "ATE1"
'OK' 'AT+CGDCONT=1,"IP","mobile.o2.co.uk"'
ABORT 'NO CARRIER'
TIMEOUT 15
'OK' 'ATDT*99#'
CONNECT ' '


However this never brings up the ppp0 interface and appears to just sit there doing nothing.

I can see it might be a pain make it work the way i want.

So the other way i can see this working is to have it 3g effectively on all the time (being the primary connection) and then scripting the wan interface post router boot up to come up configured for dhcp and switch to become the primary. With the failover removing the hard wired wan as the default gateway when it stops working and allowing the 3g connection to take over, this might be easier to do and others replicate. Primarily as the the 3g works great using dd-wrt interface and it makes it easy to configure (no messing around with bespoke usb_modeswitch for everyone's different 3g/4g dongle).

I can see that the details for the 3g connection are left in nvram even after ive switched back to normal wan mode, which begs the question which setting in nvram decides which connection is getting used. So would it be possible instead (and far easier) to have the script monitor the wan and on fail toggle the wan type to 3g then call the 3g ppp startup script. The issue here being keeping the wan open so it can be checked whilst the 3g is brought up and used.

Has anyone already attempted this and got it working if so can you detail how you did it.

If not could someone help me move it a little bit further forward?

My Goal is once a this has been made to work, is to post/write up the entire solution back to this thread so others can re-use.
Sponsor
Sash
DD-WRT Guru


Joined: 20 Sep 2006
Posts: 17619
Location: Hesse/Germany

PostPosted: Wed Jan 09, 2013 10:46    Post subject: Reply with quote
upgrade 1st
_________________
Forum Guidelines...How to get help
&
Forum Rules
&
RTFM/STFW
&
Throw some buzzwords into the WIKI search Exclamation
_________________
I'm NOT rude, just offer pure facts!
_________________
Atheros (TP-Link & Clones, etc ) debrick service in EU
_________________
Guide on HowTo be Safe, Secure and Protect Your Online Anonymity!
plazma
DD-WRT User


Joined: 22 Feb 2012
Posts: 68

PostPosted: Wed Jan 09, 2013 11:02    Post subject: Version Reply with quote
Hi Sash,

Sorry forgot to say in the above post, im running DD-WRT v24-sp2 build 20453 so im as updated as i can be.

Note i didn't have the wan/lan light issues on this firmware as some have reported.

Like i said through the interface i can get 3g to work, but i need to either be able to manually bring it up / down or to be able to let the router do this and then be able to manually configure the wan interface for dhcp and over ride the primary.
FaustoDT
DD-WRT Novice


Joined: 26 Nov 2013
Posts: 5

PostPosted: Tue Nov 26, 2013 13:30    Post subject: Reply with quote
Hello,

I have been a lurker in these forums for a very long time and have been happily running DD-WRT on my E3000 for going on 3 years now.

I have always wanted to have my router manage automatic 3G failover - I live in South Africa and suffer from frequent internet (ADSL) outages as a result of cable theft. I have searched the forums for a solution but none are available or are not catering for what I believe the requirement is. Essentially a failover to 3G when the primary WAN goes down and then a switch back to the primary WAN when it is available again (given the costs and speed of 3G connections)

I have been able to get this to work, not a very elegant solution but it does seem to work 95% of the time. Sure, the scripting can be tidied up, I'm an accountant incidentally so apologies for the code and "baby language" scripting.

I have where necessary taken ideas and code from the 4 dual WAN wiki entries.
Dual WAN with failover
Dual WAN with one as standby backup
Cellular Phone/USB Modem as WAN connection
Dual WAN with failover WITHOUT JFFS

The issue I found with the wiki entries is that none of them specifically attended to pppd connections to an ISP and DHCP assigned ip addresses together with gateway addresses that are not static or accept ping requests.

I am currently running a Linksys E3000 router (DD-WRT v24-sp2 (04/09/11) mega - build 16758M NEWD-2 K2.6 Eko) with primary WAN set us as pppoe to my ISP and a Huawei E220 USB modem plugged into a USB port on a USB hub. I have also installed optware the right way 2 on a USB drive also connected to the USB hub. JFFS also set up on approx 200kb running some startup scripts.

Step by step:
On startup the /jffs/etc/config/*.startup scripts are executed. Important one being the 3G.startup script - this essentially takes the existing dnsmasq.conf file in the routers /tmp directory and edits it to include a pointer to a different resolv-file (which will be used when the 3G connection is brought up - but you will see that later). The script also loads the required 3G modules and starts the important 3G.sh script (which is the failover script).
There are other startup scripts in the /jffs directory with the next important one being the firewall script fw.sh

The 3G.sh script monitors the primary WAN by pinging 4 defined DNS servers, when the WAN goes down the 3G connection is brought up on ppp99 using the options.pppoe file in the files directory. Furthermore, the relevant DNS servers (ISP assigned) are symbolically linked in the /tmp directory (to ensure DNS works) and the firewall script is run to ensure the correct interfaces are included in the iptables rules (hence the fixing of the 3G pppd interface number to ppp99)

Once the 3G connection is up, the script monitors the primary WAN connection to see if it comes back up. Once the primary WAN is back up the router terminates the 3G connection and restores the primary WAN connection - starting the loop again. I have included a flowchart of the failover script. Again like I said not very elegant but it does work.

I have included a script called ChangeWAN.sesbutton that allows you to switch the WAN using the SES EZSETUP button - still experimental. There are a lot of other files which you can edit for your own purposes i.e. emailing failover stats.

It has been a lot of fun putting this together and I look forward to watching the ingenious edits to my scripts and setup over the next coming weeks and months from the relevant forum members.

Cheers,
Fausto Di Trapani
PeteSL
DD-WRT User


Joined: 01 May 2007
Posts: 98

PostPosted: Sat Mar 07, 2015 11:28    Post subject: Reply with quote
FaustoDT wrote:
Hello,

I have been able to get this to work, not a very elegant solution but it does seem to work 95% of the time. Sure, the scripting can be tidied up, I'm an accountant incidentally so apologies for the code and "baby language" scripting.

...It has been a lot of fun putting this together and I look forward to watching the ingenious edits to my scripts and setup over the next coming weeks and months from the relevant forum members.

Cheers,
Fausto Di Trapani
Hopefully you still monitor this forum. Where are the scripts, etc. that you talk about? This is exactly what I am looking for as our ISP (wireless rural USA) is very unreliable and takes days to dispatch service when their equipment fails.

Thanks,

Pete
PeteSL
DD-WRT User


Joined: 01 May 2007
Posts: 98

PostPosted: Mon Mar 09, 2015 3:54    Post subject: Reply with quote
Never mind. Call me blind. Just downloaded the zip file. Thanks!
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Atheros WiSOC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum