The mikrotiks A and B are both edge routers/firewalls, and both have public IP's which are dynamic.
...
I've been reading about the various options you suggest
GRE is even more outated than L2TP; IKE (v1) which is used as part of the standardized L2TP/IPsec combo is kind of outdated too but since both ends are under your administration, nothing prevents you from ignoring that standard and using IKEv2 to encrypt the L2TP (or GRE, or IPIP). The clear advantage of L2TP is the way it substitutes IP level fragmentation by a MLPPP-level one. Nothing else (bare IPsec, something-over-IPsec) has this "magic power" of not running into MTU/fragmentation issues.
And yes, if you have dynamic addresses but there is no NAT between the devices, you can use fqdn as the
remote-address of IPIP or GRE tunnel destination, as well as as the
address of an IPsec peer.
I just remember I had some surprising behaviour on reboot where an IPsec peer had a non-existent fqdn as
address, as it has shadowed other peers for some reason - I don't remember the details but it was definitely wrong, normally the peers are automatically sorted by prefix length of the
address, but this one ended up being the first one but catching all incoming requests nevertheless.
Out of interest I still would like to learn how to do a pure IKEv2 tunnel. I would appreciate a bit more info on your suggestions:
1. Add auxiliary static IP addresses to A and B: Both routers already have 3 static internal/non-routable IP's each. Can I use those? If not, I know how the responder (A) can assign B a static IP, but do I need to create another interface on A and assign it another static IP? I haven't figure out why this is necessary, but I suspect it has to do with #2 below
2. Multiple policies for an identity: I'm having trouble with implementing this. I tried creating multiple policy templates on A in the group associated with my tunnel, but when B connects no policies are generated. I suspect because the dst address I'm setting (1.0.3.0/24) does not match/overlap the dynamic address given to B's end of the tunnel. But not sure.
If I try to create a (non-template) policy it always refuses to save.
Couldn't change IPsec policy <0.0.0.0/0;0->1.0.3.0/24:0> cannot convert template to policy (6)
Am I missing something obvious here?
The auxiliary static addresses were necessary to deal with the dynamic IP of an external NAT, so that the IPIP or GRE tunnel could use a fixed
remote-address; if you don't mind to rely on dynamic DNS updates (and you've got no other choice anyway) and there is no NAT, they are not needed.
With bare IPsec, you don't need them either - the policies may refer only to the subnets on both sites you actually want to make reachable to each other.
Policies always refer to a
peer as a static configuration item, but their
sa-dst-address is dynamically set to the
remote-address taken from the
active-peer data (it used to be different but it works this way for at least two years now). So if multiple initiators connect to the same local responder, policies for each of them can be dynamically created and get the correct
sa-dst-address.
To let policies be dynamically created, you need to set
generate-policy to something else than
no on the
identity row representing the remote peer; if you want to restrict the templates only to a few allowed ones and/or indicate a distinct
proposal to be used rather than the default one, you have to add a policy template group, mark the newly added templates as belonging to that group, and set its name in the
policy-template-group on the
identity row.
Regarding the error message you get, I have no idea how you got there. If you choose to edit an existing template, it makes sense; if you choose to add a new policy from scratch, I cannot see why such a message should appear.
So Site A would look as follows:
/ip ipsec peer
add name=siteB address=siteb.ocg-ltd.ca exchange-mode=ike2 profile=...
add name=roadWarriors exchange-mode=ike2 passive=yes profile=...
/ip ipsec identity
add peer=siteB auth-mode=... generate-policy=no ...auth mode specific parameters...
/ip ipsec policy
add peer=siteB src-address=a1.sub.net/mask dst-addrtess=b1.sub.net/mask tunnel=yes proposal=...
...(7 more rows)
add peer=siteB src-address=a3.sub.net/mask dst-addrtess=b3.sub.net/mask tunnel=yes proposal=...
(bear in mind that if the road warriors connect to Site A but have to access subnets at Site B, you need even more policies)
During the debug phase, you want the policies at Site B to be generated dynamically, hence:
/ip ipsec peer
add name=siteA address=sitea.ocg-ltd.ca exchange-mode=ike2 profile=...
/ip ipsec policy group add name=forSiteA
/ip ipsec policy add group=forSiteA template=yes proposal=...
/ip ipsec identity
add peer=siteA auth-mode=... generate-policy=port-strict policy-template-group=forSiteA ...auth mode specific parameters...