I have a rooted android 13 phone(oneplus 10 pro) and at home I have a local WiFi network used for smart home devices NAS and CCTV this network is not connected to the internet.
If I connect to this network using my phone I'm able to access my local devices but browsing the web becomes impossible because all traffic is routed over the WiFi network interface (network without internet access) by default on android when connected to a wifi network. I want my phone to route traffic for local IP's (192.168.1.x) over the WiFi network interface (Wlan0) and route all other traffic using the mobile data interface (rmnet_data2).
I tried multiple thing but I haven't found a reliable solution to get this to work, I hope someone can assist me with this. below are some of the things I did while trying to get it to work, I had some success but can't get it to work reliably.
#1. Mobile data always active
First I enabled the developer setting "Mobile data always active" to make sure both the WiFi and mobile data adapters stay enabled simultaneously when connecting to a WiFi network.
#2. USB debugging and shell
I enabled USB debugging and connected my phone to my PC so I can open a shell to execute commands on my phone (android uses the linux kernel).
using command prompt and adb I connected to my phone and opened a shell:
$ adb shell
next I elevated it to a root shell
$ su
#3 change routing stuff
Checking the current routing rules.
$ ip rule list
Checking the routing table
$ cat /proc/net/route
Checked the routes for local and public ip's using the ip route get command
$ ip route get 10.10.10.10
$ ip route get 192.168.1.135
Added a rule for the local IP's, to use wlan0 with router IP as gateway
$ ip route add 192.168.1.0/24 via 192.168.1.1 dev wlan0
route everything else using mobile connection
$ ip route add default dev rmnet_data2