My cable internet has been horrid lately. I wanted to be able to hotspot to my phone while maintaining LAN connections to my servers while the cable company takes its sweet time to fix things. Even though I connected to wifi on my phone, my desktop still prioritized the broken connection and wouldn’t use my phone to get to the internet. I verified this by looking at the routing table and running traceroute
sudo ip route ... default via 10.137.1.1 dev br0 proto dhcp src 10.10.1.124 metric 425 default via 184.108.40.206 dev wlp69s0 proto dhcp src 220.127.116.11 metric 600 ... traceroute google.com --max-hops=1 1 _gateway (10.10.50.1) 0.409 ms 0.449 ms 0.483 ms
The LAN connection’s default gateway had a lower metric than the mobile hotspot connection (lower takes precedence.) To fix this I ran this networkmanager command (thanks to this post for the inspiration)
sudo nmcli connection modify "Nicholas’s iPhone" ipv4.route-metric 50
I noticed DNS traffic was also prioritizing my LAN, which I didn’t want. I fixed it with nmcli as well (thanks to this post)
sudo nmcli connection modify "Nicholas’s iPhone" ipv4.dns-priority 1
I then noticed I couldn’t get to certain LAN subnets. I then realized I needed to add some static routes so they don’t try to go over my hotspot connection (which I learned about here)
sudo nmcli connection modify bridge-br0 +ipv4.routes "10.10.50.0/24 10.10.1.1"
Note you may need to refresh your connection once you’ve made changes. You can either disconnect and reconnect to force a refresh, or run this command (as outlined here.)
sudo nmcli con up bridge-br0 #or whatever your LAN interface name is
Once I refreshed my settings, I was able to get internet via my phone while maintaining all my local network settings.