ProtonVPN on Mikrotik

OK, success ! I seem to be sending all traffic over the Proton VPN … here is my config for anyone who is stuck -

# aug/06/2020 21:23:22 by RouterOS 6.47.1
# software id = 1E7M-1D8F
#
# model = RB4011iGS+
# serial number = serial
/interface bridge
add admin-mac=18:1F:1A:12:16:15 auto-mac=no comment=defconf name=bridge
/interface pppoe-client
add add-default-route=yes disabled=no interface=ether1 name=pppoe-out1 \
    password=password use-peer-dns=yes user=username
/interface ethernet switch port
set 0 default-vlan-id=0
set 1 default-vlan-id=0
set 2 default-vlan-id=0
set 3 default-vlan-id=0
set 4 default-vlan-id=0
set 5 default-vlan-id=0
set 6 default-vlan-id=0
set 7 default-vlan-id=0
set 8 default-vlan-id=0
set 9 default-vlan-id=0
set 10 default-vlan-id=0
set 11 default-vlan-id=0
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip ipsec mode-config
add name=ProtonVPN responder=no src-address-list=local
/ip ipsec policy group
add name=ProtonVPN
/ip ipsec profile
add enc-algorithm=aes-256 hash-algorithm=sha256 name=ProtonVPN
/ip ipsec peer
add address=nl.protonvpn.com exchange-mode=ike2 name=ProtonVPN profile=\
    ProtonVPN
/ip ipsec proposal
add auth-algorithms=sha256 enc-algorithms=aes-256-cbc name=ProtonVPN \
    pfs-group=none
/ip pool
add name=dhcp ranges=192.168.88.10-192.168.88.254
/ip dhcp-server
add address-pool=dhcp disabled=no interface=bridge name=defconf
/interface bridge port
add bridge=bridge comment=defconf interface=ether2
add bridge=bridge comment=defconf interface=ether3
add bridge=bridge comment=defconf interface=ether4
add bridge=bridge comment=defconf interface=ether5
add bridge=bridge comment=defconf interface=ether6
add bridge=bridge comment=defconf interface=ether7
add bridge=bridge comment=defconf interface=ether8
add bridge=bridge comment=defconf interface=ether9
add bridge=bridge comment=defconf interface=ether10
add bridge=bridge comment=defconf interface=sfp-sfpplus1
/ip neighbor discovery-settings
set discover-interface-list=LAN
/interface list member
add comment=defconf interface=bridge list=LAN
add comment=defconf interface=ether1 list=WAN
add interface=pppoe-out1 list=WAN
/ip address
add address=192.168.88.1/24 comment=defconf interface=ether2 network=\
    192.168.88.0
/ip dhcp-client
add comment=defconf interface=ether1
/ip dhcp-server network
add address=192.168.88.0/24 comment=defconf gateway=192.168.88.1
/ip dns
set allow-remote-requests=yes
/ip dns static
add address=192.168.88.1 comment=defconf name=router.lan type=A
/ip firewall address-list
add address=192.168.88.0/24 list=local
/ip firewall filter
add action=accept chain=input comment=\
    "defconf: accept established,related,untracked" connection-state=\
    established,related,untracked
add action=drop chain=input comment="defconf: drop invalid" connection-state=\
    invalid
add action=accept chain=input comment="defconf: accept ICMP" protocol=icmp
add action=accept chain=input comment=\
    "defconf: accept to local loopback (for CAPsMAN)" dst-address=127.0.0.1
add action=drop chain=input comment="defconf: drop all not coming from LAN" \
    in-interface-list=!LAN
add action=accept chain=forward comment="defconf: accept in ipsec policy" \
    disabled=yes ipsec-policy=in,ipsec
add action=accept chain=forward comment="defconf: accept out ipsec policy" \
    disabled=yes ipsec-policy=out,ipsec
add action=fasttrack-connection chain=forward comment="defconf: fasttrack" \
    connection-state=established,related disabled=yes
add action=accept chain=forward comment=\
    "defconf: accept established,related, untracked" connection-state=\
    established,related,untracked
add action=drop chain=forward comment="defconf: drop invalid" \
    connection-state=invalid
add action=drop chain=forward comment=\
    "defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat \
    connection-state=new in-interface-list=WAN
/ip firewall mangle
add action=change-mss chain=forward ipsec-policy=in,ipsec new-mss=1300 \
    passthrough=yes protocol=tcp tcp-flags=syn
/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade" \
    ipsec-policy=out,none out-interface-list=WAN
/ip ipsec identity
add auth-method=eap certificate="" eap-methods=eap-mschapv2 generate-policy=\
    port-strict mode-config=ProtonVPN password=vpnpass peer=\
    ProtonVPN policy-template-group=ProtonVPN username=\
    vpnuser
/ip ipsec policy
add dst-address=0.0.0.0/0 group=ProtonVPN proposal=ProtonVPN src-address=\
    0.0.0.0/0 template=yes
/ip service
set telnet address=192.168.88.0/24
set ftp address=192.168.88.0/24
set www address=192.168.88.0/24
set ssh address=192.168.88.0/24
set api address=192.168.88.0/24
set winbox address=192.168.88.0/24
set api-ssl address=192.168.88.0/24
/system clock
set time-zone-name=Europe/London
/tool mac-server
set allowed-interface-list=LAN
/tool mac-server mac-winbox
set allowed-interface-list=LAN

I added the MSS clamp because there seemed to be an issue loading some pages … but the config should still basically work without it. Think the old issue may have been the source address list I defined in ipsec mode config … but not certain since I’m not an expert. Anyway it works now apparently(don’t forget to load your certificates first). :confused:

Thank you very much for your availability.

I finally succeeded in establishing the tunnel (I forgot to add a rule to receive IKE replies on the INPUT chain of IPTABLES.

Now I will just follow the posted advices to understand how to select the traffic to encapsulate (through static routes or through iptables).

Thanks again.
A.V.

Just like to point out the extra policy that Sindy noted near the beginning of this thread. It might solve your packet issues and resolve the mss issue

I am kinda new to Mikrotik, so would appreciate if you’ve got this figured & fixed to post a little How To/ Tutorial/ Or key steps (maybe leverage an existing How To w some changes)?

Not sure if it’s any help to you guys but SurfShark has a full on guide to setting up IKEv2 VPNs on their site, only issue I found was using the servers dns name drops every 5-10 seconds, but using the Ip address of that server works flawlessly. I’m getting around 250mbps between USA and Iceland, about 150mbps between USA and their multihops…

https://support.surfshark.com/hc/en-us/articles/360012906220-Mikrotik-router-tutorial-with-IKEv2

hey getting a EAP error a little help please

from my log and setuo
ipsec, info  new ike2 SA (I): 89.xxx.xxx.xxx[4500]-193.148.18.40[4500] spi:0daf70b2bc356dad:daf672b176e4d615
ipsec, info, account peer authorized: 89.xxx.xxx.xxx[4500]-193.148.18.40[4500] spi:0daf70b2bc356dad:daf672b176e4d615
ipsec, error EAP failed: 
ipsec, info  killing ike2 SA: 89.xxx.xxx.xxx[4500]-193.148.18.40[4500] spi:0daf70b2bc356dad:daf672b176e4d615

/ip ipsec mode-config add connection-mark=ProtonVPN name=ProtonVPN responder=no
/ip ipsec policy group add name=ProtonVPN
/ip ipsec profile add dh-group=modp4096,modp2048,modp1024 dpd-interval=disable-dpd enc-algorithm=aes-256 hash-algorithm=sha256 name=ProtonVPN
/ip ipsec peer add address=193.148.18.40/32 disabled=yes exchange-mode=ike2 name=ProtonVPN profile=ProtonVPN
/ip ipsec proposal add auth-algorithms=sha256 enc-algorithms=aes-256-cbc name=ProtonVPN pfs-group=none
/ip ipsec identity add auth-method=eap certificate=ProtonVPN_ike_root.der_0 eap-methods=eap-mschapv2 generate-policy=port-strict mode-config=ProtonVPN password=1337 peer=ProtonVPN policy-template-group=ProtonVPN username=flynn
/ip ipsec policy add dst-address=0.0.0.0/0 group=ProtonVPN proposal=ProtonVPN src-address=0.0.0.0/0 template=yes

Have you imported Proton’s root CA certificate to the Mikrotik?

Yes I have

OK. So first, confirm you have changed the password and/or username on the /ip ipsec identity row before posting the export; if you haven’t, change the password at your Proton account (and update it in the identity on the Mikrotik).

Second, do the following:

  1. disable the peer or identity representing the Proton VPN
  2. issue a command /system logging add topics=ipsec,!packet
  3. issue a command /log print follow-only file=ipsec-start where topics~“ipsec”
  4. enable the peer or identity you have disabled in step 1
  5. after 5 seconds, break the /log print … command from step 3, download the file ipsec-start.txt and open it in your favourite text editor
  6. find the EAP failed line and see what’s next, there should be some details on the failure.

done, log here

15:43:49 ipsec processing payload: ENC 
15:43:49 ipsec,debug => iv (size 0x10) 
15:43:49 ipsec,debug ed799a32 6cf36989 5c95bb03 cabe0eb6 
15:43:49 ipsec,debug => decrypted and trimmed payload (size 0x8) 
15:43:49 ipsec,debug 00000008 04020004 
15:43:49 ipsec,debug decrypted packet 
15:43:49 ipsec payload seen: EAP (8 bytes) 
15:43:49 ipsec processing payloads: NOTIFY (none found) 
15:43:49 ipsec processing payload: EAP 
15:43:49 ipsec,error EAP failed:  
15:43:49 ipsec,info killing ike2 SA: 89.xxx.xxx.xxx[4500]-193.148.18.40[4500] spi:383cf41632d912ef:06f704beb94edb5d 
15:43:49 ipsec KA remove: 89.xxx.xxx.xxx[4500]->193.148.18.40[4500] 
15:43:49 ipsec,debug KA tree dump: 89.xxx.xxx.xxx[4500]->193.148.18.40[4500] (in_use=1) 
15:43:49 ipsec,debug KA removing this one...

do you need more of the log??

The colon after “EAP failed” was promising, but as the log shows it was a notification from the server side, it is unlikely the log will shed more light on the reason of the failure. However, if you are absolutely sure that the username and loging are correct (e. g., do they use the same credentials for account management via web and for the VPN authentication?), do post the complete log, I dn’t completely exclude that some hint can be found there.

Yes 100% sure of my credentials are entered correctly
no, account management and vpn credentials are diffrent

over 1600 lines of log here https://pastebin.com/QqTnwQbr

OK, I’ve missed that on your /ip ipsec identity row.

Remove the certificate item from there. The Proton’s root CA certificate you have imported is used by your Mikrotik to verify validity of the certificate provided by the responder (“server”) to authenticate itself to you. Your Mikrotik uses username and password, not certificate, to authenticate itself to the responder. By configuring a certificate, you tell it to use it instead, which confuses the responder. The fact that you’ve used the particular certificate for a wrong purpose is a secondary issue.

removed certificate from identity
new log uploaded https://pastebin.com/23dAZCzq

The differences to my working ProtonVPN configuration are the following:

  • different ProtonVPN server used (different peer address)
  • eap-methods=eap-mschapv2**,eap-peap,eap-ttls**

As the guy above you is successful with eap-mschapv2 alone, I can’t say which of the differences are more important. Maybe something has changed in the meantime.

hmm tried just for the fun of it to remove mschapv2 and added eap-peap,eap-ttls

now my log looks like this
17:49:20 ipsec ← ike2 request, exchange: AUTH:5 193.148.18.40[4500] 1d1480f532a080d8:79e854109793983f
17:49:20 ipsec,debug ===== sending 272 bytes from 89.xxx.xxx.xxx[4500] to 193.148.18.40[4500]
17:49:20 ipsec,debug 1 times of 276 bytes message will be sent to 193.148.18.40[4500]
17:49:20 ipsec,error EAP failed: handshake failed: self signed certificate
17:49:20 ipsec,info killing ike2 SA: 89.xxx.xxx.xxx[4500]-193.148.18.40[4500] spi:1d1480f532a080d8:79e854109793983f
17:49:20 ipsec KA remove: 89.xxx.xxx.xxx[4500]->193.148.18.40[4500]
17:49:20 ipsec,debug KA tree dump: 89.xxx.xxx.xxx[4500]->193.148.18.40[4500] (in_use=1)
17:49:20 ipsec,debug KA removing this one…

Trying to connect to Proton VPN with hAP mini, but

/ip firewall nat print

returns:

Flags: X - disabled, I - invalid, D - dynamic 
 0    ;;; defconf: masquerade
      chain=srcnat action=masquerade out-interface-list=WAN ipsec-policy=out,none

As you can see - no dynamic “ipsec mode-config” NAT rule is created.

My config:

# jan/27/2021 05:24:29 by RouterOS 6.48
# software id = BZYU-I2XF
#
# model = RB931-2nD
# serial number = ***
/ip ipsec mode-config
add name=ProtonVPN responder=no src-address-list=local
/ip ipsec policy group
add name=ProtonVPN
/ip ipsec profile
add dh-group=modp4096,modp2048,modp1024 dpd-interval=disable-dpd enc-algorithm=aes-256 hash-algorithm=sha256 name=ProtonVPN
/ip ipsec peer
add address=ua-01.protonvpn.com exchange-mode=ike2 name=ProtonVPN profile=ProtonVPN
/ip ipsec proposal
add auth-algorithms=sha512 enc-algorithms=aes-256-cbc name=ProtonVPN pfs-group=none
/ip pool
add name=dhcp ranges=192.168.88.10-192.168.88.254
/ip dhcp-server
add address-pool=dhcp disabled=no interface=bridge name=defconf
/ip address
add address=192.168.88.1/24 comment=defconf interface=bridge network=192.168.88.0
/ip dhcp-client
add comment=defconf disabled=no interface=ether1 use-peer-dns=no use-peer-ntp=no
/ip dhcp-server network
add address=192.168.88.0/24 comment=defconf gateway=192.168.88.1
/ip dns
set allow-remote-requests=yes use-doh-server=https://1.1.1.1/dns-query verify-doh-cert=yes
/ip dns static
add address=192.168.88.1 comment=defconf name=router.lan
/ip firewall address-list
add address=192.168.88.0/24 list=local
/ip neighbor discovery-settings
set discover-interface-list=LAN
/ip firewall filter
add action=accept chain=input comment="defconf: accept established,related,untracked" connection-state=established,related,untracked
add action=drop chain=input comment="defconf: drop invalid" connection-state=invalid
add action=accept chain=input comment="defconf: accept ICMP" protocol=icmp
add action=accept chain=input comment="defconf: accept to local loopback (for CAPsMAN)" dst-address=127.0.0.1
add action=drop chain=input comment="defconf: drop all not coming from LAN" in-interface-list=!LAN
add action=accept chain=forward comment="defconf: accept in ipsec policy" ipsec-policy=in,ipsec
add action=accept chain=forward comment="defconf: accept out ipsec policy" ipsec-policy=out,ipsec
add action=fasttrack-connection chain=forward comment="defconf: fasttrack" connection-state=established,related
add action=accept chain=forward comment="defconf: accept established,related, untracked" connection-state=established,related,untracked
add action=drop chain=forward comment="defconf: drop invalid" connection-state=invalid
add action=drop chain=forward comment="defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat connection-state=new in-interface-list=WAN
/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade" ipsec-policy=out,none out-interface-list=WAN
/ip ipsec identity
add auth-method=eap certificate="" eap-methods=eap-mschapv2 generate-policy=port-strict mode-config=ProtonVPN password=*** peer=ProtonVPN policy-template-group=ProtonVPN username=\
    ***
/ip ipsec policy
add dst-address=0.0.0.0/0 group=ProtonVPN proposal=ProtonVPN src-address=0.0.0.0/0 template=yes
/ip service
set telnet disabled=yes
set ftp disabled=yes
set api disabled=yes
set winbox disabled=yes
set api-ssl disabled=yes

What am I doing wrong?