I recently wrote about using virtual machines to host your own GitLab instance. In that post, I suggested setting a static IP address for your virtual machines so they are accessible through a fixed address. Unfortunately, issues with networking and allowing the VMs to access the outside internet forced me to look for an alternate solution. Recently, I discovered a better way of accessing these VMs that also gives them internet access and a static IP address– through a VPN using Hamachi.
Using Hamachi to Access Your VM
Personally, I used Hamachi over other VPN software. They have various binary distributions for RPM and DEB based flavors of Linux, as well as compiled ARM distributions (in case you want to try and run GitLab on your Raspberry Pi or something, which isn’t a bad idea)
Once you’ve registered a free account (which allows you to have up to 5 clients in a network, or 32 for $29 /yr), create a new network.
A mesh network works the best here for minimal configuration. If you choose to use a hub-and-spoke network, you’ll just have to make all of your servers the “hubs” and your client machines “spokes” for access between the machines to work properly.
Create the network without a password and require approval from the web portal. You can change this if you want and require a password, but it isn’t necessary as approval is required by yourself in the web portal.
You can install the Hamachi client on your Mac, Windows, or Linux computer. This will allow your development machine to access the servers, which we’ll setup in a minute.
Setting up Hamachi on the Servers
I have two servers in virtual machines– a GitLab instance and a Jenkins CI server for building my projects. The process for setting up Hamachi on either of these servers is the same.
First, go to the experimental build page for LogMein Hamachi. Half way down the page you should see the section titled “LogMeIn Hamachi for Linux (Beta).” Obviously, this is a command line client for adding your servers to Hamachi networks.
Make a note of the URL for the proper file. If you followed my other guide and used Ubuntu 12.04 LTS 64 bit, you will want the “logmein-hamachi-184.108.40.206-1_amd64.deb” file.
Download and install the DEB using the following, replacing the URL with the appropriate version of Hamachi, or use the appropriate commands for your RPM based Linux distro.
cd /tmp curl https://secure.logmein.com/labs/logmein-hamachi_220.127.116.11-1_amd64.deb -o hamachi.deb sudo dpkg -i hamachi.deb sudo apt-get install -f
Essentially, the commands above download the DEB to your
/tmp directory and install it using
dpkg. We also use the
apt-get install -f to install all the dependencies of Hamachi.
Once this is done, you can use Hamachi through
sudo hamachi. Typing this command will show you the current status of Hamachi, including the LogMeIn account attached, client ID, and other information.
To attach the client to your LogMeIn account, perform the following commands in your terminal.
sudo hamachi login sudo hamachi attach [YOUR LOGMEIN EMAIL ADDRESS]
This will attach the client to your LogMeIn account after you approve on the web client. To approve the attachment, go to the LogMeIn website on your Mac or PC (not the Linux server). At the top of your client list should be a link that indicates a machine is awaiting your approval to be attached to your account. Approve the attachment and add the computer to your network that you created earlier.
Once this is done, on your Mac or PC, navigate to the IP address listed in the Hamachi control panel for your GitLab instance. You should see the login screen if everything went smoothly.
Reconfiguring GitLab for the New IP Address
Because the GitLab instance’s IP address is now 25.x.x.x instead of the previous 192.x.x.x or 10.x.x.x, you’ll need to edit the configuration file to reflect this.
SSH into your GitLab server and perform the following commands.
sudo su gitlab cd ~/gitlab/config/ vi gitlab.yml
If you don’t want to use
vi, you can use
nano or whatever editor you wish. In the
gitlab.yml file, find the
ssh_host: fields. Change the values for both of these to the IP address of the GitLab instance.
Save the file (
vi) and reboot the server, and you should be able to use GitLab as before. As a bonus, this will even work between any new machines you add to the VPN.