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 guiEdgerouter 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
On Main FTTC link
On Back up Link
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?
1 comment:
Hi Richard, for monitoring and status checks + alerts you can use free tool MK Check, not so sure if MK Check sends SMS but if not, you can use Linux commands to sens SMS via EE dongle or perhaps a cheap 3G dongle with direct SMS commands via the Linux, MK Check can also run from the Pi.
Good luck!
Post a Comment