Programmatically send traffic through a given WAN

I’d like to do two things programmatically: get the external IP addresses of my WAN interfaces (there are three) and also speedtest them. I have a B20X. It’s straightforward to tell the router to send traffic based on a client or destination using outbound policies, but I want to run speedtests from a single server automatically, so the source would always be the same (a little Linux box), and the destination would be as well (speedtest.net).

For context, the problem I’m trying to solve is this: I have a vacation home that has terrible internet. I’m using the 20X to make the best of obstructed Starlink, lously DSL, and somewhat flaky LTE. The router (and associated SFC service) are awesome; I love it. Before I head out (at least on a trip during which I’m planning to work), I SSH into my always-on Raspberry Pi and run speedtest-cli for each connection to be sure everything is working like I expect. Right now, I need to go into the router config, enable an “enforced” rule for that client, set it to a given connection, run a speed test, change it to a different WAN, run a speedtest, etc. It would be awesome to set up a simple cronjob to run a speedtest every morning at, say 9AM and post the results to my Slack channel. To make that work, though, I’d need to be able to pass some kind of argument (like a query string or something) on which the router could act.

The only idea I’ve come up with so far is to pick a specific speedtest server for each WAN and then set up outbound rules that match a specific speedest server with a given WAN. It feels kind of hacky to me, and the speedtest servers change all the time.

Does anyone have an idea for a more elegant solution?

How about some local dns entries that point to the same speed test server.
assumes 1.2.3.4 is the ip for your speedtest server.
localentry-star 1.2.3.4
localentry-dsl 1.2.3.4
localentry-lte 1.2.3.4

Then create three outbound rules matching for that host name to direct to the wan you wan to test.
So this way from the command line you could test against the same speedtest server without changing any rules, or requiring a query parameter.

You could also try to script against the internal wan analyze server/client maybe?

That’s a cool idea! I’ll try this. I’m using a command-line utility for speedtest (speedtest-cli), so I’ll need to dig through the source code to see how to change the outbound address, but unless it’s hardcoded in a hundred different places, that should be easy enough.

Thanks for the tip! Annoyed I didn’t think of it. . . . :slight_smile: