How to Access Home Lab Using Internet

Spread the love

As an IT professional, I firmly believe that a lab environment is an essential need for practice & growth. Due to this reason, I built my lab environment using a high-end desktop last year. We can get the details of the configuration on the blog Desktop Build For SQL Server Lab.

With a self-hosted desktop/server, the challenge that we often face is the accessibility of the same when not at home. Following are the steps that I took to access my home lab website/server, say, the local Grafana website from the internet.

SQLMonitor Grafana deployed in Home Lab

Step 1: Broadband that provides public IP

We need broadband that provides a public IP address. In my locality, Airtel & Hathaway provide public IP addresses with their broadband.

To verify if you have a public IP, simply match the IP addresses in the following 2 methods. If matched, then you have got a public IP.

  • Check the IP Address on your router web page under WAN details.
  • Google ‘What is my ip’. You should get what your IP address really is to the world.

Step 2: Accessibility within the local network

For example, I installed Grafana on machine Host-A in my home lab. I should ensure that the same Grafana website is accessible from other devices (other desktop, laptop, mobile) in the same home lab network.

  • Add firewall exceptions for relevant services on the hypervisor, host, or VM level.
  • Perform MAC address binding on the router web portal for each important server. This ensures a static IP address.
  • Add port forwarding on the router web portal.

If installed within VM, then exceptions need to be added both at the hypervisor and VM level. Otherwise, just at the hypervisor level.

In complex scenario cases, you might need the help of other tools like nginx that help you redirect connectivity from hypervisor to VM.

If everything goes well till this point, then the service/server should be accessible from any other device/machine in the same home lab network. It would be reachable even on the internet using the public IP address of the host.

Step 3: SSL Certificate for Secure Web Access

Modern browsers like Google Chrome, Firefox, etc. do not allow insecure access to a web service. So we need to create & deploy an SSL certificate for the relevant service that we wish to expose on the internet.

This can be achieved either by purchasing a certificate or acquiring it from free SSL Certificate providers like ZeroSSL.com.

Step 4: Dynamic DNS Binding

By this point, we have a website with SSL certificate hosted locally that should be accessible from the internet using the public IP address of the host. Here the challenge is that this public IP address is dynamic, and might change with every reboot of the router.

So if we can register our dynamically changing public IP to a fixed DNS name each time it changes, we would be able to access the service/host easily using the DNS name.

The final task we need to perform is, to bind this dynamic public address with a DNS name so that we can connect to our service/host using the same DNS name. We need to ensure that the dynamic public IP is updated with DNS entry automatically every time the dynamic IP changes.

In my case, I am using noip.com where I have registered a host for DNS name ajaydwivedi.ddns.net, and I use the following PowerShell code to dynamically update the host IP address. Same can be found on https://github.com/imajaydwivedi/SQLMonitor/blob/dev/SQLMonitor/Update-SQLMonitorIP.ps1.

I created a SQLAgent job on a schedule of every 5 minutes that executes the below command in Operating System (CmdExec) step type:-

With this, I am able to successfully access my locally hosted Grafana website https://ajaydwivedi.ddns.net:3000 from anywhere on the internet.

I hope this will be helpful to anyone looking to publish/host their own website/server.

Kindly like, subscribe & share if this blog helped you in any way.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.