My phone is connected to my WIFI which lacks internet currently. It is also connected to the cell network and using it for data. When I ifconfig it tells me I am connected on wlan with 192.168.1.4 and rmnet at 10.124.121.12. I am trying to ping a device on 192.168.1.55 for purposes.

If I turn off my cell network I can ping it fine. With my cell network on its unreachable.

How do I get my android to allow me to ping 192.168.1.55 while being on the cell network? I have only noticed this since the internet went out on my WIFI so its a strange and new problem.

That's expected. You won't be able to ping 55 from 4, but can do opposite. The reason is that Android can connect either to Wi-Fi or mobile data, which one has internet connectivity, if given option. If both are online, WiFi is preferred. It's because default route is set to mobile data (rmnet_data) interface. You can modify routing table manually if you have root access.
– Irfan LatifJul 1 at 7:50

2 Answers
2

I have the same setup. I have a local WiFi network that is not connected to the internet. I found that if you go to settings on your phone, then select “Developer options” and tick “Cellular data always active” that you will have access to the WiFi network and the cell network simultaneously.

On my LG, I can be on the web with cell data and print to the printer on the local WiFi network. I just now tested a ping just to make sure and it works just as you would expect.

you cannot ping that device via Mobile Data.
You have Device 1 (yours) and Device 2 (device to be pinged).
Telling from the IPs given, both devices are on the same WiFi network. Device 1 can connect to Device 2 by requesting a ping to Device 2 on your router (Device 3).

Your router is most likely having the IP 192.168.1.1

As your router knows that you are connected to it, it will forward your ping request to Device 2 and back again.

When connected to your mobile carrier, you have a different IP. But, your router uses IPs to determine whether it knows a device or not. As you have a different IP and your ping request comes from the outside now, it does it's job: Not forwarding your ping requests. That's what the router is there for (besides establishing connections). It is a firewall and it's trying to prevent people from outside harming your devices.

When you are connected to WiFi

When you are connected to Mobile Service Data Provider

This means, that you are not actually having an Android Problem. What you need to do is to tell your router to forward PING packets. That's difficult. For that, you should head over to the Servers Fault community and ask them how you can do exactly that.

I've always just assumed it was connected to both networks at once and it chose a preferred path but I could force it to a certain network by using that network's IP. That does make a few ideas I had more difficult.
– AdtopkekJul 1 at 22:10

Yes, it kind of is connected to both. You can still receive phone calls when you are connected to WiFi, right? ;) So, you have two options: Tell your phone to send ping requests to your router while using mobile data for everything else, or enable forwarding for ping packets.
– ULTRACOMFYJul 2 at 6:16

But your question asked for "how can I ping device 2 whilst connected to mobile data?", that's what I answered :)
– ULTRACOMFYJul 2 at 6:18