/ip ipsec proposal
set [ find default=yes ] auth-algorithms=sha1 disabled=no enc-algorithms=aes-128-cbc,3des lifetime=30m name=default pfs-group=modp1024
/ip ipsec peer
add address=XX.XX.17.122/32 auth-method=pre-shared-key dh-group=modp1024 disabled=no dpd-interval=30s enc-algorithm=aes-128,3des exchange-mode=ike2 \
generate-policy=no hash-algorithm=sha1 policy-template-group=default secret=test send-initial-contact=yes
/ip ipsec policy
add action=encrypt disabled=no dst-address=10.168.0.0/20 dst-port=any ipsec-protocols=esp level=unique priority=0 proposal=default protocol=all \
sa-dst-address=XX.XX.17.122 sa-src-address=XX.XX.53.118 src-address=10.0.5.0/29 src-port=any tunnel=yes
/ip address
add address=10.0.5.1/29 interface=V2-1 network=10.0.5.0
xxx@instance-1:~$ ifconfig
ens4: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1460
inet 10.168.0.2 netmask 255.255.255.255 broadcast 0.0.0.0
inet6 fe80::4001:aff:fea8:2 prefixlen 64 scopeid 0x20<link>
ether 42:01:0a:a8:00:02 txqueuelen 1000 (Ethernet)
RX packets 1809 bytes 1041959 (1.0 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1829 bytes 214386 (214.3 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 160 bytes 13111 (13.1 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 160 bytes 13111 (13.1 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
xxx@instance-1:~$ ping 10.0.5.1
PING 10.0.5.1 (10.0.5.1) 56(84) bytes of data.
64 bytes from 10.0.5.1: icmp_seq=1 ttl=63 time=78.6 ms
64 bytes from 10.0.5.1: icmp_seq=2 ttl=63 time=76.9 ms
64 bytes from 10.0.5.1: icmp_seq=3 ttl=63 time=84.9 ms
^C
--- 10.0.5.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 5ms
rtt min/avg/max/mdev = 76.920/80.126/84.871/3.423 ms
xxx@instance-1:~$ ping 10.168.0.2
PING 10.168.0.2 (10.168.0.2) 56(84) bytes of data.
64 bytes from 10.168.0.2: icmp_seq=1 ttl=64 time=0.015 ms
64 bytes from 10.168.0.2: icmp_seq=2 ttl=64 time=0.043 ms
^C
--- 10.168.0.2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 29ms
rtt min/avg/max/mdev = 0.015/0.029/0.043/0.014 ms
xxx@instance-1:~$ sudo ufw status
Status: inactive
xxx@instance-1:~$
/interface bridge
add name="BGP GCP VPN" protocol-mode=none
/ip address
add address=169.254.0.1/30 comment="BGP GCP" interface="BGP GCP VPN" network=169.254.0.0
/ip ipsec profile
add dh-group=modp1024 enc-algorithm=aes-128 lifetime=10h10m name=profile_1 nat-traversal=no proposal-check=exact
/ip ipsec peer
add address=XX.XXX.XX.221/32 exchange-mode=ike2 name=peer2 profile=profile_1
/ip ipsec proposal
set [ find default=yes ] enc-algorithms=aes-128-cbc lifetime=3h
/ip ipsec identity
add peer=peer2 secret=same-password-here-than-in-gcp
/ip ipsec policy
add dst-address=169.254.0.2/32 level=unique peer=peer2 sa-dst-address=XX.XXX.XX.221 sa-src-address=0.0.0.0 src-address=169.254.0.1/32 tunnel=yes
add dst-address=10.XX.XX.0/29 level=unique peer=peer2 sa-dst-address=XX.XXX.XX.221 sa-src-address=0.0.0.0 src-address=0.0.0.0/0 tunnel=yes
/routing bgp instance
set default as=64512 client-to-client-reflection=no redistribute-connected=yes redistribute-ospf=yes redistribute-static=yes router-id=XXX.XX.1.1
/routing bgp network
add network=169.254.0.0/30 synchronize=no
/routing bgp peer
add hold-time=infinity in-filter=gcp-in name=peer1 out-filter=gcp-out remote-address=169.254.0.2 remote-as=64513 ttl=default
/routing filter
add action=discard chain=gcp-out prefix=XXX.XXX.XX.64 prefix-length=26
add action=discard chain=gcp-out prefix=169.254.0.0 prefix-length=30
@gargola
i tried your configuration. Our vpn tunnel is up but Bgp session status not. Do you have another config in firewall filter, mange of nat as well?
also how we test vpn connection? i tried pinging 169.254.0.1 from mikrotik (169.254.0.2) no luck. I also tried creating gce instance using same network not working as well.
@gargola I have few question.
Do you have any connectivity problems? I wrote to MikroTik support because my tunnel sometimes disconnects and when reconnecting which seems all fine some part of networks defined in policy don't work (Ping doesn't goes through). After disable/enable that policy it starts working again
Unfortunately that's what I do also but that's not a solution for unstable IPsec tunnel. So again I believe MikroTik has serious issue with IPsec. That's not a trick to have stable IPsec connection between two mikrotik devices or virtual instances like CHR rather than having stable connection between mikrotik and other provider e.g GCP or AWS (in the second scenario I don't know if there are the same issues).@eset yes, sometimes and randomly the ipsec tunnel is connected but no traffic passing through, so the bgp goes down. I have to reset everything manually and it comes back, I got almost fixed it setting the timers a google request them on their manual, but still having some random issues. The easiest way I've found that fix the tunnel is killing the active peer.
@gargola I have few question.
Do you have any connectivity problems? I wrote to MikroTik support because my tunnel sometimes disconnects and when reconnecting which seems all fine some part of networks defined in policy don't work (Ping doesn't goes through). After disable/enable that policy it starts working again
Emīls Z.04/12/19 09:40:03
Hello,
Please try the previously suggested workarounds - disabling phase 2 lifetime on MikroTik side and disabling pfs group on MikroTik side. IKEv2 protocol has independent rekeying times so they does not have to match on both sides. Also PFS group can be set to none, there is a reference in the GCP documentation regarding it if you insist on following it despite my recommendations.
"If your VPN gateway requires DH settings for Phase 2, use the same settings you used for Phase 1."
I have news for that subject@eset yes, sometimes and randomly the ipsec tunnel is connected but no traffic passing through, so the bgp goes down. I have to reset everything manually and it comes back, I got almost fixed it setting the timers a google request them on their manual, but still having some random issues. The easiest way I've found that fix the tunnel is killing the active peer.
@gargola I have few question.
Do you have any connectivity problems? I wrote to MikroTik support because my tunnel sometimes disconnects and when reconnecting which seems all fine some part of networks defined in policy don't work (Ping doesn't goes through). After disable/enable that policy it starts working again
Hello,
RouterOS has policy based IPsec only. You can configure 0.0.0.0/0<->0.0.0.0/0 traffic selector, but you will not be able to route specific traffic over the tunnel, so that really is not an option at this time.
Yeah we've been asking for VTI IPSEC for years now . What many guys have done in days past on traditional non cloud networks is run a GRE or IPIP tunnel and setup IPSEC over the endpoints to be able to run a routing protocol.So basically the only way to have stable tunnel between GCP and Mikrotik is to switch into Policy Based routingHello,
RouterOS has policy based IPsec only. You can configure 0.0.0.0/0<->0.0.0.0/0 traffic selector, but you will not be able to route specific traffic over the tunnel, so that really is not an option at this time.
Flags: T - template, X - disabled, D - dynamic, I - invalid, A - active, * - default
0 T * group=default src-address=0.0.0.0/0 dst-address=0.0.0.0/0 protocol=all proposal=default template=yes
1 A peer=peer2 tunnel=yes src-address=169.254.0.5/32 src-port=any dst-address=169.254.0.6/32 dst-port=any protocol=all action=encrypt
level=unique ipsec-protocols=esp sa-src-address=0.0.0.0 sa-dst-address=35.22X.XX.XX proposal=default ph2-count=1
2 A peer=peer2 tunnel=yes src-address=0.0.0.0/0 src-port=any dst-address=10.0.X.0/29 dst-port=any protocol=all action=encrypt level=unique
ipsec-protocols=esp sa-src-address=0.0.0.0 sa-dst-address=35.22X.XX.XX proposal=default ph2-count=1
But how you are using bgp In policy based ? You can't do that with gcp when you don't define in gcp that you need to do it. After that you need 0.0.0.0/0 (any) in traffic selector. But this isn't possible from mikrotik side with bgp. That what you have is policy based but configured wrong way. You are using 0.0.0.0/0 here when policy based routing requires specific , defined networks on both sides where 0.0.0.0/0 is not an option. On fact if you are using it like that , according to gcp, you are using basically route based method from gcp not policy. That's why you are still facing issue. Define networks, loose bgp , because that doesn't work either, define static routes and the tunnel will be stable. I was there already, someday using Linux peer with strongswan where had policy based and it never had issue with stability.Hi eset, djdrastic.
I'm using policy based:
Policy #1 is to route from the addresses of the bgp session, policy #2 is to route from all my network 0.0.0.0/0 to the /29 that I have in GCP.Code: Select allFlags: T - template, X - disabled, D - dynamic, I - invalid, A - active, * - default 0 T * group=default src-address=0.0.0.0/0 dst-address=0.0.0.0/0 protocol=all proposal=default template=yes 1 A peer=peer2 tunnel=yes src-address=169.254.0.5/32 src-port=any dst-address=169.254.0.6/32 dst-port=any protocol=all action=encrypt level=unique ipsec-protocols=esp sa-src-address=0.0.0.0 sa-dst-address=35.22X.XX.XX proposal=default ph2-count=1 2 A peer=peer2 tunnel=yes src-address=0.0.0.0/0 src-port=any dst-address=10.0.X.0/29 dst-port=any protocol=all action=encrypt level=unique ipsec-protocols=esp sa-src-address=0.0.0.0 sa-dst-address=35.22X.XX.XX proposal=default ph2-count=1
I'm getting a very stable tunnel, I mean, yeah I have to reset (kill the connection) but is every 3 or more weeks or sometimes it restore without my intervention
have you set /ip firewall nat ?Hello guys, I closed a VPN between Google Cloud and my RB but I can't ping the servers between the networks, let alone access it through the invalid IP through RDP.
My local network is 192.168.0.0/24 my Google Cloud network is 10.1580.0./20. Can you help me ?