How to remotely access your VPN-connected computer with Dynamic DNS

By using a dynamic DNS service in conjunction with some static routes on your home computer, you can access your home network, files and computers remotely, even if your main computer which reports your IP to the dynamic DNS service is permanently connected to a VPN.

This is a problem that I’ve been trying to crack for a long time now. I want to be able to access my home network remotely. The problem seems simple enough, but there were a number of roadblocks stopping me from doing this.

Firstly, my Internet connection at home has a dynamic IP address. This means it’s hard to target it because the IP address changes regularly. The solution to this is to use a Dynamic DNS service. The way these services work is to run a utility in the background on your computer and report its current IP address back to the Dynamic DNS service. It ties this IP address to one of its own domain names or a custom domain name that you ascribe to them.

I started to pursue this option. I purchased my own domain name and got an account at Dynu, one of several free dynamic DNS services and attached my domain name to it. I installed the IP Update Utility on my home computer, added my account credentials and successfully started reporting my IP address back to Dynu. However, there was a problem…

My computer is always connected to a VPN. Thus, whenever the IP Update Utility retrieved my IP address, it was getting the IP address of my VPN, not my public IP address. Thus, if I tried to use that to access my home network, I’d instead end up at the servers of my VPN service.

This was a hindrance for me for a long time, but today, I decided there must be a way around it, so after a lot of research, asking questions and trial and error, I found the answer.

The answer is to add your Dynamic DNS service’s IP addresses to your route table. This tells your computer that traffic to your Dynamic DNS service should go straight to your router (unprotected), rather than through your VPN. Thus, the dynamic DNS service gets the public IP address of your router, as you want it to.

I have Macs, so my instructions are for macOS, but if you have Windows, this is how to add a static route in Windows.

Once you have the IP addresses of your dynamic DNS service, use the following command in Terminal where 1.1.1.1 is the IP address of your dynamic DNS service and 10.0.1.1 is your router’s local IP address:

sudo route add -net 1.1.1.1 -netmask 255.255.255.255 -gateway 10.0.1.1

For the record, if you use Dynu, the IP addresses you need to do this for are:

  • 172.82.165.74
  • 199.233.237.18
  • 199.233.237.20
  • 176.56.236.89
  • 199.241.29.200
  • 192.30.32.138
  • 192.249.63.60

Once you do that, the next time the IP Update Utility sends an update to Dynu, you should notice that the IP address has changed to your public IP address.

With that, you can now effectively target your home network to allow you to remotely connect to your computers and files.

Author: Dave

Dave is many things. Most importantly, he’s a husband and a father to Ellie and Jack. Almost as important, he’s British (though he lives in Florida). Following on from there, he’s a WordPress developer and civil engineer, has an unhealthy love of hummus, is vegan, likes cider, wants to travel to Iceland and Japan, loves solving puzzles and is a realist.

Leave a Reply