Hamachi on Gentoo

 Linux Guides  Comments Off
Sep 272010
 

Introduction

Hamachi is a lightweight personal VPN connector that is a breeze to setup but there can be some pain if you don’t know what to expect. As always Gentoo provides us with an ebuild that simplifies the installation process but getting up and running is still a little confusing.

Installation and Setup

User Specific Configurations

The obvious first step is `emerge -av hamachi` (this only available to ~arch right now so add to `package.keywords` as necessary). The following are the typical instructions to install hamachi on Gentoo from portage:

  1. Add to `packages.keywords` if necessary
  2. `emerge -av hamachi`
  3. `rc-update add tuncfg default`

After these steps have been taken you can run hamachi as any user on the system for ad-hoc VPN creation.

Server Wide Configuration

If you prefer to do a system wide on boot VPN with hamachi this is also possible but requires a slightly different setup:

  1. Add to `packages.keywords` if necessary
  2. `emerge -av hamachi`
  3. rc-update add hamachi default

Now all configuration should be placed inside `/etc/hamachi` for this setup so the system will automatically start routing traffic correctly.

Kernel Configuration

For hamachi to work correctly you do need the tun parameter in your kernel or loaded as a module. This parameter is located in Device Drivers->Network device support->Universal TUN/TAP device driver support.

Using Hamachi

Now that hamachi is on the system we need to start using it. The server-wide installation doesn’t require this (but I’m sure you can use this method to create a configuration usable by the server-wide instance) but the user specific usage does.

Starting hamachi is as simple as the following:

  1. `hamachi-init`
  2. `hamachi start`
  3. `hamachi login`
  4. `hamachi create [ ]`
  5. `hamachi join [ ]`
  6. `hamachi go-online `

That’s it. You’re now connected to a private network named . You can view who else is connected to your network with `hamachi list` and `hamachi get-nicks`.

Conclusion

Setting up a VPN can be daunting (see the OpenVPN configuration documentation) or it can be a breeze with hamachi. Need a quick VPN for LAN gaming or a VPN for performing maintenance over the internet on a device behind a firewall? Hamachi may be the quick solution you’re looking for.

 

Installing VPNC

VPNC is found in many of the distributions’ package managements systems.  So before scouring after the source, try searching your package repositories.  If downloading the source is inevitable, the install is quite simple:

  1. `$make && su -c “make install”` or `$make && sudo make install` (for sudoers).
  2. Be sure the tun/tap device driver is built into your kernel (vpnc will tell you if it isn’t when you first run vpnc).

Configuring VPNC

Edit the configuration file:

#Interface name tun0
IPSec gateway 199.17.118.250
IPSec ID wireless
IPSec secret XXXXXXXXXXXXXXX
Xauth username (Your DragonMail UserName)
[Xauth password (Your DragonMail Password)]

Only use the password line if you don’t want to have to type your password every time.  Please, e-mail your name and dragonID to Alex Brandt to get the password that goes in the `IPSec secret` line  (Thanks to Conor Shenk for getting the password decrypted).

If you decide to include your password in the configuration file, then take the necessary precautions (e.g. `chmod 600 /etc/vpnc.conf`).

Checking Functionality

Now with everything properly configured and installed,  all you need to do is (as root for now) run `vpnc`.   If it works, congratulations, continue reading to learn how to customize it so certain users can run vpnc without becoming root. If it did not work try going through the steps again and experiment a little.  The first place you should check is the vpnc homepage.

Adding Convenience

Autostarting VPNC

If you want vpnc to start every time you start your computer, put it in your `rc.local` file.  This is located in different places based on the distribution you are running; so, please, consult the documentation for your distribution if you don’t know where it is. You will also want to add `vpnc-disconnect` to your shutdown scripts (this isn’t required, but is good practice).

Unprivileged VPNC with Sudo

If you want to allow a user to connect to the network, but not use a startup script; I recommend installing sudo to handle the security.  Using the `visudo` editor (I know how much some people like vim, but there is a tutor available by running `vimtutor`).  Now, just add this line to your sudoers file (using our handy visudo):

username    hostname    =   NOPASSWD:/usr/bin/vpnc,/usr/bin/vpnc-disconnect

Now, your specified user can start the vpn client with the following statement: `sudo vpnc`, and stop it with `sudo vpnc-disconnect`.

Aliasing VPNC

Using aliases can make your life even easier. The user can add the following lines to his `~/.bashrc` file to simplify commands requiring the school’s network.

alias vpnc="sudo vpnc"
alias vpnc-disconnect="sudo vpnc-disconnect"
alias program="sudo vpnc && program && sudo vpnc-disconnect"

This last one is invaluable if you need to log into the network for a specific program’s license or whatnot, but use your imagination and you can make your computing experience as easy as you like.

© 2011 Alunduil's Hosting Suffusion theme by Sayontan Sinha