2 ISPs, 1 routing table

Problem: have 2 ISPs – TekSavvy 60/6Mbps cable & Telus fibre – but server uses slower cable connection as default.

Solution: edit routing tables.

In the past, nmcli (Network Manager command line interface) was used to set the priorities of network interfaces, but that was half a decade ago and I forget how I did it; and on Ubuntu server 18.04 it’s not installed by default.

So this time, editing the routing tables directly seemed the way to go.

Let’s first do a speed test, which is how it was discovered that the cable connection was being used:

./speedtest.py
Retrieving speedtest.net configuration...
Testing from TekSavvy Solutions (69.172.190.161)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by The University of British Columbia (Vancouver, BC) [1.92 km]: 16.292 ms
Testing download speed................................................................................
Download: 2.20 Mbit/s
Testing upload speed................................................................................................
Upload: 3.09 Mbit/s

That’s… terrible! 2.2 Mbps is unprecedented, time to re-test:

Hosted by as26370 (Lopez Island, WA) [83.36 km]: 17.006 ms
Testing download speed................................................................................
Download: 43.72 Mbit/s
Testing upload speed................................................................................................
Upload: 1.94 Mbit/s

That’s better, but would be unprecedented if not for the previous test. Anyway… Let’s look at the routing table:

ip route | head -n 2
default via 10.60.42.1 dev eno2 metric 100
default via 75.154.232.1 dev eno1 proto dhcp src 75.154.234.99 metric 200

We can see that the priority of the 10.0.0.0/8 LAN is higher (because the metric is lower at 100 vs 200). That LAN subnet is the cable modem.

Unfortunately, the ip route command does not allow for editing of the metric value, so a new entry needs to be made for the Telus fibre with a lower metric than 200, or the default route needs deleting and re-adding with different priority:

ip route del default via 10.60.42.1 dev eno2 metric 100
ip route add default via 10.60.42.1 dev eno2 metric 300
ip route | head -n 2
default via 75.154.232.1 dev eno1 proto dhcp src 75.154.234.99 metric 200 
default via 10.60.42.1 dev eno2 metric 300
./speedtest.py  
Retrieving speedtest.net configuration...
Testing from TELUS (75.154.234.99)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by OTC Connections (Portland, OR) [413.83 km]: 9.202 ms
Testing download speed................................................................................
Download: 332.73 Mbit/s
Testing upload speed................................................................................................
Upload: 287.41 Mbit/s

Much better! And everyone lived happily ever after…

…Until (stay tuned for next post)

Thanks for reading!

By admin

Linux admin, JS / React / Python / Perl developer.