This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
networking:router:mikrotik_vpn_ipsec [2019/03/23 09:44] gcooper |
networking:router:mikrotik_vpn_ipsec [2023/06/21 15:26] (current) gcooper |
||
---|---|---|---|
Line 29: | Line 29: | ||
* Cisco Transform Set | * Cisco Transform Set | ||
* Default proposal and default profile in your identity will result in '' | * Default proposal and default profile in your identity will result in '' | ||
+ | * Very fast but less secure than '' | ||
+ | * Many Mikrotik routers support hardware acceleration of '' | ||
* NAT Bypass Rule | * NAT Bypass Rule | ||
* S2S traffic won't pass until done | * S2S traffic won't pass until done | ||
Line 38: | Line 40: | ||
:!: Note that older ROS had the default proposal with '' | :!: Note that older ROS had the default proposal with '' | ||
- | :!: You need to use '' | + | :!: You need to use '' |
:!: Note that we use /32 instead of the actual subnet mask of the WAN interfaces for simplicity and security. | :!: Note that we use /32 instead of the actual subnet mask of the WAN interfaces for simplicity and security. | ||
Line 53: | Line 55: | ||
:global SubnetBehindRouter2 " | :global SubnetBehindRouter2 " | ||
- | :global PreSharedKey "MyPreSharedKey" | + | :global PreSharedKey "YourPreSharedKey" |
</ | </ | ||
Line 72: | Line 74: | ||
/ip ipsec policy | /ip ipsec policy | ||
add dst-address=$SubnetBehindRouter2 sa-dst-address=$Router2WanAddr sa-src-address=$Router1WanAddr \ | add dst-address=$SubnetBehindRouter2 sa-dst-address=$Router2WanAddr sa-src-address=$Router1WanAddr \ | ||
- | src-address=$SubnetBehindRouter1 tunnel=yes | + | src-address=$SubnetBehindRouter1 |
# NAT bypass rule | # NAT bypass rule | ||
Line 99: | Line 101: | ||
# Peer Definition | # Peer Definition | ||
/ip ipsec peer | /ip ipsec peer | ||
- | add address=$Router1WanCidr | + | add address=$Router1WanCidr |
+ | |||
+ | # Peer Identity | ||
+ | /ip ipsec identity | ||
+ | add peer=$Site1Name | ||
# Policy Definition | # Policy Definition | ||
/ip ipsec policy | /ip ipsec policy | ||
- | | + | add dst-address=$SubnetBehindRouter1 sa-dst-address=$Router1WanAddr |
- | | + | src-address=$SubnetBehindRouter2 peer=$Site1Name |
- | | + | |
# NAT bypass rule | # NAT bypass rule | ||
/ip firewall nat | /ip firewall nat | ||
- | add chain=srcnat action=accept comment=" | + | add chain=srcnat action=accept comment=" |
src-address=$SubnetBehindRouter2 dst-address=$SubnetBehindRouter1 | src-address=$SubnetBehindRouter2 dst-address=$SubnetBehindRouter1 | ||
# Cleanup | # Cleanup | ||
/system script environment | /system script environment | ||
+ | remove Site1Name | ||
remove Router1WanAddr | remove Router1WanAddr | ||
remove Router1WanCidr | remove Router1WanCidr | ||
+ | remove SubnetBehindRouter1 | ||
+ | remove Site2Name | ||
remove Router2WanAddr | remove Router2WanAddr | ||
remove Router2WanCidr | remove Router2WanCidr | ||
- | remove SubnetBehindRouter1 | ||
remove SubnetBehindRouter2 | remove SubnetBehindRouter2 | ||
/ | / | ||
</ | </ | ||
- | :!: Try to bring up the tunnel by pinging a host (IP) from one LAN subnet to the other. | + | :!: Try to bring up the tunnel by pinging a host (IP) from one LAN subnet to the other. |
- | :!: **Important note**: While the router will properly route traffic between the LANs at this point, the router itself does not have a route to the remote subnet. | + | :!: **Important note**: While the router will properly route traffic |
< | < | ||
/ip route add disabled=no dst-address=< | /ip route add disabled=no dst-address=< | ||
+ | </ | ||
- | # for example where the remote subnet is 192.168.0.0/ | + | For example where the remote subnet is '' |
+ | |||
+ | < | ||
/ip route add disabled=no dst-address=192.168.0.0/ | /ip route add disabled=no dst-address=192.168.0.0/ | ||
</ | </ | ||
===== One Side with Dynamic IP ===== | ===== One Side with Dynamic IP ===== | ||
+ | |||
+ | https:// | ||
+ | |||
+ | <note tip>To convert a S2S VPN connection from **two-sides-static** to **one-side-dynamic**: | ||
+ | |||
+ | * Modify the (dynamic IP) peer definition on the router with static WAN IP: | ||
+ | * Set the IP address to '' | ||
+ | * Select '' | ||
+ | * Deselect '' | ||
+ | * Responder | ||
+ | * Modify the (static IP) peer definition on the router with dynamic WAN IP: | ||
+ | * Set the IP address to the static WAN IP address of the other router | ||
+ | * Deselect '' | ||
+ | * Select '' | ||
+ | * Initiator | ||
+ | </ | ||
+ | |||
+ | ==== Router with Static IP ==== | ||
+ | |||
+ | :!: In this example, this router has two LAN subnets behind it. | ||
+ | |||
+ | < | ||
+ | /ip ipsec peer | ||
+ | add name=peername passive=yes | ||
+ | /ip ipsec identity | ||
+ | add peer=peername secret=yourpresharedkey | ||
+ | /ip ipsec policy | ||
+ | set 0 disabled=yes | ||
+ | add comment=" | ||
+ | 192.168.0.0/ | ||
+ | add comment=" | ||
+ | 192.168.2.0/ | ||
+ | </ | ||
+ | |||
+ | ==== Router with Dynamic IP ==== | ||
+ | |||
+ | :!: This router has a single LAN subnet behind it. | ||
+ | |||
+ | < | ||
+ | /ip ipsec peer | ||
+ | add address=123.123.123.123/ | ||
+ | /ip ipsec identity | ||
+ | add peer=peer-with-static-ip-name secret=yourpresharedkey | ||
+ | /ip ipsec policy | ||
+ | set 0 disabled=yes | ||
+ | add dst-address=192.168.0.0/ | ||
+ | add dst-address=10.10.1.0/ | ||
+ | </ | ||
+ | |||
+ | FIXME The rest of this section needs verification | ||
http:// | http:// | ||
Line 187: | Line 247: | ||
===== Firewall ===== | ===== Firewall ===== | ||
+ | |||
+ | **IPSec Firewall Rules**: https:// | ||
http:// | http:// |