Tuesday, May 07, 2024

It's Alive

Huh 9 years later and single post. Watch this space.

Friday, June 12, 2015

Raspberry PI turns EE Osprey Mifi into automatic back up connection for Home or Office Broadband

I have a 39Mbps Down 10Mbps up FTTC broadband connection. These days that is nothing to shout about unless it stops working.  If your business has experienced a prolonged outage you have probably muddled through with 3G dongles/phone tethering/home or cafe working. If you are a big enough organisation to have an IT person or tills that only work if the internet does then you have a redundant backup link and a plan.  Surely you do don't you ?


I aspired to do better and have a seamless fail-over solution at home. Spouses and children show far less restraint and far more anger when asking is it fixed yet every two  minutes than the usual client.

This is how I achieved it for zero increase in my monthly cost:-
EE provides my FTTC broadband
The broadband package comes with a free 10 Gig per month upgrade to my 4g pay monthly phone plan.
EE allows me to share the 4G data allowance with all devices on my plan.
EE gave my a MIFI unit last week for free so no ongoing monthly charge as it shares my data plan.

Upstairs in back bedroom the Mifi unit gets a fairly reliable 12Mbps down 5Mbps up over  4G

If only it had an ethernet port it would be perfect as a backup route for my home network.  The challenge was to use a Rasperry pi to bridge the USB interface to its Ethernet port and use a Homeplug to get it to accept packets from the downstairs FTTC router when phone line was unplugged.

I now have this working:-  The necessary networking ingredients incantations and magic are as follows:-


my lan network is 192.168.9.0/24
my FTTC router is 192.168.9.1/24 an Ubiquiti Edge Router POE but other makes are available. (cough cisco).

EE Osprey Mifi 

configured to No DHCP and 192.168.9.2/24 via its web gui

Edgerouter additional commands

set firewall receive-redirects disable

*because otherwise router will send an ICMP redirect if it routes a packet out of the same interface and attached PC will then use backup link even if main link comes back up.

set interfaces ethernet eth0 pppoe 0 default-route force

*because I found in testing that the default route wouldn't always come back into the kernel routing table when the FTTC link re-established

set protocols static interface-route 0.0.0.0/0 next-hop-interface pppoe0 distance 10
set protocols static route 0.0.0.0/0 next-hop 192.168.9.2 distance 20

* the magic routing. The osprey will NAT anyway so no point having a dedicated WAN port to talk to it. Your firewall requirement mileage may vary.
* the assumption here is the pppoe dies when fttc link goes down. I may experiment with ping based SLA route injection/retraction for faster fail-over but the 30 seconds this currently takes is an acceptable outage for a home network.


Raspberry PI

Hmm this was a lot trickier than I thought. You will need:-

a /etc/network/interfaces  file containing

auto lo
iface lo inet loopback

iface eth0 inet manual


auto br0
iface br0 inet static
        bridge_ports eth0
        address 192.168.9.3
        broadcast 192.168.9.255
        netmask 255.255.255.0
        gateway 192.168.9.1


allow-hotplug usb0
auto usb0
iface usb0 inet manual
      up ifconfig $IFACE 0.0.0.0 up
      up brctl addif br0 $IFACE
      down ifconfig $IFACE down
      post-down brctl delif br0 $IFACE


The bridge interface IP address 192.168.9.3 gives me a method to communicate with the PI for other projects but the IP address  isn't need to make the fail-over work.

The mifi when connected via usb to the PI isn't detected as a network interface but as a mass storage device and we need to fix that.  

sudo apt-get install ppp usb-modeswitch wvdial

and we need bridging to actually work so

 sudo apt-get install bridge-utils

now when you plug the mifi unit in (and switch it on) it will auto detect and become part of the network bridge.

And that's it...

pi@raspberrypi ~ $ lsusb
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. 
Bus 001 Device 004: ID 0424:2517 Standard Microsystems Corp. Hub
Bus 001 Device 008: ID 1bbb:0195 T & A Mobile Phones 
Bus 001 Device 005: ID 22b8:0938 Motorola PCS 
Bus 001 Device 006: ID 22b8:093a Motorola PCS 

pi@raspberrypi ~ $ ping 192.168.9.2
PING 192.168.9.2 (192.168.9.2) 56(84) bytes of data.
64 bytes from 192.168.9.2: icmp_req=1 ttl=64 time=1.60 ms
64 bytes from 192.168.9.2: icmp_req=2 ttl=64 time=0.342 ms
--- 192.168.9.2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 0.342/0.974/1.607/0.633 ms
pi@raspberrypi ~ $ brctl show
bridge name bridge id STP enabled interfaces
br0 8000.46c46400d0da no eth0
usb0



This is a ping from the PI to outside world initially via FTTC then watch latency increase as I disable the FTTC link and it switches to the 4G

64 bytes from 8.8.8.8: icmp_req=120 ttl=52 time=13.5 ms

64 bytes from 8.8.8.8: icmp_req=121 ttl=52 time=14.9 ms
64 bytes from 8.8.8.8: icmp_req=122 ttl=52 time=13.2 ms
64 bytes from 8.8.8.8: icmp_req=123 ttl=52 time=13.8 ms
64 bytes from 8.8.8.8: icmp_req=124 ttl=52 time=13.2 ms
64 bytes from 8.8.8.8: icmp_req=125 ttl=52 time=183 ms
64 bytes from 8.8.8.8: icmp_req=126 ttl=52 time=62.4 ms
64 bytes from 8.8.8.8: icmp_req=127 ttl=52 time=103 ms
64 bytes from 8.8.8.8: icmp_req=128 ttl=52 time=94.0 ms
64 bytes from 8.8.8.8: icmp_req=129 ttl=52 time=93.8 ms
64 bytes from 8.8.8.8: icmp_req=130 ttl=52 time=92.7 ms
64 bytes from 8.8.8.8: icmp_req=131 ttl=52 time=72.8 ms





Thanks go to 
https://www.thefanclub.co.za/how-to/how-setup-usb-3g-modem-raspberry-pi-using-usbmodeswitch-and-wvdial

On Main FTTC link

My Broadband Speed Test

On Back up Link

My Broadband Speed Test

Bonus to this config is  you can make use of the wifi part of the Mifi to provide an extra wifi point for your home network. This is useful as it is on the other side of my house from my Ubiquiti access point but I did have to connect the two by 200mbps Homeplugs.

Ok the next challenge is to get the Mifi to send my mobile phone a text every time the system fail-over or recovery happens...how hard could that be?


Thursday, March 27, 2014

Dell2005-WFP 20" Monitor Repaired and temp controlled soldering iron added to kit

I had fixed a 24" version of this monitor a few years ago for some one else. This time it was my own and the screen had a horrible blurry red interference pattern across it. Dis-assembly required very determined pulling on the front bezel.  The power board, once liberated, showed 10 capacitors  in the area that that feeds the logic board. It would have been a £7.00 repair but the trip to Maplin to pick up the replacement capacitors gave the opportunity to also  purchase a temp controlled soldering iron. This made de-soldering much easier at 380 deg C  and the lead free solder flowed far better on the new components than I ever used to achieve with my ancient old Antex iron.

Monday, October 21, 2013

Dishwasher repair ...Again

This time water stopped heating. I assumed that it was the temp sensor. Wrong!.  Then the inline heater element (2KW 32mm).  Wrong!

In fact it was the control board.  Hundreds of pounds for a replacement...or just soldering a nice thick copper wire over the track to the relay pins. Job done dishes washing :)



Saturday, July 20, 2013

Finally I have the microportable system I always wanted.  I have my thinkoutside foldable keyboard successfully paired via bluetooth with my goophone i9. In fact I am typing this blog entry using this combination. Real cursor keys when editing on an android!

Next up is to try to remote desktop to my office machine. Some SSH ing to routers is also called for.

Tuesday, June 04, 2013

Goophone i9

Picked one of these up and it is a lovely phone if you can't afford the Samsung Note II. The only problem is that it  doesn't work well with 3G  on an O2 network in the UK. In fact to even make and receive calls reliably I have had to put sim into the second sim card slot. Thus relegating the phone to 2G  with gprs / edge   data speed which is SLOW!
Hoping for a firmware update that will fix 3G radio to work on UK bands


Hmmm seems I have been caught out by the spec.  the 3G bit of the goophone  works on 2100/850  and of course O2 is 2100/900 . Told to try Vodaphone.


Sunday, June 17, 2012

Raspberry PI connected to netgear router means packet loss

After multiple power supplies and different network cables I find that if I type


sudo mii-tool -F 10baseT-FD eth0

then the 20-30% packet loss on Ethernet interface goes away.

And suddenly it all works sweeeeet !
Blogged this from the otherwise truly dreadful midori browser