Sunday, September 4, 2011

Setting Up Version Control On A Home Server

When I first wrote this, I was using Hamachi to create a VPN tunnel into my home network (so I could access it from the outside). It worked okay, but not great. Its service kept stopping and overall it just wasn't reliable. So I switched options.

The problem

The problem with using a home server is that unless you pay extra for a static IP address, chances are your ISP is giving you a dynamic IP address. Which can (and will) change. Which means if you want to access your home server from the outside world, you need to know your home server's IP address, but since it can (and will) change, it turns out to be less than convenient. And if you're like me, I wanted this to be convenient (that was the whole point of having a home server, anyway).

The solution

Use a dynamic DNS service! I initially signed up for No IP to use their dynamic DNS management. But I really wanted to be able to use my own domain name instead of using a domain name provided by No IP. So I bought a domain through Namecheap.

I intentionally did not buy a domain name from Go Daddy. I hate their marketing campaign and they support (or are indifferent towards) Internet and technology laws that I don't support (like SOPA and PIPA). Namecheap, on the other hand, was waaay cheaper, plus they actively fight poorly written and overpowering laws and bills (like SOPA and PIPA). Sorry for the plug, but I have to recommend them. I'm not a domain/Internet guru, so if you need some kind of advanced capabilities with your domain name, I have no idea if Namecheap supports all the features you might need. But they certainly support all the features I need (and plenty more I don't need).

Alright, so I bought a domain name, and then on my home server, I used ddclient to update my domain to point to my home server's (changing) IP address. It worked so well that I ended up using ddclient to point multiple Namecheap domains to my home server (each domain serves a different purpose, and can, if I later decide, be changed to point to a different IP address if I want to split my server's responsibilities amongst multiple servers).

This allows me to have a version control system at home (which regularly gets backed up to the cloud with all my other home computers), and still gives me total control over everything (I can set up SSH, or I can create Samba shares so I can access my files remotely, etc.). It's actually turned out to be fantastic, and I've been using it for over a year now.

In short, here's what I recommend:

  • Buy a domain name with which you can use dynamic DNS
  • Use ddclient (or if you're on Windows/OS X, google for things like "dynamic ip update client" to find something similar) to update that domain name to point to your server's dynamic IP
  • And that's it!

Note that you may have to set up your router to do some port forwarding. Most (if not all) routers will block external access (for security reasons), so you will probably need to tell your router to allow specific ports (and then forward those ports to the server). If your router does port forwarding based on (local) IP address (i.e. 192.168.x.x, 10.x.x.x, etc.) instead of MAC address, and your router does DHCP, you will probably want to give your server a static (local) IP address instead of a dynamic one assigned by your router's DHCP service (or set your router's DHCP service to always give the same computer (based on its MAC address) the same (local) IP). This is an option that you should be able to find on your router.


  1. There are a few methods I've used. I use SSH/SFTP/VNC from remote locations all the time, and I've found that my IP only changes when I restart my router, so I just update the DNS for my domain as necessary. What you can do, though, is use something like and create a free subdomain that updates the IP automatically with a nice little daemon on the server, or better yet, there are some routers that can do it without needing a computer (dynamic DNS).

    P.S. For version control, check out mercurial.

  2. Cool, thanks for sharing! Yeah, I was actually going to go through a similar route (installing OpenVPN and using DynDNS (because my router supports automatically updating dynamic IPs with DynDNS)), but I decided to give Hamachi a try and it actually made things really simple. But if it ever turns out to have a fatal limitation I run into I think I'll go back and try what you do.

    Mercurial sounds interesting, and I've looked into it, Git, SVN, Fossil (btw, I would love to use Fossil, if only it had Visual Studio integration), and others. I've decided to start with SVN because I can always convert a SVN repository to a Git/Mercurial/SomeOtherDVCS repository if I ever feel like I really want a decentralized system (and I very well may). I'm going to try this for a couple weeks, and if I hate it I'll look into Mercurial and Git. Thanks for the suggestion though!


Note: Only a member of this blog may post a comment.