GoBGP as a Host-Based Anycast Controller

Anycast usually lets the network decide which datacenter answers. I moved that decision onto two GoBGP hosts that watch both datacenters and steer a single global VIP between them. Here's the design, the traffic flow, and three failover drills that came through with zero failed requests.
GoBGP anycast controller: a host decides which datacenter, the fabric forwards

On this page

What anycast is, and why you'd control it

Anycast is one address announced from more than one place. You advertise the same IP out of two datacenters, and the network hands each client to whichever copy its own routing math likes best. It's how a lot of DNS and CDN edges run: many boxes, one address, no logic on the client.

The catch is that "whichever the routing likes best" has nothing to do with which datacenter is actually up. Every client here comes in through one firewall pair, so there's no natural nearest datacenter to lean on anyway. The fabric still has to pick a site, and its choice doesn't know or care whether that site's application is healthy. I want to choose the datacenter on purpose, on a health signal, and change that choice without logging into a switch.

So the decision needs an owner: something that watches both datacenters and controls which one the anycast address points at right now.

What a host-based anycast controller is

That owner doesn't have to live in the network. It can be a host. A host-based anycast controller is a normal server that speaks BGP into the fabric, watches the datacenters over the network, and advertises the anycast address in a way that steers it to the site it picked. It never carries a byte of user traffic. It just decides, and the fabric forwards. Because it's a host, the logic is a script you can read and a policy you can edit, not a route-map buried in a switch.

In this network, that address is 192.168.202.0. Clients reach it as 10.80.15.50, the firewall translates one to the other, and two hosts running GoBGP decide which datacenter answers. Here's how that fits together.

The setup

Each datacenter already advertises a per-DC address for the app. 192.168.202.1 lives in DC1, 192.168.202.2 in DC2. Both are real and reachable. The global VIP 192.168.202.0 is the one clients use, and the controller decides which of the two DC addresses it points at.

The GoBGP nodes, gobgp-1 and gobgp-2, peer the two backbone switches over iBGP. They share the backbone's AS 65400. Their whole job is to originate 192.168.202.0/32 with its next-hop set to the chosen per-DC address. gobgp-1 is active at local-preference 500, gobgp-2 stands by at 450.

gobgp neighbor showing two established iBGP sessions, and gobgp global rib showing 192.168.202.0/32 with next-hop 192.168.202.1 and local-pref 500
The controller: two established sessions to the backbone, originating the global VIP with next-hop 192.168.202.1 at local-pref 500.

The backbone takes that route and resolves the next-hop recursively into the datacenter. Here the global VIP lands in DC1, out swp1.100 and swp2.100, exactly where 192.168.202.1 lives. In the BGP table, gobgp-1 wins on local-pref, gobgp-2 sits behind it at 450, and the datacenter's own copies wait further down as a backstop.

This post is for paying subscribers only

Subscribe to LevelUp I.T. newsletter and stay updated.

Don't miss anything. Get all the latest posts delivered straight to your inbox. It's free!
Great! Check your inbox and click the link to confirm your subscription.
Error! Please enter a valid email address!