Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wi-Fi hotspot enabled on host device with OpenVPN connected... connected client devices have no internet #34

Closed
GoogleCodeExporter opened this issue Mar 19, 2015 · 40 comments
Labels

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Enable "Portable Wi-Fi hotspot" on device1
2. Connect device2 to device1 via Wi-Fi like you would with a router
3. Attempt to connect to the internet

What is the expected output?
The internet to work as normal on device2 except it's all rerouted through the 
OpenVPN connection on device1

What do you see instead?
I get no response on device2 and eventually times out ( any application that 
requires internet )

What version of the product are you using? 0.5.6

On what operating system? Android 4.0.4 Build IMM76I ( device1, stock, not 
rooted )

Please provide any additional information below.

device1 - Samsung Galaxy Nexus Android - 4.0.4 Build IMM76I ( stock, not rooted 
)
device2 - Samsung Galaxy Tab 10.1 - Android 3.2 ( stock, not rooted )

Original issue reported on code.google.com by sinat...@gmail.com on 26 May 2012 at 8:22

@GoogleCodeExporter
Copy link
Author

Yeah. I know that this not work (got another report about this behaviour). The 
application uses the VPNService API. The routing on Android is behind my 
control. I am afraid but this a bug google would have to fix.

Original comment by arne@rfc2549.org on 26 May 2012 at 10:16

  • Changed state: Invalid

@GoogleCodeExporter
Copy link
Author

okie, oh well

Original comment by sinat...@gmail.com on 26 May 2012 at 11:00

@GoogleCodeExporter
Copy link
Author

I reported the issue in the google android bug tracker:
http://code.google.com/p/android/issues/detail?id=32622

Original comment by arne@rfc2549.org on 3 Jun 2012 at 6:46

@GoogleCodeExporter
Copy link
Author

From a mail, you can do if you have rooted your phone:

iptables -A POSTROUTING -s 192.168.43.0/24 -j MASQUERADE -t nat
iptables -A FORWARD -j ACCEPT -i wlan0 -o tun0
iptables -A FORWARD -j ACCEPT -i tun0 -o wlan0


Original comment by arne@rfc2549.org on 12 Jun 2012 at 3:02

@GoogleCodeExporter
Copy link
Author

Issue 96 has been merged into this issue.

Original comment by arne@rfc2549.org on 8 Oct 2012 at 12:44

@GoogleCodeExporter
Copy link
Author

Issue 104 has been merged into this issue.

Original comment by arne@rfc2549.org on 5 Nov 2012 at 8:09

@GoogleCodeExporter
Copy link
Author

ah.. so it is possible by just adding postrouting  and forwarding rules?

are you going to implement this in to the app?

i mean, you could do a simpel root-check to see if the the dives is rooted and 
if so just add those rules.. right?

Original comment by gilu...@gmail.com on 5 Nov 2012 at 9:04

@GoogleCodeExporter
Copy link
Author

Well sometimes the tunnel device is also called tun1. And I know from HTC 
devices that they do some different iptables rules from stock android. While 
the VPNService API has a defined interface anything beyond that is dependend on 
the vendor implementation.  Adding rules could potiently do more harm than good.

Also the wlan interface may be called different on different handsets. For 
example the Motrola Defy has tiwlan0.

Original comment by arne@rfc2549.org on 5 Nov 2012 at 9:28

@GoogleCodeExporter
Copy link
Author

Solution if root,

See http://forum.xda-developers.com/showpost.php?p=33749904&postcount=10

Oneneeds iptables commands as specified above AND
routing command in 'dedicated tether routing  table'

Hope it helps

Original comment by francesc...@gmail.com on 6 Nov 2012 at 6:23

@GoogleCodeExporter
Copy link
Author

Issue 107 has been merged into this issue.

Original comment by arne@rfc2549.org on 20 Nov 2012 at 8:09

@danieljarolim
Copy link

This is how to get tethering to work regardless of OpenVPN and hotspot startup sequence on Lollipop, with the caveat that it bypasses the VPN tunnel..
If hotspot is active and OpenVPN is then started with "Bypass VPN for local networks" enabled (default), the network/route is shown in the log (high verbosity) as excluded as a local network. The VPN tunnel is bypassed for the tethered devices and tethering appears to work.
If OpenVPN is started first with "Bypass VPN for local networks" enabled, there is no local network detected so the network normally used for tethering is not excluded as before. When the hotspot is activated the subnet used for tethered devices is now NOT being excluded but cannot be routed through the VPN tunnel so tethering appears broken.
The fix is to identify the subnet used by the hotspot service and manually add it to Excluded Networks for the connection. In my case 192.168.43.0/24
Now when the tunnel is initiated the hotspot subnet is always excluded from routing through the tunnel regardless of startup sequence and tethering always works.

@schwabe
Copy link
Owner

schwabe commented Jul 14, 2015

@danieljarolim from my experience Hotspot on 4.4+ works without these tricks and always uses the non VPN connection

@danieljarolim
Copy link

@schwabe I realsied I was using the vpn provider's profile so tried again with a default configuration but ended up with same results. This is on Android 5.1.1. It's on an old phone so it's a custom ROM but should be close to AOSP defaults.
I'm seeing the same symptoms as #104 and #107 (both start VPN then enable hotspot). I can post working and non-working connection log.

@schwabe
Copy link
Owner

schwabe commented Jul 15, 2015

@danieljarolim All I can say that it works on Nexus devices out of the box.

@jonathonf
Copy link

jonathonf commented Oct 19, 2016

I know this has been closed for a while but it still persists.

I suspect the cause (and why it works in 4.4+) is the tether_dun_required setting. This is default true on stock 4.4+.

When enabled, a separate 'dial-up network' is created specifically for tethering. This would allow tethering to be active while the standard network device has an active OpenVPN connection - they are using separate network devices.

With some custom ROMs (and possibly AOSP?), tether_dun_required is set to false, so tethering and normal data use the same network device. With VPN active the tethered device can't obtain an IP address from the phone.

(I'm running BrokenOS 4.9.1 on my Nexus 5)

@otaviobonder-deel
Copy link

Sorry to reopen a closed issue, but is there a solution to this bug? If VPN is active, devices can't get IP thru wireless tether

@schwabe
Copy link
Owner

schwabe commented Jul 19, 2017

You can try to exclude 192.168.42.0/24 (the hotspot range)

@otaviobonder-deel
Copy link

Where do I find the option to exclude it?

@schwabe
Copy link
Owner

schwabe commented Jul 19, 2017

under excluding routes

@otaviobonder-deel
Copy link

I tried to exclude the 192.168.42.0/24 but got no luck. The device can't get an IP address from my hotspot. I have to disconnect from my VPN, connect the other device to my hotspot, and then reconnect the VPN. This way it works. But if the VPN is connected, the device trying to connect to my hotspot can't get an IP address

@schwabe
Copy link
Owner

schwabe commented Jul 20, 2017

@otaviobps there is probably nothing the app can do about that then. :(

@jonathonf
Copy link

jonathonf commented Jul 21, 2017

On my device, 192.168.42.0/24 is for USB tethering; for WiFi tethering I have to exclude 192.168.43.0/24. (Or just use 192.168.42.0/23 for both.)

Clients connecting via either won't route via the VPN, though (which would have been the better solution; maybe some iptables rules would fix that).

I have clients able to connect and VPN active on the phone with:

Include: 0.0.0.0/0
Exclude: 192.168.42.0/23

@otaviobonder-deel
Copy link

I could solve the problem by assigning a manual IP on the device connecting to my hotspot. Maybe the VPN interferes with DHCP

@jonathonf
Copy link

I think what we're really trying to do actually needs server-side configuration to work - whether it's routing or bridging I'm not sure yet, but essentially the phone has to act as a router for its client devices. If this is what's needed, I don't think it's in scope for this app. :)

@schwabe
Copy link
Owner

schwabe commented Jul 21, 2017

I don't think server side configuration will help. The dhcp stuff is probably a bug in Android itself.

@jonathonf
Copy link

Here's my thinking: With the simplest setup, the phone is acting as a client. The server has already provided a DHCP address to the phone; if it's getting other requests from what it sees as the same client it won't do anything as the current lease is still valid - it has to know the client is actually acting as a router/gateway, and service the other requests appropriately.

@schwabe
Copy link
Owner

schwabe commented Jul 21, 2017

@jonathonf in hotspot mode the phone itself is the DHCP server.

@jonathonf
Copy link

Right, in plain hotspot mode clients will get an IP address from the phone's DHCP server. However, when the OpenVPN client is running, by default it is redirecting all traffic to the OpenVPN server, meaning any client traffic is also being redirected. Hence, the clients aren't talking to the phone's DHCP server any more - they are talking to the OpenVPN server, and if that doesn't provide an IP address via DCHP then the clients connection attempts will "hang".

However - if the phone acts as a gateway to the OpenVPN network for its hotspot clients, everything should work - instead of clients being given an IP address by the phone, they will be given an address by the OpenVPN server.

@mae1989
Copy link

mae1989 commented Oct 7, 2017

Hello guys,

Could you please provide a short step by step procedure on how to do the following in android terminal.

Include: 0.0.0.0/0
Exclude: 192.168.42.0/23

My devices are stuck in obtaining ip addresses.

Please help.

@jonathonf
Copy link

jonathonf commented Oct 7, 2017

Look in the VPN connection settings. No need for the terminal.

"OpenVPN for Android"... Profiles->Edit profile... Routing->Excluded Networks.

@mae1989
Copy link

mae1989 commented Oct 7, 2017

Hi @jonathonf. Thank you for the quick response. I really appreciate it.

So, I went to Settings>Connection>VPN>Turbo VPN. I couldn't find a setting to include or exclude these addresses. Any workaround to do in emulator?

@schwabe
Copy link
Owner

schwabe commented Oct 7, 2017

Turbo VPN does not sound anything that would be in my app. Are you sure that you are using my app?

@mae1989
Copy link

mae1989 commented Oct 7, 2017

Hi @schwabe. Forgive me, I must be off-topic. But the discussion in this thread matches my issue.

Scenario: I am trying to execute android "Mobile Hotspot (wifi)" on my s7 edge device that is connected to a vpn. However, when the other android devices start connecting, they are getting the "Fail to obtain ip address' error. Your helpful replies in these thread say that I should include or exclude a particular IP address from the VPN. And, I really want to do it, but I am not sure how to do that in the terminal. Please help.

@schwabe
Copy link
Owner

schwabe commented Oct 7, 2017

@mae1989 The VPN app has to implement this. If not you would need root for that and (very) good understanding of ip rules and iptables to figure out how to manipulate the policy based routing to achieve that. But I cannot help you with that either since my phones are not rooted.

@mae1989
Copy link

mae1989 commented Oct 7, 2017

Hi @schwabe. My phone is rooted. Now, I am just basically lost how to add/exclude those addresses within terminal. I wish someone could help. Thank you for taking time on my issue. In case, someone could help, I have attached the the results using ifconfig and ip route.
screenshot_20171007-212431

@mae1989
Copy link

mae1989 commented Oct 7, 2017

Hi again @jonathonf and @schwabe. Btw, thank you for pointing out how to exclude the address in OpenVPN. I tried it and it works great! My devices are now connecting. You guys are awesome. I bet I need to move to OpenVPN instead of other vpn apps, until I figure the solution for those. :)

@drzraf
Copy link

drzraf commented Mar 31, 2018

Is it really fixed?

  • Android 7.0:
  • enable hotspot
  • enable VPN
  • connect a client
  • the client get an IP but does not connect using the VPN

@jonathonf
Copy link

jonathonf commented Mar 31, 2018

This has already been covered. Read my comment above and you'll see that the clients are excluded from the VPN.

@schwabe
Copy link
Owner

schwabe commented Apr 1, 2018

See also the FAQ. Connected clients via Tethering always use the normal connection and not VPN

@drzraf
Copy link

drzraf commented Apr 2, 2018

1° The FAQ does not mention Android > 5.1
2° workarounds exist but rely on a rooted phone to change ip routing which is not offered via the standard Android API => It would be nice to get a link to AOSP upstream bug report about problematic API call in order to follow possible resolution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants