0
Network/Connectivity OnePlus 6 won't connect to Wifi with no internet

  1. henry_shadowjet
    Cupcake Sep 27, 2018

    henry_shadowjet , Sep 27, 2018 :
    Hi everyone,

    My first post in the forums here. Been a loyal OnePlus fan since the the 3 though, and looks like will continue to use it. Been very satisfied, especially with this new OnePlus 6 (getting it was a hike though, had to get my cousin to ship it from America to Australia).

    Just a small problem, ever since the very recent update (just yesterday) update to Android Pie, I'm not able to connect to my WiFi router if there is no internet connection on it. I suspect it's a new feature from the Pie to not route connection to an internet-less WiFi, but for several reasons I need it to be able to do this (I have a Raspberry Pi that I need to access this way). I can't find where I can disable this feature either in the settings or in developer options.

    My device is rooted, just FYI, so solutions that require rooting is available to me.
    I forgot to mention, if I disable the mobile data, it works. But again, because of how I use the Raspberry Pi as the router but use the phone as an internet source simultaneously (which I was able to do in the past no problem pre-update), having to disable mobile data to connect is not an option for me.

    Thank you so much in advance for all the help.

    Cheers,
    Henry
     

    #1
  2. henry_shadowjet
    Cupcake Sep 27, 2018

    henry_shadowjet , Sep 27, 2018 :
    Managed to get it back by issuing the following command after "su" in Termux:
    ip route add 192.168.3.0/24 dev wlan0 table rmnet_data1
    - 192.168.3.0 being the network address, 24 being the subnet mask
    - rmnet_data1 being the network interface for the mobile data
    In order to route connection from the Raspberry Pi to the internet via mobile data is still a little bit trickier than it used to be, I had to tweak around with "ip rule" settings, and since it changes every time I connect and disconnect (auto script executed by Android, I presume), I still haven't worked it out 100% yet. I managed to get it working, but the steps I follow is different every time depending on a few things.
     
    Last edited: Sep 27, 2018

    #2
  3. henry_shadowjet
    Cupcake Sep 27, 2018

    henry_shadowjet , Sep 27, 2018 :
    OK, I think I managed to work it out. So first what I have to do is, while having the WiFi connected to the router, go to Developer settings and enable "Mobile data always active" to ON (I had to do this in the past anyway). This ensures that connection rmnet_data1 is always active, even when I managed to somehow give internet connection to the Raspberry Pi/router.

    After that, as "su" in the Termux app, I issued command "ip rule add lookup rmnet_data1". This cuts through the complex rules that Android has in place and ensures that every connection goes through the rmnet_data1 table.

    Now that all connections are referencing to rmnet_data1 table, we have to add the conection to the router to the rmnet_data1 table as mentioned in my previuos post so that we can connect to the router, by issuing:
    ip route add 192.168.3.0/24 dev wlan0 table rmnet_data1

    Finally after all that's done, we just have to make sure that all the standard forwarding rules are set up:
    - iptables -A oem_fwd -i wlan0 -o rmnet_data1 -j ACCEPT
    - iptables -A oem_fwd -i rmnet_data1 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
    - iptables -t nat -A POSTROUTING -o rmnet_data1 -j MASQUERADE
    - echo 1 >/proc/sys/net/ipv4/ip_forward

    And VOILA! Everything works like a charm. Well, that's assuming that the other side is setup right. With my Raspberry Pi, I just have to do:
    - sudo ip route add default scope global via [the phone's IP as given by the DHCP]

    When disconnecting, just remember to do the opposite, which is:
    - Delete the ip rule: ip rule del lookup rmnet_data1
    - Optionally: disable the "mobile data always on" feature in Developer settings
    - Disconnect the wifi - this is the last step if you disable the "mobile data always on", if you do this without deleting the ip rule first, I think the phone tries to route connection through the router which then tries to connect to the phone and creates a loop that crashes the phone and restarts. Nothing major, but if you don't want to have that problem, do this last.

    Hope the above helps for someone who has similar needs. I like doing this instead of setting the phone as a Wifi Hotspot because of a few reasons. First is because it saves battery, second is because I have more control if I do this through the Raspberry Pi such as being able to route it differently if there are more interfaces or using a VPN. Correct me if I'm wrong, but so far I haven't found a way to do WiFi Hotspot while enabling VPN for all client connections (saving me from giving each of them my VPN user & password & settings).
    Also, when I'm in my car and using the Raspberry Pi as a "screen" to mirror my phone to my car TV (it has HDMI slot, no fancy Android Auto), I use ADB screenrecord command and it gets really hot when I use the phone as the WiFi Router as well. It helps when I share the load and make the Raspberry Pi as the router and the phone as the internet source only.

    Cheers!
     
    Last edited: Sep 27, 2018

    #3