{"id":1633,"date":"2021-01-13T14:58:40","date_gmt":"2021-01-13T12:58:40","guid":{"rendered":"https:\/\/helia.ee\/koolitus\/?page_id=1633"},"modified":"2021-01-13T14:58:40","modified_gmt":"2021-01-13T12:58:40","slug":"mikrotik-ipsec-tunnel-mikrotik-to-pfsense","status":"publish","type":"page","link":"https:\/\/helia.ee\/koolitus\/?page_id=1633","title":{"rendered":"Mikrotik &#8211; IPSec Tunnel : Mikrotik to pfSense"},"content":{"rendered":"<header class=\"entry-header\">\n<h1 class=\"entry-title \">IPSec Tunnel : Mikrotik to pfSense<\/h1>\n<div class=\"entry-meta\"><\/div>\n<hr class=\"featurette-divider __before_content\" \/>\n<\/header>\n<section class=\"entry-content \">\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" class=\"wp-image-434\" src=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/logical_pfsense_mikrotik_ipsec.png\" sizes=\"(max-width: 391px) 100vw, 391px\" srcset=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/logical_pfsense_mikrotik_ipsec.png 391w, https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/logical_pfsense_mikrotik_ipsec-150x50.png 150w\" alt=\"\" data-attachment-id=\"434\" data-permalink=\"https:\/\/www.zerodispersion.com\/ipsec-tunnel-mikrotik-to-pfsense\/logical_pfsense_mikrotik_ipsec\/\" data-orig-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/logical_pfsense_mikrotik_ipsec.png\" data-orig-size=\"391,130\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"logical_pfsense_mikrotik_ipsec\" data-image-description=\"\" data-medium-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/logical_pfsense_mikrotik_ipsec.png\" data-large-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/logical_pfsense_mikrotik_ipsec.png\" \/><\/figure>\n<h2>Introduction<\/h2>\n<p>I recently began working with a Mikrotik router OS based device for use in small business. I thought this was the perfect time to try out some cross platform configurations between Mikrotik and pfSense which are both very popular in the hobbyist and small business space.<\/p>\n<p>This post will show the steps I used to configure an IPSec tunnel between a Mikrotik router and a pfSense firewall. This is a basic tunnel configuration so traffic will flow freely through the tunnel based on the phase 2 configuration. This is a great configuration if you want to tunnel some traffic between two trusted networks.<\/p>\n<p>The tunnel shown in this configuration is an IPv4 tunnel only, but IPv6 traffic could be added with minor tweaks. A Mutal PSK authentication is used to simplify the configuration.<\/p>\n<p>This configuration has not been audited for maximum security and has not been tested for performance.<\/p>\n<h2>Requirements<\/h2>\n<p>This configuration is based on the following systems:<\/p>\n<ul>\n<li>pfSense version 2.4.4<\/li>\n<li>Mikrotik version 6.46.6<\/li>\n<\/ul>\n<p>The systems must be able to reach each other over a WAN interface and should have unique LAN IP address ranges. You will also need to add a rule on pfSense to accept the ISAKMP connection on port 500. To be most secure you can create this rule to only allow the peer IP\/host.<\/p>\n<h2>Configure Phase 1 \u2013 pfSense<\/h2>\n<p>Of the two platforms pfSense is probably the most logical of the two in how it lays out the configuration. The configuration entries are neat and tidy and nested in the GUI.<\/p>\n<p>Navigate to<strong><em>\u00a0VPN -&gt; IPSec -&gt; Tunnel<\/em><\/strong>. Then click the\u00a0<strong><em>Add P1<\/em><\/strong>\u00a0button to start adding the new phase 1 entry. Then begin filling in the\u00a0<strong><em>General Information<\/em><\/strong>\u00a0as shown.<\/p>\n<ul>\n<li>Key Exchange Version: IKEv2<\/li>\n<li>Internet Protocol: IPv4<\/li>\n<li>Interface: WAN (or other if applicable)<\/li>\n<li>Remote Gateway: IP or hostname of the Mikrotik router (I used a hostname)<\/li>\n<\/ul>\n<figure class=\"wp-block-image size-medium is-style-default\"><img decoding=\"async\" class=\"wp-image-404\" src=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step1-1024x377.png\" sizes=\"(max-width: 1024px) 100vw, 1024px\" srcset=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step1-1024x377.png 1024w, https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step1-150x55.png 150w, https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step1.png 1142w\" alt=\"\" data-attachment-id=\"404\" data-permalink=\"https:\/\/www.zerodispersion.com\/ipsec-tunnel-mikrotik-to-pfsense\/pfsense_phase1_step1\/\" data-orig-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step1.png\" data-orig-size=\"1142,421\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"pfsense_phase1_step1\" data-image-description=\"\" data-medium-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step1-1024x377.png\" data-large-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step1.png\" \/><\/figure>\n<p>Then fill in the following for the\u00a0<em><strong>Phase 1 Proposal (Authentication)<\/strong><\/em><\/p>\n<ul>\n<li>Authentication Method: Mutual PSK<\/li>\n<li>My identifier: My IP Address<\/li>\n<li>Peer identifier: Peer IP Address<\/li>\n<li>Pre-Shared Key: Click the\u00a0<strong><em>Generate new Pre-Shared Key<\/em><\/strong>\u00a0button to create a key for this tunnel<\/li>\n<\/ul>\n<figure class=\"wp-block-image size-medium\"><img decoding=\"async\" class=\"wp-image-406\" src=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step2-1024x269.png\" sizes=\"(max-width: 1024px) 100vw, 1024px\" srcset=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step2-1024x269.png 1024w, https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step2-150x39.png 150w, https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step2.png 1144w\" alt=\"\" data-attachment-id=\"406\" data-permalink=\"https:\/\/www.zerodispersion.com\/ipsec-tunnel-mikrotik-to-pfsense\/pfsense_phase1_step2\/\" data-orig-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step2.png\" data-orig-size=\"1144,301\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"pfsense_phase1_step2\" data-image-description=\"\" data-medium-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step2-1024x269.png\" data-large-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step2.png\" \/><\/figure>\n<p>Next, create\/update a\u00a0<strong>Phase 1 Proposal (Encryption Algorithm)<\/strong>. You should be able to get by with a single correct entry here.<\/p>\n<ul>\n<li>Algorithm: AES<\/li>\n<li>Key length: 128 bits (I\u2019m sure you can go larger as dictated by your requirements)<\/li>\n<li>Hash: SHA256<\/li>\n<li>DH Group: 14 (2048 bit)<\/li>\n<\/ul>\n<figure class=\"wp-block-image size-medium\"><img decoding=\"async\" class=\"wp-image-407\" src=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step3-1024x227.png\" sizes=\"(max-width: 1024px) 100vw, 1024px\" srcset=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step3-1024x227.png 1024w, https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step3-150x33.png 150w, https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step3.png 1141w\" alt=\"\" data-attachment-id=\"407\" data-permalink=\"https:\/\/www.zerodispersion.com\/ipsec-tunnel-mikrotik-to-pfsense\/pfsense_phase1_step3\/\" data-orig-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step3.png\" data-orig-size=\"1141,253\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"pfsense_phase1_step3\" data-image-description=\"\" data-medium-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step3-1024x227.png\" data-large-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step3.png\" \/><\/figure>\n<p>The final step in phase 1 is to go over the advanced options. The defaults should be fine. Then click\u00a0<strong><em>Save<\/em><\/strong>.<\/p>\n<figure class=\"wp-block-image size-medium\"><img decoding=\"async\" class=\"wp-image-413\" src=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step4-946x512.png\" sizes=\"(max-width: 946px) 100vw, 946px\" srcset=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step4-946x512.png 946w, https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step4-150x81.png 150w, https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step4.png 1148w\" alt=\"\" data-attachment-id=\"413\" data-permalink=\"https:\/\/www.zerodispersion.com\/ipsec-tunnel-mikrotik-to-pfsense\/pfsense_phase1_step4\/\" data-orig-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step4.png\" data-orig-size=\"1148,621\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"pfsense_phase1_step4\" data-image-description=\"\" data-medium-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step4-946x512.png\" data-large-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase1_step4.png\" \/><\/figure>\n<h2>Configure Phase 1 \u2013 Mikrotik<\/h2>\n<p>Configuration of the Mikrotik router is shown through the web GUI that runs on port 80 of the device. Login to your router and navigate to<strong><em>\u00a0IP -&gt; IPSec<\/em><\/strong>. There will be multiple configurations that need created or adjusted.<\/p>\n<p>First, we can configure the peer by going to<strong><em>\u00a0IP -&gt; IPSec -&gt; Peers<\/em><\/strong>\u00a0and clicking\u00a0<strong><em>Add New<\/em><\/strong>. Then fill in the following:<\/p>\n<ul>\n<li>Name: This can be the hostname or other identified you want to use<\/li>\n<li>Address: This can be an IP address or hostname<\/li>\n<li>Port and Local address can be left as default<\/li>\n<li>Profile can be left as default<\/li>\n<li>Exchange mode: IKE2<\/li>\n<li>Passive: Disabled<\/li>\n<li>Send INITIAL_CONTACT: Enabled<\/li>\n<\/ul>\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" class=\"wp-image-417\" src=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase1_step1.png\" sizes=\"(max-width: 642px) 100vw, 642px\" srcset=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase1_step1.png 642w, https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase1_step1-150x85.png 150w\" alt=\"\" data-attachment-id=\"417\" data-permalink=\"https:\/\/www.zerodispersion.com\/ipsec-tunnel-mikrotik-to-pfsense\/mikrotik_phase1_step1\/\" data-orig-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase1_step1.png\" data-orig-size=\"642,364\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"mikrotik_phase1_step1\" data-image-description=\"\" data-medium-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase1_step1.png\" data-large-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase1_step1.png\" \/><\/figure>\n<p>Next we need to update the default profile to match our pfSense settings. Head over to\u00a0<strong><em>IP -&gt; IPSec -&gt; Profiles<\/em><\/strong>\u00a0and click on\u00a0<strong><em>default<\/em><\/strong>\u00a0and change the settings as follows. When you are done click\u00a0<strong><em>OK<\/em><\/strong>. Settings not mentioned can remain at default.<\/p>\n<ul>\n<li>Hash Algorithms: SHA256<\/li>\n<li>Encryption Algorithm: aes-128<\/li>\n<li>DH Group: modp2048<\/li>\n<\/ul>\n<figure class=\"wp-block-image size-medium\"><img decoding=\"async\" class=\"wp-image-418\" src=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase1_step2-403x512.png\" sizes=\"(max-width: 403px) 100vw, 403px\" srcset=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase1_step2-403x512.png 403w, https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase1_step2-118x150.png 118w, https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase1_step2.png 441w\" alt=\"\" data-attachment-id=\"418\" data-permalink=\"https:\/\/www.zerodispersion.com\/ipsec-tunnel-mikrotik-to-pfsense\/mikrotik_phase1_step2\/\" data-orig-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase1_step2.png\" data-orig-size=\"441,560\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"mikrotik_phase1_step2\" data-image-description=\"\" data-medium-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase1_step2-403x512.png\" data-large-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase1_step2.png\" \/><\/figure>\n<p>Finally, go over to<strong><em>\u00a0IP -&gt; IPSec -&gt; Identities<\/em><\/strong>\u00a0and click\u00a0<strong><em>Add New<\/em><\/strong>\u00a0to create an identity for this tunnel.<\/p>\n<ul>\n<li>Enabled: Checked<\/li>\n<li>Peer: The peer you created earlier<\/li>\n<li>Auth. Method: pre shared key<\/li>\n<li>Secret: The key generated in pfSense<\/li>\n<li>My ID Type: auto<\/li>\n<li>Remote ID Type: auto<\/li>\n<li>Match by: remote id<\/li>\n<\/ul>\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" class=\"wp-image-420\" src=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase1_step3.png\" sizes=\"(max-width: 538px) 100vw, 538px\" srcset=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase1_step3.png 538w, https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase1_step3-150x125.png 150w\" alt=\"\" data-attachment-id=\"420\" data-permalink=\"https:\/\/www.zerodispersion.com\/ipsec-tunnel-mikrotik-to-pfsense\/mikrotik_phase1_step3\/\" data-orig-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase1_step3.png\" data-orig-size=\"538,447\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"mikrotik_phase1_step3\" data-image-description=\"\" data-medium-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase1_step3.png\" data-large-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase1_step3.png\" \/><\/figure>\n<h2>Verify Phase 1<\/h2>\n<p>Verifying phase 1 will show us that the the devices have connectivity to one another and no firewall rules are blocking the session from being established.<\/p>\n<p>In pfSense go to\u00a0<strong><em>Status -&gt; IPSec<\/em><\/strong>\u00a0and look for your IPSec session to be\u00a0<strong><em>Established<\/em><\/strong>.<\/p>\n<p>In Mikrotik you can verify the Phase 1 session under\u00a0<strong><em>IP -&gt; IPSec -&gt; Active Peers<\/em><\/strong>. You should see an increasing uptime for the configured session.<\/p>\n<h2>Configure Phase 2 \u2013 pfSense<\/h2>\n<p>Phase 2 is where we tell the firewall how to identify which packets need encrypted and sent to the remote peer. It also contains the configuration of the encryption algorithms to use in transit. To begin adding your phase 2 entry go to<strong><em>\u00a0VPN -&gt; IPSec -&gt; Tunnels<\/em><\/strong>. Find the Phase 1 entry you just created and click the<strong><em>\u00a0+ Show Phase 2 Entries<\/em><\/strong>. There shouldn\u2019t be any yet. Then click the\u00a0<strong><em>Add P2<\/em><\/strong>\u00a0button.<\/p>\n<p>Fill in the General Information as follows:<\/p>\n<ul>\n<li>Mode: Tunnel IPv4<\/li>\n<li>Local Network: LAN Subnet (most likely)<\/li>\n<li>Remote Network: Fill in the LAN subnet behind the Mikrotik that you want to reach from pfSense<\/li>\n<\/ul>\n<figure class=\"wp-block-image size-medium\"><img decoding=\"async\" class=\"wp-image-425\" src=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase2_step1-1024x425.png\" sizes=\"(max-width: 1024px) 100vw, 1024px\" srcset=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase2_step1-1024x425.png 1024w, https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase2_step1-150x62.png 150w, https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase2_step1.png 1148w\" alt=\"\" data-attachment-id=\"425\" data-permalink=\"https:\/\/www.zerodispersion.com\/ipsec-tunnel-mikrotik-to-pfsense\/pfsense_phase2_step1\/\" data-orig-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase2_step1.png\" data-orig-size=\"1148,477\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"pfsense_phase2_step1\" data-image-description=\"\" data-medium-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase2_step1-1024x425.png\" data-large-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase2_step1.png\" \/><\/figure>\n<p>Next fill in the Phase 2 Proposal (SA\/Key Exchange) as follows:<\/p>\n<ul>\n<li>Protocol: ESP<\/li>\n<li>Encryption Algorithms\n<ul>\n<li>AES128-GCM \u2013 128 Bits<\/li>\n<li>AES192-GCM \u2013 Auto<\/li>\n<li>AES256-GCM \u2013 Auto<\/li>\n<\/ul>\n<\/li>\n<li>Hash Algorithms\n<ul>\n<li>SHA256<\/li>\n<\/ul>\n<\/li>\n<li>PFS Key Group: 14 (2048 bit)<\/li>\n<\/ul>\n<figure class=\"wp-block-image size-medium\"><img decoding=\"async\" class=\"wp-image-424\" src=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase2_step2-876x512.png\" sizes=\"(max-width: 876px) 100vw, 876px\" srcset=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase2_step2-876x512.png 876w, https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase2_step2-150x88.png 150w, https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase2_step2.png 1144w\" alt=\"\" data-attachment-id=\"424\" data-permalink=\"https:\/\/www.zerodispersion.com\/ipsec-tunnel-mikrotik-to-pfsense\/pfsense_phase2_step2\/\" data-orig-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase2_step2.png\" data-orig-size=\"1144,669\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"pfsense_phase2_step2\" data-image-description=\"\" data-medium-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase2_step2-876x512.png\" data-large-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/pfsense_phase2_step2.png\" \/><\/figure>\n<p>When you are done click\u00a0<strong><em>Save<\/em><\/strong>.<\/p>\n<h2>Configure Phase 2 \u2013 Mikrotik<\/h2>\n<p>First we need to configure the Mikrotik Phase 2 proposal to match pfSense. Go to\u00a0<strong><em>IP -&gt; IPSec -&gt; Proposals<\/em><\/strong>\u00a0and click on the default proposal to edit it.<\/p>\n<ul>\n<li>Auth Algorithms:\n<ul>\n<li>sha256<\/li>\n<\/ul>\n<\/li>\n<li>Encr. Algorithms\n<ul>\n<li>aes-192 ctr<\/li>\n<li>aes-128 gcm<\/li>\n<li>aes-256 gcm<\/li>\n<\/ul>\n<\/li>\n<li>PFS Group: modp2048<\/li>\n<\/ul>\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" class=\"wp-image-428\" src=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase2_step1.png\" sizes=\"(max-width: 401px) 100vw, 401px\" srcset=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase2_step1.png 401w, https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase2_step1-142x150.png 142w\" alt=\"\" data-attachment-id=\"428\" data-permalink=\"https:\/\/www.zerodispersion.com\/ipsec-tunnel-mikrotik-to-pfsense\/mikrotik_phase2_step1\/\" data-orig-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase2_step1.png\" data-orig-size=\"401,424\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"mikrotik_phase2_step1\" data-image-description=\"\" data-medium-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase2_step1.png\" data-large-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase2_step1.png\" \/><\/figure>\n<p>The final step for phase 2 on the Mikrotik is to create a policy. Navigate to\u00a0<strong><em>IP -&gt; IPSec -&gt; Policies<\/em><\/strong>\u00a0and click\u00a0<strong><em>Add New<\/em><\/strong>. The fill in the settings as follows:<\/p>\n<ul>\n<li>Enabled: Checked<\/li>\n<li>Peer: The peer you created<\/li>\n<li>Tunnel: Checked (If you don\u2019t check this you might lose your remote management, be careful)<\/li>\n<li>Src Address: Subnet and mask of local subnet to tunnel<\/li>\n<li>Dst. Address: Subnet and mask of remote subnet to tunnel<\/li>\n<li>Protocol: 255 (all)<\/li>\n<li>Action: encrypt<\/li>\n<li>Level: require<\/li>\n<li>IPSec Protocols: esp<\/li>\n<li>Proposal: default<\/li>\n<\/ul>\n<figure class=\"wp-block-image size-medium\"><img decoding=\"async\" class=\"wp-image-430\" src=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase2_step3-430x512.png\" sizes=\"(max-width: 430px) 100vw, 430px\" srcset=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase2_step3-430x512.png 430w, https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase2_step3-126x150.png 126w, https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase2_step3.png 464w\" alt=\"\" data-attachment-id=\"430\" data-permalink=\"https:\/\/www.zerodispersion.com\/ipsec-tunnel-mikrotik-to-pfsense\/mikrotik_phase2_step3\/\" data-orig-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase2_step3.png\" data-orig-size=\"464,552\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"mikrotik_phase2_step3\" data-image-description=\"\" data-medium-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase2_step3-430x512.png\" data-large-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/mikrotik_phase2_step3.png\" \/><\/figure>\n<h2>Testing the Configuration<\/h2>\n<p>There are two ways to test the tunnel. The most obvious is probably to have a host on one LAN ping a host on the other LAN, this assumes though that you have hosts in both LANs that can ping which might not be the case if one side is remote or a new deployment. You can still test the tunnel though from Mikrotik.<\/p>\n<p>To test from Mikrotik go to<strong><em>\u00a0Tools -&gt; Ping<\/em><\/strong>\u00a0and setup a ping to the LAN gateway on the pfSense system. In my case the far end LAN is 192.168.1.1. I was able to test it by using the Mikrotik bridge interface as the source interface.<\/p>\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" class=\"wp-image-431\" src=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/test_mikrotik_ping.png\" sizes=\"(max-width: 639px) 100vw, 639px\" srcset=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/test_mikrotik_ping.png 639w, https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/test_mikrotik_ping-150x101.png 150w\" alt=\"\" data-attachment-id=\"431\" data-permalink=\"https:\/\/www.zerodispersion.com\/ipsec-tunnel-mikrotik-to-pfsense\/test_mikrotik_ping\/\" data-orig-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/test_mikrotik_ping.png\" data-orig-size=\"639,431\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"test_mikrotik_ping\" data-image-description=\"\" data-medium-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/test_mikrotik_ping.png\" data-large-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/test_mikrotik_ping.png\" \/><\/figure>\n<p>To test from pfSense it\u2019s the same idea, go to\u00a0<strong><em>Diagnostics -&gt; Ping<\/em><\/strong>\u00a0and use the LAN as the Source address.<\/p>\n<figure class=\"wp-block-image size-medium\"><img decoding=\"async\" class=\"wp-image-432\" src=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/test_pfSense_ping-600x512.png\" sizes=\"(max-width: 600px) 100vw, 600px\" srcset=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/test_pfSense_ping-600x512.png 600w, https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/test_pfSense_ping-150x128.png 150w, https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/test_pfSense_ping.png 700w\" alt=\"\" data-attachment-id=\"432\" data-permalink=\"https:\/\/www.zerodispersion.com\/ipsec-tunnel-mikrotik-to-pfsense\/test_pfsense_ping\/\" data-orig-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/test_pfSense_ping.png\" data-orig-size=\"700,597\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"test_pfSense_ping\" data-image-description=\"\" data-medium-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/test_pfSense_ping-600x512.png\" data-large-file=\"https:\/\/www.zerodispersion.com\/wp-content\/uploads\/2020\/05\/test_pfSense_ping.png\" \/><\/figure>\n<p>Statistics are available on both platforms. In pfSense go to\u00a0<strong><em>Status -&gt; IPSec<\/em><\/strong>, in Mikrotik take a look under\u00a0<strong><em>IP -&gt; IPSec -&gt; Active Peers<\/em><\/strong>.<\/p>\n<h2>Conclusion<\/h2>\n<p>Configuring a secure IPSec tunnel between Mikrotik and pfSense was not as hard as I expected. Both platforms have plenty of configuration options allowing a secure tunnel to be established with ease. The drawback to this configuration is that there is no logical interface for the connection on either platform, meaning the tunneled traffic is basically assumed to be in a protected zone as it exits the tunnel. This is great if both sides are more or less the same traffic level, but not sufficient if you want to make rules for traffic as it enters on one side or the other. For that reason I am intending on switching to a GRE tunnel with IPSec which will be shown in a later post.<\/p>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>IPSec Tunnel : Mikrotik to pfSense Introduction I recently began working with a Mikrotik router OS based device for use in small business. I thought this was the perfect time to try out some cross platform configurations between Mikrotik and pfSense which are both very popular in the hobbyist and small business space. This post [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":612,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"class_list":["post-1633","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/pages\/1633","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1633"}],"version-history":[{"count":1,"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/pages\/1633\/revisions"}],"predecessor-version":[{"id":1634,"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/pages\/1633\/revisions\/1634"}],"up":[{"embeddable":true,"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/pages\/612"}],"wp:attachment":[{"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1633"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}