<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: A. Kayes</title>
    <description>The latest articles on DEV Community by A. Kayes (@dider).</description>
    <link>https://dev.to/dider</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F271072%2F38344e5a-a045-4ff3-8247-d880c6af4552.png</url>
      <title>DEV Community: A. Kayes</title>
      <link>https://dev.to/dider</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dider"/>
    <language>en</language>
    <item>
      <title>Connect to an OpenVPN server running on Synology DSM 7</title>
      <dc:creator>A. Kayes</dc:creator>
      <pubDate>Wed, 05 Oct 2022 15:37:08 +0000</pubDate>
      <link>https://dev.to/dider/connect-to-an-openvpn-server-running-on-synology-dsm-7-5bal</link>
      <guid>https://dev.to/dider/connect-to-an-openvpn-server-running-on-synology-dsm-7-5bal</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;This is the second part of the series "Configure OpenVPN on Synology DSM 7". In the &lt;a href="https://dev.to/dider/configure-openvpn-server-on-synology-dsm-7-371n"&gt;first part&lt;/a&gt; we've set up an OpenVPN server on Synology DSM 7, configured port forwarding and firewall on our router and NAS.&lt;/p&gt;

&lt;p&gt;In this part we'll see how we can connect to that OpenVPN server using the OpenVPN Connect client in Windows 10 and iOS.&lt;/p&gt;

&lt;h3&gt;
  
  
  The setup
&lt;/h3&gt;

&lt;p&gt;The setup remains the same as what we've used in the &lt;a href="https://dev.to/dider/configure-openvpn-server-on-synology-dsm-7-371n"&gt;first part&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NAS:&lt;/strong&gt; Synology DS920+, DSM 7.1-42661 Update 4&lt;br&gt;
&lt;strong&gt;OpenVPN server app:&lt;/strong&gt; VPN Server package (1.4.7-2901) by Synology Inc.&lt;br&gt;
&lt;strong&gt;Router:&lt;/strong&gt; Ubiquiti UniFi DreamMachine&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OpenVPN clients:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;OpenVPN Connect 3.3.6.2752 on Windows 10&lt;/li&gt;
&lt;li&gt;OpenVPN Connect 3.3.2.5086 on iOS 16.0.2&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The OpenVPN Connect client is an official client developed and maintained by OpenVPN Inc. It can be downloaded from here:&lt;br&gt;
&lt;a href="https://openvpn.net/client-connect-vpn-for-windows/" rel="noopener noreferrer"&gt;https://openvpn.net/client-connect-vpn-for-windows/&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;There's another client called OpenVPN GUI. This is a community project and can also be used on Windows. It can be downloaded from here:&lt;br&gt;
&lt;a href="https://openvpn.net/community-downloads/" rel="noopener noreferrer"&gt;https://openvpn.net/community-downloads/&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We'll use the official OpenVPN Connect client as the UX is pretty identical on both Windows and iOS.&lt;/p&gt;

&lt;h3&gt;
  
  
  Exporting the configuration file:
&lt;/h3&gt;

&lt;p&gt;First we have to export the configuration .ovpn file to be used with the clients. Clicking the &lt;code&gt;Export Configuration&lt;/code&gt; will export the configuration and initiate a file download. The exported file is a .zip file that contains a &lt;code&gt;VPNConfig.ovpn&lt;/code&gt; file (a configuration file for the client) and a &lt;code&gt;README.txt&lt;/code&gt; file (simple instruction on how to set up OpenVPN connection for the client).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftgopozrt6ebdt9teebh7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftgopozrt6ebdt9teebh7.png" alt="Export Configuration"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Following is how the .ovpn file looks like.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

dev tun
tls-client

remote YOUR_SERVER_IP 1194

# The "float" tells OpenVPN to accept authenticated packets from any address,
# not only the address which was specified in the --remote option.
# This is useful when you are connecting to a peer which holds a dynamic address
# such as a dial-in user or DHCP client.
# (Please refer to the manual of OpenVPN for more information.)

#float

# If redirect-gateway is enabled, the client will redirect it's
# default network gateway through the VPN.
# It means the VPN connection will firstly connect to the VPN Server
# and then to the internet.
# (Please refer to the manual of OpenVPN for more information.)

#redirect-gateway def1

# dhcp-option DNS: To set primary domain name server address.
# Repeat this option to set secondary DNS server addresses.

#dhcp-option DNS DNS_IP_ADDRESS

pull

# If you want to connect by Server's IPv6 address, you should use
# "proto udp6" in UDP mode or "proto tcp6-client" in TCP mode
proto udp

script-security 2



reneg-sec 0

cipher AES-256-CBC

auth SHA512

auth-user-pass
comp-lzo
&amp;lt;ca&amp;gt;
-----BEGIN CERTIFICATE-----
MIIF...hHwg==
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIF...GCc=
-----END CERTIFICATE-----

&amp;lt;/ca&amp;gt;
key-direction 1
&amp;lt;tls-auth&amp;gt;
#
# 2048 bit OpenVPN static key
#
-----BEGIN OpenVPN Static key V1-----
c78b6...6c58c2
-----END OpenVPN Static key V1-----

&amp;lt;/tls-auth&amp;gt;
verify-x509-name 'myhostname.synology.me' name



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Let's talk about the configuration file a little.&lt;/p&gt;

&lt;p&gt;We basically have to change one thing in the above config file. At line #4, we have to replace &lt;code&gt;YOUR_SERVER_IP&lt;/code&gt; with the DDNS hostname, &lt;code&gt;myhostname.synology.me&lt;/code&gt;, which we've configured in the &lt;a href="https://dev.to/dider/configure-openvpn-server-on-synology-dsm-7-371n"&gt;first part&lt;/a&gt;. Or we can use the static IP address if we have one.&lt;/p&gt;

&lt;p&gt;The other directive of note is &lt;code&gt;redirect-gateway def1&lt;/code&gt;. This is what determines whether we configure a split-tunnel or full-tunnel VPN. If we want full-tunneling then we have to uncomment the directive. This means that all connection requests, including the ones for websites on the public internet, will go through the VPN server. But we're only interested in accessing the Synology apps like DS Photo, DS Video, DS File etc. (which are only available within our home network and not exposed to the public internet). So, we'll leave this commented out.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;OpenVPN allows VPN server to issue an authentication certificate to the clients.&lt;/li&gt;
&lt;li&gt;Each time VPN Server runs, it will automatically copy and use the certificate shown at &lt;code&gt;Control Panel&lt;/code&gt; &amp;gt; &lt;code&gt;Security&lt;/code&gt; &amp;gt; &lt;code&gt;Certificate&lt;/code&gt;. This is the certificate which we got from Let's Encrypt while configuring DDNS using Synology provider.&lt;/li&gt;
&lt;li&gt;If we want to use a third-party certificate, we have to import the certificate at &lt;code&gt;Control Panel&lt;/code&gt; &amp;gt; &lt;code&gt;Security&lt;/code&gt; &amp;gt; &lt;code&gt;Certificate&lt;/code&gt; &amp;gt; &lt;code&gt;Add&lt;/code&gt; and restart VPN Server. We'll explore this in the third part of this tutorial.&lt;/li&gt;
&lt;li&gt;VPN Server will automatically restart each time the certificate file shown at &lt;code&gt;Control Panel&lt;/code&gt; &amp;gt; &lt;code&gt;Security&lt;/code&gt; &amp;gt; &lt;code&gt;Certificate&lt;/code&gt; is modified. We will also have to export the new .opvn file to all clients.&lt;/li&gt;
&lt;li&gt;More info on Certificates can be found here: &lt;a href="https://kb.synology.com/en-br/DSM/help/DSM/AdminCenter/connection_certificate?version=7" rel="noopener noreferrer"&gt;https://kb.synology.com/en-br/DSM/help/DSM/AdminCenter/connection_certificate?version=7&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Let's check firewall settings on Windows 10
&lt;/h3&gt;

&lt;p&gt;Since we'll be using Windows 10 as our client OS, it's a good idea to check its firewall settings before we try to connect. We need to check whether outgoing UDP requests are allowed on remote port 1194 in Windows Firewall. I've found that it works without having to add any additional rule.&lt;/p&gt;

&lt;h3&gt;
  
  
  Connect using OpenVPN Connect in Windows 10
&lt;/h3&gt;

&lt;p&gt;I've already installed the OpenVPN Connect 3.3.6.2752 client from the link mentioned above under 'The setup'. I've also disconnected from my home Wi-Fi network in Windows and switched to mobile hotspot so that I connect from 'outside' of my home network.&lt;/p&gt;

&lt;p&gt;When we first launch the app, it lets us import a config file via an URL or a file upload. We'll use the file upload option.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fow4aga02z8kya59u2spd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fow4aga02z8kya59u2spd.png" alt="The OpenVPN Connect client"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnv9dy1tti6yfqqh4s9pw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnv9dy1tti6yfqqh4s9pw.png" alt="Select the .ovpn configuration file"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After selecting the .ovpn config file, we're prompted to enter the VPN Username and Password. This is the same &lt;code&gt;vpnuser&lt;/code&gt; that we've configured in &lt;a href="https://dev.to/dider/configure-openvpn-server-on-synology-dsm-7-371n"&gt;part one&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0okbn9c62apbgwxgxrik.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0okbn9c62apbgwxgxrik.png" alt="Enter VPN Username and Password"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We're also being asked to assign a Certificate and Key for the client but we'll skip them. Because we're not concerned with Certificate Authentication in this part. We'll look at that in the third part.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note that we can also customize the profile name at the top.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;After we've entered the Username and Password, let's click the big orange &lt;code&gt;CONNECT&lt;/code&gt; button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fazsiu35dro0k1yg1mgqh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fazsiu35dro0k1yg1mgqh.png" alt="Missing external certificate"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But we're presented with an info dialog that says that the external certificate is missing. It also says that we can still continue if our profile allows connection without client certificate. It does, so we'll click &lt;code&gt;CONTINUE&lt;/code&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;By default the OpenVPN sever doesn't require a client certificate.&lt;/li&gt;
&lt;li&gt;In the config file for the OpenVPN server, &lt;code&gt;openvpn.conf&lt;/code&gt;, there is a directive, &lt;code&gt;verify-client-cert none&lt;/code&gt;, which dictates that.&lt;/li&gt;
&lt;li&gt;The config file is located here on the NAS: &lt;code&gt;usr/syno/etc/packages/VPNCenter/openvpn/openvpn.conf&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;In order to access that file, we have to SSH into the NAS.&lt;/li&gt;
&lt;li&gt;It's possible to tell the client to not expect a client &lt;code&gt;Certificate and Key&lt;/code&gt; because it's a bit annoying to skip it everytime. This can be done by adding this directive to the .ovpn file: &lt;code&gt;setenv CLIENT_CERT 0&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;It's documented here:
&lt;a href="https://openvpn.net/faq/how-to-make-the-app-work-with-profiles-that-lack-a-client-certificate-key/" rel="noopener noreferrer"&gt;https://openvpn.net/faq/how-to-make-the-app-work-with-profiles-that-lack-a-client-certificate-key/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;Anyway, after clicking &lt;code&gt;CONTINUE&lt;/code&gt;, we're hit with another roadblock. This time the connection failed, and the error message read "Peer certificate verification failure".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5jpul4oqz7pp4o5y3x4l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5jpul4oqz7pp4o5y3x4l.png" alt="Connection failed, Peer certificate verification failure"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The culprit is on the last line in the &lt;code&gt;VPNConfig.ovpn&lt;/code&gt; file above:&lt;br&gt;
&lt;code&gt;verify-x509-name 'myhostname.synology.me' name&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This is the issue that I've mentioned about in the &lt;a href="https://dev.to/dider/configure-openvpn-server-on-synology-dsm-7-371n"&gt;first part&lt;/a&gt;. That last line got added when we ticked the &lt;code&gt;Verify server CN&lt;/code&gt; checkbox.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fderhwndaaoapjm69l9lp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fderhwndaaoapjm69l9lp.png" alt="'Verify server CN' checkbox ticked"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When the .ovpn file was exported, the &lt;code&gt;myhostname.synology.me&lt;/code&gt; was wrapped within single quotes (''). And because of this, the client couldn't connect when the .ovpn file was imported to it. It seems like this issue only appeared in OpenVPN Connect client since version 3.3.x.&lt;/p&gt;

&lt;p&gt;Fortunately, after a little googling around I've found a fix, which was provided by the user called &lt;code&gt;DreamCypher&lt;/code&gt; in this OpenVPN Support Forum topic:&lt;br&gt;
&lt;a href="https://forums.openvpn.net/viewtopic.php?p=106554#p106554" rel="noopener noreferrer"&gt;https://forums.openvpn.net/viewtopic.php?p=106554#p106554&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The fix is very simple. We just need to wrap &lt;code&gt;myhostname.synology.me&lt;/code&gt; within double-quotes (""):&lt;br&gt;
&lt;code&gt;verify-x509-name "myhostname.synology.me" name&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;So let's do that, import the updated .ovpn file to the client and try connecting again. It works!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fudnvtz9499iabpp0s5zg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fudnvtz9499iabpp0s5zg.png" alt="VPN connection works"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Connect using OpenVPN Connect in iOS
&lt;/h3&gt;

&lt;p&gt;Let's search for the OpenVPN Connect client in App Store and install it. The client UI is pretty identical to the Windows client.&lt;/p&gt;

&lt;p&gt;Now we have to import the &lt;code&gt;VPNConfig.ovpn&lt;/code&gt; file. There's no need to change anything, just import the exact same file that we've imported to the Windows client.&lt;/p&gt;

&lt;p&gt;I've put it on my Synology NAS home directory and will now open it in the DS File app in iOS.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;DS File is a file manager app developed by Synology.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frkobhrk85xwk0mku5ffx.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frkobhrk85xwk0mku5ffx.PNG" alt="Open the DS File app"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then tap the &lt;code&gt;...&lt;/code&gt; menu and tap on Share.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvtr0scd9pidme4720f2q.JPEG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvtr0scd9pidme4720f2q.JPEG" alt="Tap on Share"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Tap the OpenVPN app icon to import the .ovpn file to it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmyhz5a3zzqfu43c4wcqp.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmyhz5a3zzqfu43c4wcqp.PNG" alt="Tap the OpenVPN app icon"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The UI we're presented with next is already familiar with us by now. We can customize the profile name, enter the VPN Username and Password and tap &lt;code&gt;CONNECT&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;We will leave the &lt;code&gt;Certificate and Key&lt;/code&gt; field with the default value &lt;code&gt;None&lt;/code&gt; as we're not going to use client-side Certificate Authentication. We'll look at how to do that in part three of this tutorial.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiz0kx1bjhqzfhstj2dsi.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiz0kx1bjhqzfhstj2dsi.PNG" alt="Enter Username and Password"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;iOS now prompts us to allow the OpenVPN app to add a VPN configuration to the OS. We will allow it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fndwzs4y03i7laxoqdef6.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fndwzs4y03i7laxoqdef6.PNG" alt="Allow OpenVPN app to add a VPN configuration to iOS"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We're asked to enter our iPhone passcode. Let's do that.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1f6u64xqcpmagkrpv0j9.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1f6u64xqcpmagkrpv0j9.PNG" alt="Enter iPhone passcode"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Et voilà! We're connected.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fol1x2aaxxu8iimqotpp5.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fol1x2aaxxu8iimqotpp5.PNG" alt="VPN connection established"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we go to &lt;code&gt;Settings&lt;/code&gt; &amp;gt; &lt;code&gt;General&lt;/code&gt; &amp;gt; &lt;code&gt;VPN &amp;amp; Device Management&lt;/code&gt; &amp;gt; &lt;code&gt;VPN&lt;/code&gt;, we can see the configuration added by the OpenVPN app.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdf77asemc477det1mwd3.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdf77asemc477det1mwd3.PNG" alt="VPN configuration added by the OpenVPN app in iOS"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;So that's about it. Configuring the client is pretty straight forward (when it works of course ;)). There are tons of very good tutorial videos and posts on OpenVPN all over the internet. And the OpenVPN docs are also very helpful. Hope this tutorial also comes in handy for some.&lt;/p&gt;

</description>
      <category>synology</category>
      <category>openvpn</category>
      <category>openvpnconnect</category>
      <category>security</category>
    </item>
    <item>
      <title>Configure OpenVPN server on Synology DSM 7</title>
      <dc:creator>A. Kayes</dc:creator>
      <pubDate>Wed, 05 Oct 2022 15:36:14 +0000</pubDate>
      <link>https://dev.to/dider/configure-openvpn-server-on-synology-dsm-7-371n</link>
      <guid>https://dev.to/dider/configure-openvpn-server-on-synology-dsm-7-371n</guid>
      <description>&lt;h3&gt;
  
  
  Prologue
&lt;/h3&gt;

&lt;p&gt;I use my Synology DS920+ mainly for the storage of family photos and videos and I have a ton of them. I also have documents, eBooks etc. stored on it. The NAS is not exposed to internet, and I usually access it through an L2TP VPN connection, which I'd configured on my Ubiquiti UniFi DreamMachine in the past, from outside of my home network. It's usually documents that I've accessed from outside so far and never really accessed photos and videos.&lt;/p&gt;

&lt;p&gt;Last week I went on a family weekend getaway trip where I needed to look for some old family photos and videos. I flipped the VPN switch on my iPhone and got connected almost immediately. But not for long. It was frequently disconnecting while watching videos. Usually the L2TP connection works fine for me but something happened that day. I really wished that I had OpenVPN set up as an alternative. And that's exactly what I did first thing after returning home from the trip.&lt;/p&gt;

&lt;h3&gt;
  
  
  What we're doing
&lt;/h3&gt;

&lt;p&gt;This tutorial will be split into 3 parts. In the first part, which is this post, we'll set up the OpenVPN server on our Synology NAS.&lt;/p&gt;

&lt;p&gt;In the &lt;a href="https://dev.to/dider/connect-to-an-openvpn-server-running-on-synology-dsm-7-5bal"&gt;second part&lt;/a&gt;, we'll connect to the VPN server from Windows 10 and iOS, without using client-side Certificate Authentication.&lt;/p&gt;

&lt;p&gt;And in the last part, we'll connect from Windows 10 and iOS using client-side Certificate Authentication.&lt;/p&gt;

&lt;h3&gt;
  
  
  The setup
&lt;/h3&gt;

&lt;p&gt;It's critical to mention the details of the hardware and software being used because in the world of tech, the way of doing things can often change with the changes in hardware or software. So, following are our setup:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NAS:&lt;/strong&gt; Synology DS920+, DSM 7.1-42661 Update 4&lt;br&gt;
&lt;strong&gt;OpenVPN server app:&lt;/strong&gt; VPN Server package (1.4.7-2901) by Synology Inc.&lt;br&gt;
&lt;strong&gt;Router:&lt;/strong&gt; Ubiquiti UniFi DreamMachine&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OpenVPN clients:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;OpenVPN Connect 3.3.6.2752 on Windows 10&lt;/li&gt;
&lt;li&gt;OpenVPN Connect 3.3.2.5086 on iOS 16.0.2&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The OpenVPN Connect client is an official client developed and maintained by OpenVPN Inc. It can be downloaded from here:&lt;br&gt;
&lt;a href="https://openvpn.net/client-connect-vpn-for-windows/"&gt;https://openvpn.net/client-connect-vpn-for-windows/&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;There's another client called OpenVPN GUI. This is a community project and can also be used on Windows. It can be downloaded from here:&lt;br&gt;
&lt;a href="https://openvpn.net/community-downloads/"&gt;https://openvpn.net/community-downloads/&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We'll use the official OpenVPN Connect client as the UX is pretty identical on both Windows and iOS.&lt;/p&gt;

&lt;h4&gt;
  
  
  DDNS
&lt;/h4&gt;

&lt;p&gt;For OpenVPN to work, we need a static IP address for our server. Like most people, I have dynamic external IP address, so creating a DDNS (Dynamic Domain Name System) hostname is required so that even if the external IP address changes, the server can be reached using the DDNS hostname. DDNS allows connection to the Synology NAS over the internet by mapping a hostname to its IP address. I've already configured DDNS using the free synology.me DDNS provider. It's beyond the scope of this post how to do it, but this doc from Synology may be followed: &lt;a href="https://kb.synology.com/en-us/DSM/help/DSM/AdminCenter/connection_ddns?version=7"&gt;https://kb.synology.com/en-us/DSM/help/DSM/AdminCenter/connection_ddns?version=7&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's say our DDNS hostname is &lt;code&gt;myhostname.synology.me&lt;/code&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: if we have a static external IP address, which never changes, then we can simply use that and we do not have to configure DDNS.&lt;/p&gt;

&lt;p&gt;Also note that configuring DDNS using Synology provider will require us to get a certificate from Let's Encrypt and set it as default. This certificate will be automatically used when we export the configuration to be used with the client in the &lt;a href="https://dev.to/dider/connect-to-an-openvpn-server-running-on-synology-dsm-7-5bal"&gt;second part&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Installing the VPN Server package
&lt;/h3&gt;

&lt;p&gt;It's probably the easiest task. We just search for it and install. That's it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qH5EbBcv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0itbofejavyg2aliijot.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qH5EbBcv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0itbofejavyg2aliijot.png" alt="Search and install the VPN Server package" width="880" height="376"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a user to use with OpenVPN server
&lt;/h3&gt;

&lt;p&gt;Any existing user we have on our NAS would work just fine. We only need to grant it the required privilege. But we should really create a separate user just for the purpose of connecting to the VPN server. In doing so, we can restrict the VPN user from pretty much everything else on the NAS. So, in case it gets compromised, it can't be used to access other apps or shared folders.&lt;/p&gt;

&lt;p&gt;Let's open up &lt;code&gt;Control Panel&lt;/code&gt;, select &lt;code&gt;User &amp;amp; Group&lt;/code&gt; from the left-hand-side panel and hit the &lt;code&gt;Create&lt;/code&gt; button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1WTbBv-r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pfqlg69zjdqbp79ma9uq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1WTbBv-r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pfqlg69zjdqbp79ma9uq.png" alt="Click on the Create button in the User &amp;amp; Group app" width="856" height="522"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;User Creation Wizard&lt;/code&gt; will pop up. On the first screen, we fill in the required details like Name and Password and hit &lt;code&gt;Next&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ss-yA3mS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pehmdtvvmaurx757ivzw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ss-yA3mS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pehmdtvvmaurx757ivzw.png" alt="User Creation Wizard, screen 1, fill in required details" width="880" height="627"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the next screen, we can add the user to any group we want. By default, the user is added to the System default group &lt;code&gt;users&lt;/code&gt;. In case we want to create multiple VPN users for different members of the family, we may want to create a dedicated group, say 'vpnusers', with the required privileges or restrictions and assign all VPN users to that group. That way we wouldn't have to restrict or grant the same privileges to individual users manually. For the purpose of this tutorial, we'll leave this as-is and assign the restrictions/ privileges manually on the next screens.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tmHVYNo4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3veovu6dao0vuxsi8s0r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tmHVYNo4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3veovu6dao0vuxsi8s0r.png" alt="User Creation Wizard, screen 2, assign user to groups" width="880" height="627"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the following screen, we can assign permission to access different shared folders. We don't want to assign any. So let's tick the &lt;code&gt;No Access&lt;/code&gt; checkbox at the top to deny access to all shared folders.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--U91Hcymr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ffgunm1ebp4g9oe8lz59.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--U91Hcymr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ffgunm1ebp4g9oe8lz59.png" alt="User Creation Wizard, screen 3, deny access to all shared folders" width="880" height="627"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We'll leave the next step as-is.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--m4UqlZRw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dz65973bk1cvwyn2aut2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--m4UqlZRw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dz65973bk1cvwyn2aut2.png" alt="User Creation Wizard, screen 4, assign user quota, leave as-is" width="880" height="628"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next screen is for assigning application permissions and we want to deny access to all.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--L0NReIfA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o4bpnbvbhuiup9v467hr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--L0NReIfA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o4bpnbvbhuiup9v467hr.png" alt="User Creation Wizard, screen 5, assign application permissions, deny all" width="880" height="627"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We'll leave the next step as-is.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Br1zdzkA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qkusa9rtr1d73z6d8ttp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Br1zdzkA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qkusa9rtr1d73z6d8ttp.png" alt="User Creation Wizard, screen 6, Set user speed limit, leave as-is" width="880" height="627"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The last step is for reviewing the settings and confirm.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--y2IC7qvy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tfjk9cdbnenpbmmjmejn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--y2IC7qvy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tfjk9cdbnenpbmmjmejn.png" alt="User Creation Wizard, screen 7, Confirm settings" width="880" height="627"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Configuring the OpenVPN server
&lt;/h3&gt;

&lt;p&gt;Let's open up the VPN Server app and head straight to the &lt;code&gt;Privilege&lt;/code&gt; screen. We'll grant our newly created &lt;code&gt;vpnuser&lt;/code&gt; the privilege to connect to the VPN Server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hvYtw2Pg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3mzechp6zi1tsthw0azy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hvYtw2Pg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3mzechp6zi1tsthw0azy.png" alt="VPN Server app, Privilege screen, grant privilege to newly created user" width="880" height="493"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, we'll go to the screen for configuring OpenVPN and tick &lt;code&gt;Enable OpenVPN server&lt;/code&gt; checkbox. On this screen we can customize each of the settings. We'll leave the dropdowns as-is, with the default values selected. Then we'll check only the first 4 checkboxes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8TP7xyMY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rqlc0mskzk0xqt7oy0xw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8TP7xyMY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rqlc0mskzk0xqt7oy0xw.png" alt="VPN Server app, OpenVPN screen, leave settings as-is" width="880" height="493"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we want to enable IPv6 server mode, we can check the last one too. But in order to enable OpenVPN server to send IPv6 addresses, we have to first get a prefix via &lt;code&gt;6in4/6to4/DHCP-PD&lt;/code&gt; in &lt;code&gt;Control Panel&lt;/code&gt; &amp;gt; &lt;code&gt;Network&lt;/code&gt; &amp;gt; &lt;code&gt;Network Interface&lt;/code&gt;, then select the prefix on this screen.&lt;/p&gt;

&lt;p&gt;If we don't want the clients to be able to access the server's LAN, we can untick the second checkbox &lt;code&gt;Allow clients to access server's LAN&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Also, take note of the second-to-last checkbox &lt;code&gt;Verify server CN&lt;/code&gt;. We can leave it unticked. But if we tick it, then it creates an issue for the OpenVPN Connect client, which we'll see when we configure the client in the &lt;a href="https://dev.to/dider/connect-to-an-openvpn-server-running-on-synology-dsm-7-5bal"&gt;second part&lt;/a&gt; of this tutorial.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Bgz0wkKF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/stk6dq0hos8hbf6mh88l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Bgz0wkKF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/stk6dq0hos8hbf6mh88l.png" alt="VPN Server app, OpenVPN screen, leave settings as-is" width="880" height="493"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we have to click &lt;code&gt;Apply&lt;/code&gt; for the changes to take effect first before we export the configuration. After clicking the &lt;code&gt;Apply&lt;/code&gt; button, we are shown an information dialog which tells us to check port forwarding and firewall settings on both the NAS and the router. We'll talk about those settings shortly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QiP39Q4o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ei44gsj0edrtvrqyoy37.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QiP39Q4o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ei44gsj0edrtvrqyoy37.png" alt="Info on port forwarding" width="880" height="493"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note that it's a security best practice to not use any default configured port (like 1194 here) and instead use a different available port.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Enable port forwarding on the router
&lt;/h3&gt;

&lt;p&gt;Before the VPN server connection request could reach the Synology NAS (where the VPN server runs), it reaches our router using the external IP address on port 1194. This is the default configured port, whcih we saw earlier. The router then forwards the request to the same port at the NAS' local IP address. But this does not happen automatically. That's why we need to enable port forwarding on the router. The process to do it is pretty much same on most routers and can easily be found online by searching with the router model name. Following is how it looks like on our Ubiquiti UniFi DreamMachine.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VH8C6L0y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9o2i7qr4wfb7biqh01yb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VH8C6L0y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9o2i7qr4wfb7biqh01yb.png" alt="Configure port forwarding on Ubiquiti Unifi DreamMachine" width="880" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MV6a6_y9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u26fdrkunewo3k7lzn7x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MV6a6_y9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u26fdrkunewo3k7lzn7x.png" alt="Configure port forwarding on Ubiquiti Unifi DreamMachine" width="880" height="318"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Check firewall settings on the router
&lt;/h3&gt;

&lt;p&gt;Most of the time any connection attempt on port 1194 will be blocked by default on the routers. So we need to allow this by creating a firewall rule.&lt;/p&gt;

&lt;p&gt;Luckily on our DreamMachine, a rule is automatically created once the port forwarding has been set up.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6RpEn1zM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ivst1ydi0nyi41xj27t6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6RpEn1zM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ivst1ydi0nyi41xj27t6.png" alt="firewall rule automatically created on router" width="880" height="588"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Check firewall settings on the NAS
&lt;/h3&gt;

&lt;p&gt;We need to make sure that port 1194 is allowed to receive UDP connection requests in the Synology firewall. I already have firewall enabled with the default profile and found that the VPN connection can be established without having to add any additional rule. But if it's not the case then we have to add a rule to enable port 1194 (or whatever port we've configured).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NqxI-l2g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ts9iayu120ah649ymjmy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NqxI-l2g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ts9iayu120ah649ymjmy.png" alt="Enable port 1194 in Synology firewall" width="880" height="380"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;That's basically it as far as configuring the OpenVPN server on Synology NAS is concerned. It's not too difficult but we do need to take care to check the firewall settings on both the NAS and the router as most of the time VPN connection issues are caused by misconfigured firewalls.&lt;/p&gt;

&lt;p&gt;In the &lt;a href="https://dev.to/dider/connect-to-an-openvpn-server-running-on-synology-dsm-7-5bal"&gt;next part&lt;/a&gt;, we'll look at how to connect to the OpenVPN server we've just configured.&lt;/p&gt;

</description>
      <category>openvpn</category>
      <category>synology</category>
      <category>openvpnconnect</category>
      <category>security</category>
    </item>
  </channel>
</rss>
