ikev2

IKEv2 VPN on your own server

A free app for iPhone, iPad, Mac, Android and Windows, and one script that sets up your server: firewall, a free certificate and logins included — with a username and password, a pre-shared key or a certificate. No ads, no tracking.

  1. 1 · Get the app
  2. 2 · Get a server
  3. 3 · Run the script
  4. 4 · Open the ports
  5. 5 · Connect

1Get the IKEv2 VPN app

The built-in VPN of iPhone, Mac, Windows and the strongSwan app on Android also work with the same server.

2Get a server

Any VPS works: Ubuntu 22.04 / 24.04 or Debian 12, 1 CPU and 512 MB are plenty for a family. Pick the country you want your VPN to appear in.

No domain name? No problem. The script gets a free Let's Encrypt certificate for your server's IP address, so iPhone, iPad, Mac and Android need nothing installed. Using Windows? Point a domain name (for example vpn.yourname.com) at the server with an A record: then Windows needs nothing either. With just an IP, Windows installs one certificate file once.

3Run the script on the server

Log in to the server with SSH as root (or a user with sudo) and run:

wget -O brooog-ikev2.sh https://brooog.com/download/ikev2/brooog-ikev2.sh
sudo bash brooog-ikev2.sh

It asks three questions, then sets up everything in a couple of minutes (strongSwan, the firewall, the certificate and your logins) and shows what your devices need:

  1. Your domain name — or press Enter to use the server's IP address.
  2. Which devices — iPhone/iPad/Mac, Android, Windows, or all.
  3. How they sign in — one or more of the options below (only those your devices can use).
Sign in withiPhone, iPad, MacAndroidWindows
Username + password
EAP-MSCHAPv2 · easiest, one per person
✓✓✓
Pre-shared key
PSK · one key for all your devices
✓✓—*
Certificate
a file per device, no password to type
✓ as a profile✓ .p12—

* Windows itself doesn't support IKEv2 with a pre-shared key, so Windows uses username + password.

Without questions / more options
sudo bash brooog-ikev2.sh --host vpn.yourname.com --devices all --auth eap,psk --yes
  • --host domain name or IP the apps connect to (default with --yes: the server's IP)
  • --devices apple, android, windows or all (default with --yes: all)
  • --auth eap (username + password), psk, cert, or several (default with --yes: eap). Run the script again with other choices to change them later; logins are kept.
  • --email for Let's Encrypt notices (optional)
  • --user / --password the first login (default: vpnuser and a random password)
  • --dns 1.1.1.1,8.8.8.8 DNS servers for your devices
  • --own-ca skip Let's Encrypt and use the server's own certificate authority

Script: brooog-ikev2.sh · SHA-256 64408f59801f54d9f8f95d0dbbbf59f988b4111d0788b00603fa556aea5bbe57

4Open the ports at your provider

The script opens the server's own firewall. Many providers also have a firewall in their control panel (security group, cloud firewall, network rules). Allow there:

  • UDP 500 and UDP 4500 (the VPN)
  • TCP 80 (Let's Encrypt checks it when the certificate is made and renewed, a few seconds each time)

5Connect

Need a file on your phone or PC (a certificate login, or a certificate for Windows)? On the server run sudo brooog-ikev2 --share: it shows a link and a QR code for 10 minutes. Open it on the device — every file is there with a note on what it's for. Username + password and the pre-shared key need no file: see them with sudo brooog-ikev2 --show.

In the IKEv2 VPN app tap Add VPN, enter your server address, then pick one:

  • Username + password: Authentication EAP, your username and password. Nothing else to install.
  • Pre-shared key: Authentication PSK, the shared secret, Remote ID = your server address, Local ID = anything (your name, for example). Nothing else to install.
  • Certificate (.p12): open NAME.mobileconfig from the --share link in Safari (on a Mac, double-click it). Settings › Profile Downloaded › Install, and enter the certificate's password from --show. The VPN appears in Settings › VPN, ready to connect.

Server installed with --own-ca (no Let's Encrypt)? First install ca.mobileconfig the same way, then on iPhone/iPad turn it on in Settings › General › About › Certificate Trust Settings.

In the IKEv2 VPN app tap Add VPN, enter your server address, then pick one:

  • Username + password: your username and password. Nothing else to install.
  • Pre-shared key: the shared secret; identity = anything (your name, for example).
  • Certificate (.p12): download NAME.p12 from the --share link and import it in the app with the certificate's password from --show.

No .pem file needed: Android trusts the server's Let's Encrypt certificate by itself. Only a server installed with --own-ca needs ca.pem imported in the app as the server's certificate.

In the IKEv2 VPN app choose Your own server: your server address, username and password.

  • With a domain name: that's all — Windows trusts the Let's Encrypt certificate.
  • With only an IP address: download ca.cer from the --share link and pick it in the app's certificate field (or double-click it › Install Certificate › Local Machine › Trusted Root Certification Authorities). Windows needs the server name in a form a Let's Encrypt certificate for an IP can't give, so the script makes this one just for Windows.
  • Using Windows' own VPN settings instead of the app? Download windows-setup.ps1 (next to ca.cer if you have one) and run it in PowerShell as administrator.

Installing a certificate? Check its SHA-256 fingerprint matches the one the script shows.

Manage your VPN

sudo brooog-ikev2 --showserver address, logins, pre-shared key and certificate passwords
sudo brooog-ikev2 --sharea 10-minute link and QR code with the files for your devices
sudo brooog-ikev2 --add-user NAMEa username + password for another person (random password, or add one after the name)
sudo brooog-ikev2 --del-user NAMEremove a username
sudo brooog-ikev2 --add-cert NAMEa certificate login for another device (profile + .p12)
sudo brooog-ikev2 --del-cert NAMErevoke a certificate (a lost phone, for example)
sudo brooog-ikev2 --psk newa new pre-shared key (then update it on your devices)
sudo brooog-ikev2 --statusrunning? connected devices, certificate expiry
sudo brooog-ikev2 --uninstallremove everything the script added

One login can be used on several devices at once. The Let's Encrypt certificate renews by itself (certificates for IP addresses last 6 days, so it checks twice a day). The server keeps no connection logs.

If it doesn't connect

UDP 500 and 4500 are blocked: open them in your provider's firewall (step 4). Some public Wi-Fi networks block VPNs; try mobile data.

The server address must be exactly the one the script used (domain or IP, see sudo brooog-ikev2 --show), and for a pre-shared key the Remote ID too. On Windows with only an IP address, install ca.cer first (step 5).

Check the username and password, or the pre-shared key, with sudo brooog-ikev2 --show (they're case-sensitive), and that the app's authentication matches the one you're using. A revoked certificate (--del-cert) stops working.

Run sudo brooog-ikev2 --status: the firewall should be active. If your provider blocks traffic between networks, contact them. Rerunning the script fixes changed settings without losing your logins.

Don't want to run a server?

Brooog VPN: servers in many countries, ready in one tap, with IKEv2, WireGuard, VLESS and more.

Get Brooog VPN

Questions? [email protected]