作者: 张无忌 時間: 2025-7-20 12:50 標題: 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"
- #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
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
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
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
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
- 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
作者: 张无忌 時間: 2025-7-20 12:51
本帖最後由 张无忌 於 2025-7-21 04:09 編輯
MikroTik logging for IPsec debug
以前不知道怎样debug,所以不知道错在哪里,这次经过朋友说,在MikroTik里有ipsec debug,这样可以知道那些缺,例如sha256,ecp256,aes256-cbc可以加上去。
Add IPsec debug
- /system logging
- add topics=ipsec
- IKE Protocol: IKE
- propsal #1
- enc: aes256-gcm
- prf: hmac-sha256
- dh: ecp256
- proposal #2
- enc: aes256-gcm
- prf: hmac-sha256
- dh: modp2048
- proposal #3
- enc: aes256-cbc
- prf: hmac-sha256
- dh: ecp256
- proposal #4
- enc: aes256-cbc
- prf: hmac-sha256
- dh: modp2048
- matched proposal
- proposal #3
- enc: aes256-cbc
- prf: hmac-sha256
- dh: ecp256
- processing payload: IKE
https://help.mikrotik.com/docs/s ... ardwareacceleration
log iPhone SE1 and iPhone 7
- IKE Protocol: IKE
- propsal #1
- enc: aes256-cbc
- prf: hmac-sha256
- auth: sha256
- dh: modp2048
- proposal #2
- enc: aes256-cbc
- prf: hmac-sha256
- auth: sha256
- dh: ecp256
- proposal #3
- enc: aes256-cbc
- prf: hmac-sha256
- auth: sha256
- dh: modp1536
- proposal #4
- enc: aes128-cbc
- prf: hmac-sha1
- auth: sha1
- dh: modp1024
- proposal #5
- enc: 3des-cbc
- prf: hmac-sha1
- auth: sha1
- dh: modp1024
- matched proposal
- propsal #1
- enc: aes256-cbc
- prf: hmac-sha256
- auth: sha256
- dh: modp2048
- processing payload: IKE
作者: 张无忌 時間: 2025-7-20 12:51
本帖最後由 张无忌 於 2025-7-23 14:00 編輯
以前我学MikroTik通常利用screenshots,把所有settings都记录下来,用一个reference是。
Figure 1: Certificate
[attach]2488420[/attach]
Figure 2a: Policy-General
[attach]2488421[/attach]
Figure 2b: Policy-Action
[attach]2488422[/attach]
Figure 2c: Policy-Status
[attach]2488423[/attach]
Figure 3: Proposal
[attach]2488424[/attach]
Figure 4. Group
[attach]2488425[/attach]
Figure 5: Peer
[attach]2488426[/attach]
Figure 6: Identity with certs
[attach]2488942[/attach]
"Remote ID Type=ignore" for Listing 4:05 "Load ID=<blank>"
Figure 7: Identity with PSK for both iPhone and Android
[attach]2488776[/attach]
Figure 8: Profile
[attach]2488429[/attach]
Figure 9: Config
[attach]2488430[/attach]
作者: 张无忌 時間: 2025-7-20 12:51
本帖最後由 张无忌 於 2025-7-25 22:55 編輯
Certification:
- [admin@MikroTik] /certificate> print
- Flags: K - PRIVATE-KEY; L - CRL; A - AUTHORITY; I - ISSUED; T - TRUSTED
- Columns: NAME, COMMON-NAME
- # NAME COMMON-NAME
- 0 KLA T dt1.ca dt1.ca
- 1 K IT dt1.server dt1.abc.org
- 2 K IT peter peter
- [admin@MikroTik] /certificate>
- [admin@MikroTik] /ip/ipsec>
- active-peers key policy settings
- identity mode-config profile statistics
- installed-sa peer proposal export
- [admin@MikroTik] /ip/ipsec>
- [admin@MikroTik] /ip/ipsec> proposal/
- [admin@MikroTik] /ip/ipsec/proposal> print
- Flags: X - disabled; * - default
- 0 * name="default" auth-algorithms=sha1
- enc-algorithms=aes-256-cbc,aes-192-cbc,aes-128-cbc lifetime=30m
- pfs-group=modp1024
- 1 name="ike2" auth-algorithms=sha256,sha1
- enc-algorithms=aes-256-cbc,aes-192-cbc,aes-128-cbc lifetime=30m
- pfs-group=none
- [admin@MikroTik] /ip/ipsec/proposal>
For another example "Profile"
- [admin@MikroTik] /ip/ipsec> profile
- [admin@MikroTik] /ip/ipsec/profile> print
- Flags: * - default
- 0 * name="default" hash-algorithm=sha1 enc-algorithm=aes-128,3des
- dh-group=modp2048,modp1024 lifetime=1d proposal-check=obey
- nat-traversal=yes dpd-interval=2m dpd-maximum-failures=5
- 1 name="ike2" hash-algorithm=sha256 enc-algorithm=aes-256,aes-128,3des
- dh-group=ecp256,modp2048,modp1024 lifetime=1d proposal-check=obey
- nat-traversal=yes dpd-interval=8s dpd-maximum-failures=4
- [admin@MikroTik] /ip/ipsec/profile>
Admin Panel and OpenWrt Contents
作者: VPN-Guru 時間: 2025-7-20 15:21
感謝張無忌兄的無私分享, 做福在墻内的港燦。
我們是國内互聯網封鎖的受害者, 長居在國内的港燦,上不了美帝的 YouTube FaceBook Whatsapp Google 基本上就是生不如死的:活著的死人。 完全與西方文明世界脫節,只能接收黨媒一面倒的報喜不報憂的厲害了我的國的資訊
其實我們冒死觀看的美帝的 YouTube FaceBook Whatsapp Google 基本上不是什麽國家的機密, 在西方文明世界是一些 【公開的資訊】而已
因此我們的 VPN 科學上網,只 觀看的美帝的 YouTube FaceBook Whatsapp Google 這些公開的資訊,是不需要任何【加密】的
不需要那些 Digital Certificate 和密碼保護那麽【軍事級別的加密】的
就是最簡單的 Password 登入就可以啦, 最重要就是簡單, 能【科學上網】就可以, 其他的完全不重要的。 我們不是什麽銀行這些金融機構, 因此不需要高規格的【軍事級別的加密】
就算是沒有 Security 保安, 被黑客入侵, 我的電腦什麽都沒有,只是用來上網和看 YouTube Facebook 而已, 就算中毒,就【洗機】重灌快樂版本的 Window, Easy Job 啦, 定期清清 C Drive 也是很不錯, 已經成爲生活的 Routine 啦, 沒有什麽大不了的吧
作者: linuxfans 時間: 2025-7-22 21:32
拜读 楼主的精彩好文,学习和收藏!赞!!!
作者: murderfreaker 時間: 2025-7-23 10:37
呢啲史前技術就咪成日重覆拎嚟提完又提啦,仲要搵人推。
仲IKEv2
用一個鐘個Destination IP就被GFW收皮啦。
作者: Newsman 時間: 2025-7-24 23:47
回覆 4# 张无忌
十分有用的资料, 感谢楼主技术分享,造福我们这些新手。。。
