1. Launch the Settings application.
  2. Tap “Network & internet”. Or, if using Android 7 or earlier, tap More… in the Wireless & networks section.
  3. Tap VPN.
  4. Tap Add VPN Profile or the + icon at top-right of screen.
  5. Enter anything you like in the Name field.
  6. Select L2TP/IPSec PSK in the Type drop-down menu.
  7. Enter Your VPN Server IP in the Server address field.
  8. Leave the L2TP secret field blank.
  9. Leave the IPSec identifier field blank.
  10. Enter Your VPN IPsec PSK in the IPSec pre-shared key field.
  11. Tap Save.
  12. Tap the new VPN connection.
  13. Enter Your VPN Username in the Username field.
  14. Enter Your VPN Password in the Password field.
  15. Check the Save account information checkbox.
  16. Tap Connect.

Once connected, you will see a VPN icon in the notification bar. You can verify that your traffic is being routed properly by looking up your IP address on Google. It should say “Your public IP address is Your VPN Server IP“.

iOS/Android sleep mode

To save battery, iOS devices (iPhone/iPad) will automatically disconnect Wi-Fi shortly after the screen turns off (sleep mode). As a result, the IPsec VPN disconnects. This behavior is by design and cannot be configured. If you need the VPN to auto-reconnect when the device wakes up, try OpenVPN instead, which has support for options such as “Reconnect on Wakeup” and “Seamless Tunnel”.

Android devices will also disconnect Wi-Fi shortly after entering sleep mode, unless the option “Keep Wi-Fi on during sleep” is enabled. This option is no longer available in Android 8 (Oreo). Alternatively, you may try enabling the “Always-on VPN” option to stay connected. Learn more here.