2

My phone (Google Pixel 6 and Android 15) is connected to both 4G and a Wifi network with no Internet. The wifi network gives me IP address 192.168.4.2 and I know there's a WIFI Access point on 192.168.4.1. The 4G network gives me IP address 10.96.106.X.

When I am connected to both networks I go to Termux and I try:

ping 192.168.4.1

but ping is unsuccessful - all the packets time out. Then I disconnect the 4G and I try again:

ping 192.168.4.1

And then the ping is successful. It seems like Android is thinking "The only way to perform the ping is go through the 4G network because your Wifi doesn't have internet", so it does the ping over the 4G network and hence it is unsuccessful. But that's wrong - I'm trying to ping an internal IP address on the wifi network so it should do the ping successfully. Any suggestions?

2
  • "It seems like Android is thinking "The only way to perform the ping is go through the 4G network because your Wifi doesn't have internet"" - this doesn't seem unreasonable for a phone Commented May 10 at 13:05
  • 1
    Follow-up to Android.SE: android.stackexchange.com/q/260418/44325 Commented May 13 at 2:05

2 Answers 2

2

This behavior is likely due to androids network priority and routing rules when both Wi-Fi, without internet and mobile data, 4G with internet, are active.

When your Wi-Fi network has no internet, no gateway or no dns, android may still keep mobile data active as the default route for internet access.

You can try to manually modify the routing table in termux.

Or if developer options is active, disable "Mobile data always active", this should prevent android from keeping 4G active when Wi-Fi is connected.

You can also try the ping -I wlan0 192.168.4.1 to specify the wifi interface and try forcing ping ti use Wi-Fi.

-I interface address

Set source address to specified interface address. Argument may be numeric IP address or name of device. When pinging IPv6 link-local address this option is required.

Other sources:
2
  • ping -I wlan0 192.168.4.1 works fine. Now I need to check if my flutter app supports specifying the wlan interface. But isn't this a bug that needs to be resolved? It seems like it should be possible to ping local network IPs without specifying the interface name. Commented May 11 at 5:56
  • If ping works, I would mark the question as solved. And post a new one on android.stackexchange.com to ask whether additional routing or possibly gateways can be configured if you didn't make progress with the links in the posts, or on stackoverflow.com, whether it can be integrated directly into your Flutter app code(I don't know if routing or additional gateways can be set up directly in the Flutter code, as this is usually configured at the operating system level or routing level), where you also share your Android version and parts of the code (but don't ask the same question as here ^^). Commented May 11 at 8:31
0

When the Wi-Fi has internet, ping works fine (I just tested it).

This is not an Unix issue. It is a router issue. Some routers/WAPs have an option to not disconnect Wi-Fi when there is no internet (My Unifi system does). Without this, the Wi-Fi is continuously disconnecting and reconnecting. Meaning that the only network you have is 4G.

Your router may have different names for it, so look for phrases such as

  • Allow Internet Access
  • Isolate Network
  • Client Device Isolation
  • Failover
  • Connectivity
2
  • 1
    Are you certain this applies to OP's situation? They said this happens when they're connected to the Wi-Fi. Wouldn't that (usually) mean it's not disconnected? Commented May 10 at 15:01
  • 1
    How can it be a router issue? When 4G is not connected the router responds to ping just fine. Only when both 4G and Wifi are on the ping doesn't work. Commented May 11 at 5:51

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.