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.
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.
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:
- Your domain name — or press Enter to use the server's IP address.
- Which devices — iPhone/iPad/Mac, Android, Windows, or all.
- How they sign in — one or more of the options below (only those your devices can use).
| Sign in with | iPhone, iPad, Mac | Android | Windows |
|---|---|---|---|
| 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
--hostdomain name or IP the apps connect to (default with--yes: the server's IP)--devicesapple,android,windowsorall(default with--yes: all)--autheap(username + password),psk,cert, or several (default with--yes: eap). Run the script again with other choices to change them later; logins are kept.--emailfor Let's Encrypt notices (optional)--user/--passwordthe first login (default:vpnuserand a random password)--dns 1.1.1.1,8.8.8.8DNS servers for your devices--own-caskip 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.mobileconfigfrom the--sharelink 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.p12from the--sharelink 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.cerfrom the--sharelink 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 toca.cerif 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 --show | server address, logins, pre-shared key and certificate passwords |
sudo brooog-ikev2 --share | a 10-minute link and QR code with the files for your devices |
sudo brooog-ikev2 --add-user NAME | a username + password for another person (random password, or add one after the name) |
sudo brooog-ikev2 --del-user NAME | remove a username |
sudo brooog-ikev2 --add-cert NAME | a certificate login for another device (profile + .p12) |
sudo brooog-ikev2 --del-cert NAME | revoke a certificate (a lost phone, for example) |
sudo brooog-ikev2 --psk new | a new pre-shared key (then update it on your devices) |
sudo brooog-ikev2 --status | running? connected devices, certificate expiry |
sudo brooog-ikev2 --uninstall | remove 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
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).
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.
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.
Questions? [email protected]