Free Dynamic DNS: Remote Access to Home Server

This tutorial explains how to setup Dynamic DNS (DDNS) to remotely access your home server with a free domain name! Using dynDNS, you can access any devices in your home network from anywhere in the world.

This page is still work in progress, for more information check out the video which is linked in the title image.

Forward ports to server

Find your standard gateway (if its not simply 192.168.1.1) by opening a new CMD command line and entering

ipconfig /all

Open your router settings, log in and find the “port-forwarding” section and forward port 80 and 443 to your home server

Best DynDNS service provider

In order to access your home server through a domain name, you will need to get an account with a DynDNS service provider. I usually recommend to go with https://dynu.com since they provide excellent service and are completely free to use.

After creating an account on Dynu, click on the “DDNS Services” option and create your first free DDNS domain name.

Note: If you own a domain name, you can just as well use that!

After creating a free domain name, Dynu should automatically use the he IPv4 address that you’re currently using to link to your domain name. If you have a static IP address, you can skip the next step.

Automatically update IP address

If you have a dynamic IP address (which is the default with most ISP’s), your IP address will regularly change. Therefore, we need to periodically report our latest public IP address to Dynu in order to still be able to access our home server form outside of our local network. To this end, we need to create a new cronjob by opening crontab:

sudo crontab -e

and add a new Crontob by adding the following line

*/15 * * * * wget -O dynulog -4 "https://api.dynu.com/nic/update?hostname=example.dynu.com&myip=10.0.0.0&myipv6=no&username=someusername&password=somepassword"

Provide your hashed password, as can be obtained from https://www.dynu.com/NetworkTools/Hash

Setup subdomains

If you want to provide access to multiple applications running on your home server, set up CNAME records under “DNS Records”.

Apache Reverse Proxy Configuration

To access both your Nextcloud and Bitwarden instance running on your home server, you will need to configure Apache to work as a reverse proxy.

Open the Apache configuration file

sudo nano /etc/apache2/sites-available/000-default.conf

and enter virtual host entries. Following two examples for Nextcloud and Bitwarden:

<VirtualHost *:80>

    ServerName YOURDOMAIN.giize.com
    DocumentRoot /var/www/nextcloud

    <Directory /var/www/nextcloud/>
        Require all granted
        AllowOverride All
        Options FollowSymLinks MultiViews

        <IfModule mod_dav.c>
            Dav off
        </IfModule>

        RewriteEngine On
        RewriteRule ^/\.well-known/carddav https://%{SERVER_NAME}/remote.php/dav/ [R=301,L]
        RewriteRule ^/\.well-known/caldav https://%{SERVER_NAME}/remote.php/dav/ [R=301,L]
        RewriteRule ^/\.well-known/host-meta https://%{SERVER_NAME}/public.php?service=host-meta [QSA,L]
        RewriteRule ^/\.well-known/host-meta\.json https://%{SERVER_NAME}/public.php?service=host-meta-json [QSA,L]
        RewriteRule ^/\.well-known/webfinger https://%{SERVER_NAME}/public.php?service=webfinger [QSA,L]

    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

<VirtualHost *:80>

    ServerName SUBDOMAIN.YOURDOMAIN.giize.com

    ProxyVia On
    ProxyRequests Off
    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/
    ProxyPreserveHost on

    <Proxy *>
          Options FollowSymLinks MultiViews
          AllowOverride All
          Order allow,deny
          allow from all
    </Proxy>

    ErrorLog /var/log/apache2/error.log
   CustomLog /var/log/apache2/access.log example
</VirtualHost>

Next, you will need to enable a few Apache modifications and reload Apache

sudo a2enmod proxy proxy_http
sudo service apache2 restart

Fix untrusted domain error on Nextcloud

If you are able to successfully connect to the applications running on your home server using the free domain name from Dynu but you get the “Access through untrusted domain” error then you need to modify your Nextcloud configuration file

array (
  0 => '192.168.1.xx',
  1 => 'yourdomain.dynu.com',
),

6 thoughts on “Free Dynamic DNS: Remote Access to Home Server”

  1. hye im a bit confuse about how to set the cron, what’s the ip should i put at the cron? my static pc ip address or my public ip address ??

    Reply
  2. */15 * * * * wget -O dynulog -4 “https://api.dynu.com/nic/update?hostname=example.dynu.com&myip=10.0.0.0&myipv6=no&username=someusername&password=somepassword”

    do i need to change this with credentials from dynu? for username and passwd?

    that example.dynu.com do i need to change my current domain?? myip=10.0.0.0 do i need to change to my isp public ip address or my static pc ip address ??

    im sorry im new, can u help me?

    Reply
  3. Your guidance is great! I’m just experiencing some issues getting my Nextcloud running, and I’m clearly not as experienced as you are. Would you perhaps be willing to help? Currently I’m routing all my traffic through a Wireguard VPN which is set-up on my router. I have no clue how to connect to my Nextcloud(server) when that VPN is active. I am able to access it whenever I disable it and connect directly to my ISPmodem, but just can’t seem to figure out how I can get it to work with the VPN still active.

    Hope you can help me out! Feel free to contact me via mail

    Reply

Leave a Comment

Dear reader

Ads allow me to dedicate a significant amount of time into the creation of valuable content both on YouTube as well as on this website.

Please support my work by disabling your ad blocker or whitelisting this site!

Alternatively, you can remove all ads on this site by becoming a supporter for as little as 2$/month. Thereby, you will directly support my content on YouTube and on this blog!