How do you make commands use WiFi instead of mobile data?
I self-host a few services such as ssh and ollama that I only access on my LAN with commands containing ip addresses starting with 192.* . I can access them using the right commands as long as WiFi is on and mobile data is off. If mobile data is on, it tries to use that and the commands hang because the mobile data connection cannot access the devices on my LAN that start with 192.* . Is there a way, perhaps with proxies or something, that I can make a command use the WiFi instead of mobile data?
12 Replies
With Termux:API you can check which Wi-Fi you're connected and enable/disable Wi-Fi.
But I use Tailscale to use always the same hostname for SSH.
i always need wifi on for this to work. I think I'd need the equivalent for mobile data. This would require root which I do not have
Do you use tailscale to access machines on your LAN? Any issues if WiFi and data are enabled at the same time?
No issues
@sudomain that sounds strange. I'm on mobile + wifi at home all the time and am always talking to things on my LAN from my phone, and can think of a lot of things that would break if that didn't work
you're saying that with your phone at home, wifi on, mobile off,
curl 192.168.x.y
works, but if you turn mobile on (with wifi still on), it fails with no route to host?sometime ago I've seen something about a setting that would let android switch automatically between the two if wifi was unstable, or data was unstable
not sure it's still a thing, maybe it could be that
or that

I would think that changes whether it uses the default route from the mobile or the wifi connection - under normal linux networking, your wifi interface is gonna get an address like
192.168.1.45/24
and packets destined for anything in 192.168.1.*
will be sent out via that interface
actually, no, I would think that's a radio toggle
more power for less time to switch over, sorry, not even the default route
but either way
this is how linux generally works, and I do stuff every day on my phone that depends on android working this way, and any device setup that goes through wifi would depend on this as wellit's weird, I never had anything like that ever happening on any phone I had
wifi + data enabled, everything works as intended
That's correct. It's annoying to remember to have to do and interrupts downloads in progress
@sudomain can you be explicit about what "it" in that message was? I wasn't describing doing anything, I was describing not needing to do anything
Oh sorry. Sure: "it" is needing to turn off data in order to access 192.* IP addresses
okay, so, I'll say it again: I regularly access LAN IPs on my phone while connected to mobile data and wifi, my understanding of how networking works requires that to work, and a number of consumer electronics depend on that working
a lot of shit would break if what you're describing didn't work
so maybe we need a much better description of exactly what you're doing and exactly what's happening
and not your theory of why, because as I said, your theory makes no sense so far :) what have you set up, what are the conditions, what did you try to do (exact command), what happened (exact error)