algo icon indicating copy to clipboard operation
algo copied to clipboard

VPN Disconnecting Intermittently on Apple devices

Open watkinsmd opened this issue 9 years ago • 31 comments

OS / Environment

macOS Sierra 10.12.3/iOS X devices Router: Apple Time Capsule (5th generation). UDP ports 500 and 4500 open (see below)

Ansible version

2.2.0.0

Version of components from requirements.txt

setuptools>=11.3 ansible>=2.1,<2.2.1 dopy==0.3.5 boto>=2.5 boto3 azure==2.0.0rc5 msrest==0.4.1 apache-libcloud six pyopenssl jinja2==2.8

Summary of the problem

Algo is up and running but the VPN keeps disconnecting intermittently. It will eventually reconnect after a few minutes. It will also reconnect if I turn off wi-fi and reconnect, or if I switch from my regular network to the 5 GHz network and vice versa. If there is another post on this matter please send the link so I can troubleshoot accordingly--I couldn't find one.

Steps to reproduce the behavior

Use devices while connected to VPN. They will eventually drop and reconnect. According to the Amazon AWS documentation on VPNs, this could be due to ports not being open. http://docs.aws.amazon.com/AmazonVPC/latest/NetworkAdminGuide/Introduction.html

I opened UDP ports 500 and 4500 and the issue is still occurring on all my devices (MacBook Pro, iPad, iPhone)

The way of deployment (cloud or local)

Cloud (Amazon EC2); connecting to Oregon region

Expected behavior

No disconnects

Actual behavior

Intermittent disconnection of VPN.

Full log

watkinsmd avatar Apr 03 '17 14:04 watkinsmd

Yeah you don't need those ports open

dguido avatar Apr 03 '17 14:04 dguido

also getting DC's from AWS...connecting to nova

...I also tried different server types since originally I thought it was a byproduct of the free tier but even on a paid tier with a dedicated CPU it happens. Was thinking of trying Amazon Lightsail instead of EC2 but haven't gotten to it yet.

ghudgins avatar Apr 03 '17 14:04 ghudgins

I'm experiencing the same issue on iOS 10.3 across multiple devices. The VPN is hosted in AWS US-WEST2 (OR).

deansaxe avatar Apr 03 '17 15:04 deansaxe

I use iOS 10.3.2 Beta 1 and I got the same problems.

eliabieri avatar Apr 05 '17 06:04 eliabieri

Seeing the same thing on Azure with iOS 10.3 as the client

kiratp avatar Apr 05 '17 16:04 kiratp

EDIT: That did not fix the issue. Got disconnected again :(

_On windows 10

go to network connections (right click start menu and go to network connections) < right click your algo connection < properties < security < advanced < uncheck mobility or set number super high.

also did "reg add HKLM\System\CurrentControlSet\Services\Rasman\Parameters /v NegotiateDH2048_AES256 /t REG_DWORD /d 1 /f ".

Haven't had any discos since. If it continues it might be related to MTU somehow. May need to be adjusted server side, but haven't had time to dive in further._

biffalo avatar Apr 05 '17 16:04 biffalo

@biffalo Cool, I'll try that out.

I've also been having issues on windows 10. Since I imagine there are many things which would be causing this so it might be hard to track down. I read online that some people switched their VPN network from being a public network in windows to a private network (which enables network device discovery on windows clients). I think I might try it but I'm concerned about potential security issues.

sregister avatar Apr 05 '17 16:04 sregister

@sregister Changing firewall location won't fix it. Firewall just says what ports can be open closed for programs etc. Network discovery on your vpn shouldn't really hurt security wise since you'd only be discover-able by other clients on your algo vpn ;)

biffalo avatar Apr 05 '17 16:04 biffalo

This smells like an issue related to timeouts and keep-alive windows.

kiratp avatar Apr 05 '17 17:04 kiratp

If helpful: Using El Capitan (10.11.5), I have NOT experienced the disconnects, running for > 1 hour. Using iOS 10.2 and the same server (AWS N. California), I do experience the disconnects.

ananonuser avatar Apr 06 '17 07:04 ananonuser

Also experienced DCs across iOS devices on EC2 AWS US-WEST2 (OR). Same configuration set up on Digital Ocean droplet has had no problems so far after one night/day.

magicwave avatar Apr 07 '17 16:04 magicwave

I changed the dead peer detection to High in the mobileconfig and haven't noticed and issue:

<key>DeadPeerDetectionRate</key>
<string>High</string> 

The weird thing is when I turn on the screen after some idle time, the status bar only shows LTE. After a few secs, Wifi + VPN shows up. When I go to VPN settings however, the time connected doesn't appear to have reset to 0.

kiratp avatar Apr 08 '17 21:04 kiratp

I was facing disconnection problems before on a own local ubuntu server. Switching DPD Rate on the configuration profile to High has resolved my disconnection problems across all my Apple devices.

iOS 10.3.1 macOS 10.12.4

@kiratp's modification does maintain a steady connection on my iOS device that was previously disconnecting.

Unfortunately, it also came with a significant (negative) impact to battery life.

ananonuser avatar Apr 09 '17 19:04 ananonuser

@ananonuser - My solution is a workaround since it just ups the keep alives and reconnects. We need to figure out why disconnects are happening in the first place

DPD at High is per minute while medium is every 10 mins. 10x the power :)

https://developer.apple.com/reference/networkextension/nevpnprotocolikev2/nevpnikev2deadpeerdetectionrate

kiratp avatar Apr 10 '17 01:04 kiratp

I seem to be experiencing a related issue on macOS 10.12.4. I have two access points in my house and when I move from one to the other, the VPN disconnects. At the new access point, it will fail to reconnect after several attempts. If I wait several minutes before attempting again, it will successfully reconnect at the new access point. Enabling VPN on demand to automatically connect on wifi doesn't seem to help. Is there are limit on number of reconnects before it blocks you out for several minutes?

sohanmurthy avatar Apr 10 '17 04:04 sohanmurthy

I think I found the reason for disconnects - on GCP at least: https://cloud.google.com/compute/docs/networks-and-firewalls

Note: All instances are configured with a "hidden" firewall rule that drops TCP connections after 10 minutes of inactivity. If this timeout causes connectivity errors to or from your instance, you should configure TCP keep-alives to prevent connections from being dropped. See the tips and troubleshooting page for details.

the Apple DeadPeer Detection setting at medium is 10 mins...

More on keep-alive - maybe we can solve this on the server side: https://cloud.google.com/compute/docs/troubleshooting#communicatewithinternet

kiratp avatar Apr 10 '17 19:04 kiratp

I see that #437 disables DPD and am asking if that's the right approach long term? Or are we just doing this until we move to a newer rev of strongSwan?

jauderho avatar Apr 18 '17 18:04 jauderho

We're not upgrading the base image of Ubuntu to 17.04 yet. We're also not compiling strongSwan from source since that's not the way to do things with Ansible. As a result, we disabled DPD which was the strongSwan recommended solution for 5.3.5. This may have resolved the root cause of this issue. I'm going to close this ticket for now while we work on things like getting Windows clients and GCE servers to the same position.

dguido avatar Apr 18 '17 18:04 dguido

I built my VPN server using the archive/master.zip of July 9, 2017. It is running on AWS, as per the documentation. I built it from a Mac. However, I am experiencing the "random" disconnects mentioned in this ticket on all my Apple platforms: Mac, IOS-ipad, IOS-iphone. I am wondering in light of @dguido 's comment, that maybe this ticket should be reopened.

UPDATE 2 August 2018

I have since migrated from AWS to Digital Ocean. What a difference!!!!

  1. Costs are like 1/2 of what AWS was costing!
  2. Disconnects have gone away! Now part of this could be that I have it automatically reconnect via an option (not sure if that was on before), but I now have reliable VPN service at about $6 / month.

I couldn't be happier with this system!

expaand avatar Jul 18 '17 19:07 expaand