Connect custom subdomain to Synology NAS

Say you purchased a custom domain mydomain.com and you want to make sure it connects to your Synology NAS. This means that when you type nas.mydomain.com in your browser, you want the browser to reach the public ip address of your network. To figure out what your public IP address is, just type my ip in Google, and you will immediately get it. For the sake of this tutorial, let's imagine that it is 2.247.50.21

nas.mydomain.com -> 2.247.50.21

The problem with this is that your public IP address can potentially change over time for security reasons, and we don't want to always update the connection between domain and public IP.

Introducing DDNS

Dynamic DNS allows you to connect your domain to a service that takes care of automatically updating the public IP for you. There are a bunch of free options, and the one I use is No-IP (the catch is that every 30 days you need to confirm you are still using the service unless you want to pay. Not a deal breaker for me). When you create your account, you then insert the domain name you want, and you will claim a DDNS address in the form of mydomain.ddns.net. This means that, in the final setup, the DDNS will stand in between domain name and public IP address, so that you wqon't need to change a thing as NoIP will take the responsibility to automatically update the information about the public IP.

nas.mydomain.com -> mydomain.ddns.net -> x.x.x.x

Routing your domain to the DDNS

First thing we need to do is that we want to establish the connection between your domain and the DDNS (nas.ydomain.com -> mydomain.ddns.net). This step is fairly simple but changes a bit depending on the company that you got your domain from.

  1. Access your domain control panel
  2. Find where you can add/edit records
  3. Add a new record:
    Type: CNAME
    Name: nas.mydomain.com
    To: mydomain.ddns.net

Note that in this tutorial we are using nas., but you can pick anything you want, syno., mynas....). If in the future you will need to add new subdomains being directed to your network public IP via DDNS, you will just need to add new records like we just did above.

Once this is done, we have finally connected nas.mydomain.com to mydomain.ddns.net, which will automatically redirect the traffic to your network public IP x.x.x.x.

Setup your router to connect web traffic to the Synology DSM

At this point we have connected our domain to our public IP (in this tutorial 2.247.50.21). But once you reach the public IP, you need to tell the traffic where to go within your home local network. In out local network, every single device has its own local IP (usually in the form of 192.168.0.x). In this tutorial we will pretend that we have three connected devices: Router (192.168.0.1), Synology NAS (192.168.0.100), a Printer (192.168.0.200). The Router is what we use to route the traffic however we want, and we will use to say "If you have incoming web traffic from nas.mydomain.com then redirect it to the Synology DSM".

When reaching a domain, web traffic can mainly come in two ways:

  1. http://: HTTP is not secured and goes to port 80
  2. https://: HTTPS is secured and goes to port 443

Your network devices can use thousands of different ports and these ports can be assigned to specific services that you might have at home (i.e. HTTP 192.168.0.1:80, HTTPS 192.168.0.1:443). In other words, when you type http://nas.mydomain.com you will reach your Public IP at specific ports, and we need the Router to redirect the traffic to the Synology DSM.

domain -> DDNS -> public IP -> Synology NAS IP:Synology DSM Port

The Synology DSM uses port 5000 for HTTP and 5001 for HTTPS (HTTPS connection is not active by default but it can be easily setup fdrom the Control Panel). This means that we need to establish the following connections:

http://nas.mydomain.com -> mydomain.ddns.net -> 2.247.50.21 -> 192.168.0.100:5000

https://nas.mydomain.com -> mydomain.ddns.net -> 2.247.50.21 -> 192.168.0.100:5001

To do this, we need to access our router admin panel (in this example 192.168.0.1), login with username and password, and then setup the port forwarding. This process is slightly different for every Router manifacturer, but it usually looks something like this:

Onced this is done, you should be able to reach the Synbology DSM remotely by using http://nas.mydomain.com or https://nas.mydomain.com