MikroTik + IKEv2 + RSA/PSK authentication + iOS/macOS/Android/Windows
本帖最後由 张无忌 於 2025-7-28 10:53 編輯
MikroTik hAP ac3 v7.19.3
iPhone iOS v18.5
以前用MikroTik hAP ac2[1], 那个时候iPhone 7 and iPhone SE1,到现在iPhone 16e and iPhone 13 Pro,hardware encryption有所提升,在[1]不再适合,而iPhone 16e and iPhone 13 Pro都有error。现在MikroTik要有所改动后,那么iPhone SE1,iPhone 7,iPhone 13 Pro and iPhone 16e都同时适合。iPhone用家可以有两个选择 1)用certs 和 2)只用pre-shared key (secret)。除了iOS(iPhone和iPad),可以参考macOS / Android / Windows[1]。
下面用MikroTik "New Terminal",然后输入,当"sign"要实行之一句完,再继续执行其他多段。
Listing 1: Part A-Firewall输入- #Suitable position
- /ip firewall filter
- add chain=input action=accept protocol=udp dst-port=500,4500 comment="Allow IKEv2"
複製代碼 Listing 2: Part B-Certificates of dt1.ca, dt1.server, and peter- #Define and sign CA "dt1.ca"
- /certificate
- add common-name=dt1.ca name=dt1.ca days-valid=4900
- sign dt1.ca ca-crl-host=xyz.abc.org
- #Define and sign Server "dt1.server"
- add common-name=xyz.abc.org subject-alt-name=DNS:xyz.abc.org name=dt1.server key-usage=tls-server days-valid=4900
- sign dt1.server ca=dt1.ca
- #Server certificate trusted
- /certificate/set dt1.server trusted=yes
- ######################
- #Define and sign client 1 "peter"
- /certificate
- add common-name=peter name=peter subject-alt-name=DNS:peter key-usage=tls-client days-valid=4900
- sign peter ca=dt1.ca
- #Client certificate trusted
- /certificate/set peter trusted=yes
- ######################
- #export certificate of server
- /certificate
- export-certificate dt1.ca type=pem
- #export certificate of "peter"
- /certificate
- export-certificate peter export-passphrase=12345678 type=pkcs12
複製代碼 上面certificates可以delete,重新再来都可以。
Listing 3: Part C-IPsec config including ip pool- /ip ipsec profile
- add name=ike2 hash-algorithm=sha256 enc-algorithm=aes-256,aes-128,3des dh-group=ecp256,modp2048,modp1024
- /ip ipsec proposal
- add name=ike2 pfs-group=none auth-algorithms=sha1,sha256
- /ip pool
- add name=ike2-pool ranges=192.168.77.2-192.168.77.254
- /ip ipsec mode-config
- add address-pool=ike2-pool address-prefix-length=32 name=ike2-conf
- /ip ipsec policy group
- add name=ike2-policies
- /ip ipsec policy
- add dst-address=192.168.77.0/24 group=ike2-policies proposal=ike2 src-address=0.0.0.0/0 template=yes
- /ip ipsec peer
- add exchange-mode=ike2 name=ike2 passive=yes profile=ike2
- /ip ipsec identity
- add auth-method=digital-signature certificate=dt1.server generate-policy=port-strict mode-config=ike2-conf peer=ike2 policy-template-group=ike2-policies
複製代碼 在最后一句"certificate=dt1.server"要看清楚。如果Part C要有改动都可以,不影响Part B-Certifications。
Files in FILE folder
1. drag "cert_export_dt1.ca.crt" into Windows folder
2. darg "cert_export_peter.p12" into Windows folder
Mail to Windows Gmail
1. mail "cert_export_dt1.ca.crt"
2. mail "cert_export_peter.p12"
iPhone Mail (Gmail) for "dt1.ca" , open "dt1.ca", tap "cert_export_dt1.ca.crt"
iPhone Settings: Profile Downloaded, Install Profile "dt1.ca", iPhone passcode
iPhone Mail (Gmail) for "peter.p12" , open "peter", tap "cert_export_peter.p12"
iPhone Settings: Profile Downloaded, Install Profile "peter.p12", iPhone passcode and "12345678" for peter
Listing 4: iPhone IKEv2 configuration with certificates- Type=IKEv2
- Desciption=IKEv2-DT1-peter
- Server=xyz.abc.org
- Remote ID=xyz.abc.org
- Local ID=peter
- User Authentication=None
- Use Certificate=(green on)
- Certificate=peter
複製代碼 以前的code都可以要求certs,今次我们可以用PSK (pre-shared key),用iPhone可以用PSK去注册IKEv2。
Listing 5: Part D-PSK for iPhone and Android without certificates- /ip ipsec identity
- add peer=ike2 auth-method=pre-shared-key secret=hk1997 policy-template-group=ike2-policies mode-config=ike2-conf generate-policy=port-strict remote-id=ignore
複製代碼 "remote-id=ignore" is added to ignore "Local ID=<blank>".
Listing 6: iPhone IKEv2 configuration using a PSK without certificates- Type=IKEv2
- Desciption=IKEv2-DT1-PSK
- Server=xyz.abc.org
- Remote ID=xyz.abc.org
- Local ID=
- User Authentication=None
- Use Certificate=(grey off)
- Secret=hk1997
複製代碼 Listing 7: Android IKEv2 configuration using a PSK without certificates- Name=<Any name>
- Type=IKEv2/IPSec PSK
- Server address=xyz.abc.org
- IPsec identifier=xyz.abc.org
- Pre-shared key=hk1997
複製代碼 测试:
1. iOS iPhone/iPad: RSA SE1、7、13 Pro、16e、iPad Pro all passed
2. iOS iPhone/iPad: PSK SE1、7、13 Pro、16e、iPad Pro all passed
3. macOS: PSK passed
4. Android PSK: all passed
5. Windows 10 RSA: all passed
Remarks:
1. 现在最新的iPhone 16e and SE1都可以注册成功及正常使用。
2. 用certs可以,只有一个certs。不用certs而用PSK都可以,可以多人login。
3. 现在是用ARM microprocessors,改用TILE microprocessors不行,测试时可以,但是只有单边流动,原因要MikroTik才能找出答案。
4. 而你家里hAP ax3 (IPQ-6010) and RB5009UG+S+IN (88F7040)可以在"/ip/ipsec/proposal"加入aes256-gcm[2],但是怎样选,决定于MikroTk。
5. 如果不考虑用Windows IKEv2,可以上面Listing 3:23 "remote-id=ignore"补上去,iPhone IKEv2 configuration "Local ID"不填。
References:
[1] MikroTik RouterOS IKEv2 RSA VPN Settings for both Apple and Android devices
[2] Hardware acceleration |
|
|