3

I use a VPN on my Galaxy S8+ and I am looking for a way to be able to share my ExpressVPN connection via hotspot to be able to connect devices such as Xbox One and a Smart TV. Currently cannot use a PC and my router is trash so my phone is the last resort. What can I do? What are some workarounds?

1

Android doesn't redirect hotspot traffic through VPN network as far as I have tested on Pie ROM (almost stock; custom ROMs might have different implementations or some specific settings). The reason is VPNService API works in Java framework of Android to redirect traffic to VPN's tun interface based on UIDs (and/or SOcket MARKs) of apps. While tethering works in native code; dnsmasq is the DNS server (up to Pie) while the rest of traffic is handled by kernel directly. Also using same internet connection or VPN for multiple devices may break terms of contract with service providers. So it's left disabled by default.

A workaround is to modify routing table but it requires root and is a bit complex on Android. This works for me:

~# ip rule add iif wlan0 lookup table 5000
~# ip route add default dev tun0 table 5000
~# ip rule add to 192.168.43.0/24 lookup table 5001
~# ip route add default dev wlan0 table 5001
  • First command adds a rule to RPDB to send traffic coming on hotspot (WiFi) interface to table 5000.
  • Second command adds a route to routing table 5000 to send all traffic on tun0 interface i.e. the one used by VPN app.
  • Third and fourth rules do inverse i.e. send traffic coming from VPN to tethered devices.

Firewall works above routing policy. Forwarding rules and source NAT should already be set with hotspot but just to make sure:

~# echo -n 1 >/proc/sys/net/ipv4/ip_forward
~# iptables -I FORWARD -o wlan0 -i tun0 -j ACCEPT
~# iptables -I FORWARD -i wlan0 -o tun0 -j ACCEPT
~# iptables -t nat -I POSTROUTING -o tun0 -j MASQUERADE
  • First three commands instruct kernel/firewall to forward traffic in both directions in between VPN and hotspot interfaces.
  • Fourth command sets SNAT i.e. keeps track of hotspot traffic leaving VPN interface and coming back.

Make sure interfaces names and IP address are correct as on your device.

Also there is VPN Hotspot but I haven't tried. For non-root devices there exist some Wi-Fi Direct (ad-hoc) based solutions like PdaNet which require setup on both sides.

RELATED: How to use Private DNS on Android Pie for tethering?

| improve this answer | |
  • Ahh you have a beautiful mind! My next step would be how to root on kernel with Verizon s8+. I havent been able to find any solid info on how to do it, can you maybe point me in the right direction? – Derpyshamrock Aug 22 '19 at 19:32
  • @Derpyshamrock rooting is dangerous, it voids your warranty, it may brick your phone, it's not recommended, and it's very device specific. A web search may help. – Irfan Latif Aug 23 '19 at 0:12
1

Another option would be to use a raspberry Pi as the router with one of its USB ports connected to your phone with the VPN-based internet connection. To provide the internet to other devices, the ethernet port of the Raspberry Pi can connect to a router/switch/bridge and/or also the Pi's own wifi could be used to broadcast it for wireless devices. Or a wireless access point could be added to the router attached to the Pi.

Here is an answer for using a Raspberry Pi tethered to a phone to enable its mobile network to be provided as an internet connection other devices:

Answer to: 4G LTE Device [USB Tethering]--> Raspberry Pi [Ethernet]--> Router, is this possible?

What this answer assumes is that your phone will support USB tethering and the VPN at the same time and that the VPN-based internet connection can be routed over that USB tethered connection to the USB host to which your phone is attatched.

If that is possible, then I can't foresee any other blockers, assuming that the steps described in that answer are correct (I haven't yet tried them).

If successful then that means you would not need to do any particular adjustments to your phone - possible examples of reduced hassle could be: less involved, less risk to 'bricking' the phone, less risk to banking apps stopping working due to rooting, also can use another phone without having to redo the steps on that.

Update

(Following a comment from @Irfan Latif here, I added a response comment, and updated my answer with it, here):

However, if VPN is not supported at the same time as USB tethering on your phone, then the next option you could try is to run the VPN on the Pi itself Other VPN providers, such as speedify.com also support the Raspberry Pi - and Speedify in particular can bond different network connections together should, say, the original poster want to use multiple phones etc as internet connection sources. I don't work for ExpressVPN nor Speedify nor have a financial interest or affiliation with them.

It's worth also noting that if you try this, then the settings in that linked answer above might need adjusting because they might have been written for a scenario that doesn't use a VPN. I say might - because they might still work - I don't know - I just want to bring your attention to it to minimise any frustration :) . With that in mind, the approach could be to get the steps working on your setup with the Raspberry Pi, without the VPN running. Then install ExpressVPN on the Raspberry Pi and see if it still works. By having tried without VPN first, you'll know that the Raspberry Pi can work as a router, so you have that and use that as the basis to get it working with the VPN. Maybe the VPN provider can support you, or at least they might be interested as there maybe others who want to do what you're aiming to achieve, so it saves them time supporting everyone on this as well giving them the edge on support and appealing to those who appreciate the adaptability - all good for their offering in the market.

| improve this answer | |
  • 1
    As the question states that the phone doesn't support WiFi tethering and the VPN at the same time. So is there a reason to "assume that the phone supports USB tethering and the VPN at the same time"? The difference is only of network interface type i.e. WiFi or RNDIS. The network routing is alike AFAIK. – Irfan Latif Apr 25 at 18:20
  • +1 fair point. I could expect the original poster of this question to confirm this - but until then we would not know, for sure, however it's certainly possible as you advise. If indeed USB tethering isn't possible with the VPN, then the next thing to try is to run the VPN on the Pi itself, ExpressVPN seem to provide support for this: expressvpn.com/support/vpn-setup/app-for-raspberry-pi Other VPN providers, such as speedify.com also support the Raspberry Pi - and they can bond different network connections together should, say, the original poster want to use mulriple phones etc. – therobyouknow Apr 25 at 18:34
  • P.S. I don't work for ExpressVPN nor Speedify not have a financial interest or affiliation with them. – therobyouknow Apr 25 at 18:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.