Using trunk(4) for cheap failover.

My home gets more and more depen­dent on an func­tion­ing Inter­net Con­nec­tion — espe­cially after I switched to VoIP. My wife would kill me if her pre­cious phone went offline because our DSL provider has prob­lems :-)

I decided to add some redun­dancy to my home net­work. My neigh­bor had a WLAN router which I could reach from my home office and that made things real easy.

After get­ting his per­mis­sion to use his uplink in a failover sit­u­a­tion I went in search of an auto­matic failover solution …

My cur­rent router at home runs OpenBSD so after read­ing a few man pages I quickly found that the trunk(4) dri­ver was exactly what I was look­ing for. The trunk(4) inter­face allows the aggre­ga­tion of mul­ti­ple net­work inter­faces into a vir­tual trunk(4) inter­face which then can be set up to failover between the phys­i­cal trunk(4) mem­bers based on their link status.

The con­fig­u­ra­tion is, like most things in OpenBSD, rather simple :

ifcon­fig trunk0 trunk­proto failover trunk­port fxp0 trunk­port ral0 192.168.0.1 net­mask 255.255.255.0

This com­mand cre­ates a pseudo-device, trunk0, com­prised of 2 phys­i­cal net­work cards. When my DSL uplink fails, fxp0 changes it’s link sta­tus to down and that would trig­ger the trunk(4) failover mech­a­nism and trunk(4) would then send traf­fic using my wire­less net­work card (ral0) which is con­nected to my neigh­bors WLAN router.

trunk(4) can do other stuff besides failover; roundrobin and load­bal­ance oper­a­tions are also supported.

Since trunk(4) only detects changes in the link state of a net­work card (like an unplugged cable or the like) I also use ifstated(8) to fur­ther val­i­date my DSL con­nec­tiv­ity; once ifs­tated detects that my uplink is down it downs the net­work card that con­nects to my DSL modem so that trunk(4) can do its magic.

A nice ben­e­fit was that my neigh­bor and I were using 2 dif­fer­ent ISP’s but as it turns out we also use com­pletely dif­fer­ent cir­cuits ! My DSL line runs over the cob­ber phone line but my neigh­bors DSL runs over his TV Cable box which makes my failover solu­tion even more redun­dant ;-)

No Comments

Leave a Reply

Your email is never shared.Required fields are marked *