{"id":4538,"date":"2022-07-28T17:12:00","date_gmt":"2022-07-28T22:12:00","guid":{"rendered":"https:\/\/www.incredigeek.com\/home\/?p=4538"},"modified":"2022-07-28T15:43:54","modified_gmt":"2022-07-28T20:43:54","slug":"configure-mikrotik-router-as-wireguard-vpn-appliance","status":"publish","type":"post","link":"https:\/\/www.incredigeek.com\/home\/configure-mikrotik-router-as-wireguard-vpn-appliance\/","title":{"rendered":"Configure MikroTik Router as WireGuard VPN Appliance"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p><em>You may need to upgrade your MikroTik if the WireGuard options are not available.<\/em><\/p>\n\n\n\n<p>Quick overview of setting up a MikroTik Router as a VPN appliance.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Configure WireGuard Interface on MikroTik Router<ol><li>Copy interface public key<\/li><li>Add IP address on WireGuard interface<\/li><\/ol><\/li><li>Create WireGuard client config<ol><li>Use above interface public key<\/li><li>Copy the client Public Key<\/li><\/ol><\/li><li>Create a WireGuard Peer on the MikroTik Router<ol><li>Use client Public Key<\/li><li>Assign proper IP address<\/li><\/ol><\/li><\/ol>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Configure WireGuard on Router<\/h2>\n\n\n\n<p>First we need to create a WireGuard interface to use.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/interface\/wireguard add listen-port=51820 mtu=1420 name=wireguard1<\/pre>\n\n\n\n<p>We&#8217;ll need to copy the public key, shown in the following command, for use in the client config.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/interfaces\/wireguard print<\/pre>\n\n\n\n<p>Next we&#8217;ll configure an IP address\/range for the new WireGuard interface.  <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/ip\/address add address=192.168.1.1\/24 network=192.168.1.0 interface=wireguard1<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Configure WireGuard Client<\/h2>\n\n\n\n<p>Download and install the WireGuard application on your computer or phone.<\/p>\n\n\n\n<p>Create an empty config (Ctrl +N), click edit, add the following.  <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Address = 192.168.1.2\/24\nDNS = 9.9.9.9\n\n[Peer]\nPublicKey = ReplaceWithInterfacePublicKeyFromMikrotik\nAllowedIPs = 0.0.0.0\/0\nEndpoint = endpointip:51820<\/pre>\n\n\n\n<p>Here is a screenshot as an example.  We need to copy the public key.  We&#8217;ll use that when we create the peer.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/07\/image-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"834\" height=\"655\" src=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/07\/image-1.png\" alt=\"\" class=\"wp-image-4541\" srcset=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/07\/image-1.png 834w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/07\/image-1-300x236.png 300w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/07\/image-1-768x603.png 768w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/07\/image-1-382x300.png 382w\" sizes=\"auto, (max-width: 834px) 100vw, 834px\" \/><\/a><figcaption>Configure WireGuard Client<\/figcaption><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Create WireGuard Peer<\/h2>\n\n\n\n<p>Now lets create a peer.  Back on the MikroTik, run the following command.  Change the allowed address and public key.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/interface\/wireguard\/peers add allowed-address=192.128.1.2\/32 interface=wireguard1 public-key=\"PublicKeyFromClientCreatedInNextStep\"<\/pre>\n\n\n\n<p>Note that the 192.168.1.2\/32 is important.  If you have multiple clients connected and one of them is setup with a \/24 instead of a \/32, it will cause issues.  I think this is because WireGuard tries to route the whole \/24 over that peer.<\/p>\n\n\n\n<p>Also note that you can not use DHCP with WireGuard.  Each client will have a static IP address assigned in the config.  In this example, 192.168.1.2.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>You should now be all set up and able to connect from your device.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting<\/h2>\n\n\n\n<p>Some issues you may run into.<\/p>\n\n\n\n<p><strong>Unable to have two devices connected at the same time.<\/strong><\/p>\n\n\n\n<p>First, you&#8217;ll need to have one Peer per Client connection.  Either that, or do not connect at the same time.<\/p>\n\n\n\n<p>Second, check and verify that each peer has the ClientIP\/32 in the Allowed Address.  <\/p>\n\n\n\n<p>For example, if the WireGuard interface is using 192.168.1.0\/24, and one of the peers has 192.168.1.4\/24 in the Allowed Address option, then only one client will work.  It appears that the MikroTik will attempt to route all 192.168.1.0\/24 request to 192.168.1.4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You may need to upgrade your MikroTik if the WireGuard options are not available. Quick overview of setting up a MikroTik Router as a VPN appliance. Configure WireGuard Interface on MikroTik Router Copy interface public key Add IP address on &hellip; <a href=\"https:\/\/www.incredigeek.com\/home\/configure-mikrotik-router-as-wireguard-vpn-appliance\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[452],"tags":[301,388,924,1334],"class_list":["post-4538","post","type-post","status-publish","format-standard","hentry","category-mikrotik","tag-mikrotik","tag-routeros","tag-vpn","tag-wireguard"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/4538","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=4538"}],"version-history":[{"count":7,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/4538\/revisions"}],"predecessor-version":[{"id":4547,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/4538\/revisions\/4547"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=4538"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/categories?post=4538"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/tags?post=4538"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}