I have a reasonably complex routing requirement. I’ve made it work on Cisco, I’ve made it work on Snapgear but I can’t nut it out on Mikrotik.
Side A (source) has public IP address XXX.XXX.XXX.XXX and private LAN AAA.AAA.AAA.AAA/24 . Side B (destination) has public IP YYY.YYY.YYY.YYY and private LAN BBB.BBB.BBB.BBB/24. Now for the tricky part… destination needs all traffic to BBB.BBB.BBB.BBB/24 to come from source CCC.CCC.CCC.CCC/32.
IPsec tunnel connects phase 1 but phase 2 expires immediately. What else would be needed to achieve this goal? I can post a working cisco config if that would help.
Had similar problem with Mikrotik and D-Link. Solved partialy by using SH1 instead of MD5. Tunnel was establishing
Still I couldn’t access Dlinks LAN from Mikrotik, luckily the needs where to access Mikrotiks LAN from D-Links subnet
Then solved it very simply - bought 2 Mikrotik routers and made a simple IPIP tunnel
Try setting generate-policy to no and writing your own static phase two policies that select traffic from C.C.C.C/32 to B.B.B.B/24 and vice versa. The automatically generated policy can’t know about the NAT requirement.
Create a bridge interface
/interface bridge print
Flags: X - disabled, R - running
0 R name=“SunriseLAN” mtu=1500 l2mtu=65535 arp=proxy-arp mac-address=00:00:00:00:00:00
protocol-mode=none priority=0x8000 auto-mac=yes admin-mac=00:00:00:00:00:00
max-message-age=20s forward-delay=15s transmit-hold-count=6 ageing-time=5m
Assign desired source IP to the interface
/ip address print
;;; Sunrise Loopback
CCC.CCC.CCC.CCC/32 CCC.CCC.CCC.CCC CCC.CCC.CCC.CCC SunriseLAN
Create a source nat rule for the LAN to the remote LAN
;;; Sunrise
chain=srcnat action=src-nat to-addresses=CCC.CCC.CCC.CCC src-address=AAA.AAA.AAA.AAA/24
dst-address=BBB.BBB.BBB.BBB out-interface=SunriseLAN ← Note out-if is the bridge
And of course the IPsec masquerade bypass rule
;;; Sunrise VPN
chain=srcnat action=accept src-address=CCC.CCC.CCC.CCC dst-address=BBB.BBB.BBB.BBB/24