How to share your VPN via Mobile Hotspot on Android

Hi, when I am connected to PIA VPN via your PIA Android app to your UK server for example, when I am physically in HK. I have noticed with whatmyip.com that I considered as being from UK from my mobile chrome browser.

That’s normal. BUT when I share this phone internet access to a remote device, this device is being seen as being from HK. That’s not what I want, it should be seen as being in the UK too.

Is there a setting to correct in PIA for Android? Regards

No way to do that via native MHS without rooting.

What you CAN do though, is use Wifi Direct (An app like Netshare No Root Tether can make it super easy), and a proxy server app (EveryProxy or Android Proxy Server, both are free) can help. What you do here is connect your remote device to the Wifi Direct hotspot, then configure whatever software you want to use the proxy server. This not only has the benefit of sending the connected device’s traffic through the VPN, but allows you to control data usage by only letting SOME things on the remote device access the internet (like a browser). This also works regardless of your data plan.

I wrote a shell script to do it over adb shell, needs root though and I’m not sure how similar the firewall setup is between various android devices and versions so it may need tweaking for your device.

I think it’s only set up for USB hotspot too, although should only need minor tweaks for WiFi hotspot.

The issue is that Android sets up a rule for locally-generated packets to be directed into the VPN tunnel, but not forwarded packets - so we just add some iptables and ip rules to also direct forwarded packets into the tunnel and we’re good to go.

It also needs to be re-run whenever you re-enable hotspot, possibly when you reconnect VPN too.

PS: VPN client apps can’t do it for you, this is a design decision of Android itself

I got VPN (Riseup) shared via hostspot on android 13 lineage os without root. I enabled Riseup in ->VPN to be always on, allowed VPN sharing in “hostpot” settings and also enabled sharing VPN in the application.
then it began to work.

What you CAN do though, is use Wifi Direct (An app like Netshare No Root Tether can make it super easy), and a proxy server app (EveryProxy or Android Proxy Server, both are free) can help. What you do here is connect your remote device to the Wifi Direct hotspot, then configure whatever software you want to use the proxy server. This not only has the benefit of sending the connected device’s traffic through the VPN, but allows you to control data usage by only letting SOME things on the remote device access the internet (like a browser). This also works regardless of your data plan.

Thank you for your help. To be sure I have properly understood : using this method, only apps that have a proxy setting entry possibility and where you enter your proxy server configuration will actually use the VPN. Is that correct ?

2 years later, this will be the very post that helps make my app possible

does this still work? rooted android 14

Also do you have such scripts for wifi hotspot and usb hotspot, I asssume this is only for mobile hotspot. do you have a channel or website or something?

thanks a lot

This is correct. Makes a good data saver, and no real leak potential as the Wifi Direct network will have no internet access on it’s own, it’s merely just a closed LAN.

Don’t need it in Android 14 - there’s an option in hotspot and tethering settings, "Allow clients to use VPNs’

I have used Every Proxy as you recommended and it works great. All the other device traffic is going through the VPN now :slight_smile:

Not in my stock rom. OOS 14