I used this tutorial as a beginning to install hamachi as a system service:
http://ubuntuforums.org/showthread.php?t=135036
The very first part of the Hamachi installation is to enable IP Tunnelling support in your kernel. This can be done like this:
sudo modprobe tun
then open your /etc/modules file and add tun to the list of modules:
sudo gedit /etc/modules
If you are using a standard Ubuntu kernel, this should be all you need to do. However, if you compiled your own kernel, you made need to recompile it with IP Tunnelling support (only if you recieve an erro with 'modprobe'). If anyone needs help installing the module, see HOWTO: Hamachi Linux Guide (2.4.x and 2.6.x) By Kamel
Okay, now on to the actual Hamachi software. But first, we need to make sure that a valid tunnelling node has been created in /dev. This is done like this:
ls /dev/net/tun
If you get a "No Such File or Directory" error, you need to create a new node like this:
sudo mkdir /dev/net sudo mknod /dev/net/tun c 10 200
Okay, now that we have a valid IP Tunnel node, time to install Hamachi.
Download the latest version of Hamachi from http://www.hamachi.cc/download. (direct download here: http://files.hamachi.cc/linux/.)
Enter the directory where you downloaded it and here is how to install it:
#Extract the archive tar -zxvf hamachi-0.9.9.9-x.tar.gz cd hamachi-0.9.9.9-x/ #install Hamachi sudo make install sudo tuncfg #Hamachi is installed
For security sake, we are going to set the permissions of Hamachi so that it can only be started by members of the 'hamachi' group. This is done like so:
#Create the 'hamachi' group sudo groupadd hamachi #Add your user to the group sudo gpasswd -a user hamachi #Add root to the group sudo gpasswd -a root hamachi #Set socket permissions sudo chmod 760 /var/run/tuncfg.sock #Finally, changing the group of the file sudo chgrp hamachi /var/run/tuncfg.sock
As of Ubuntu 9.10, the hamachi file no longer executed properly without immediately returning "Killed", with an accompanying crash report. To fix this, I followed this hint at http://ubuntuforums.org/archive/index.php/t-1241784.html:
sudo apt-get install upx-ucl cd /usr/bin sudo upx -d hamachi
Now that permissions are done, on to configuration.
Follow this section if you want Hamachi to run as a system service (in the background). I chose to list this method of configuration first because it seemed most relivant to the guide. If you want to have Hamachi run as a user application and install the gtk frontend, skip to section 'E'.
Creating an initial configuration can be done like so:
sudo hamachi-init -c /etc/hamachi
Initializing Hamachi configuration (/etc/hamachi). Please wait .. generating 2048-bit RSA keypair .. ok making /etc/hamachi directory .. ok saving /etc/hamachi/client.pub .. ok saving /etc/hamachi/client.pri .. ok saving /etc/hamachi/state .. ok Authentication information has been created. Hamachi can now be started with 'hamachi start' command and then brought online with 'hamachi login'.
Okay, next is to start Hamachi:
sudo hamachi -c /etc/hamachi start
Now that we are up and running, you need to set your nickname:
sudo hamachi -c /etc/hamachi set-nick "YourNickHere"
Next, we need to login to Hamachi and then either login to an existing network or create a new one. Like this:
#Login to Hamachi sudo hamachi -c /etc/hamachi login #To join an existing network sudo hamachi -c /etc/hamachi join network password #Or to create a new network sudo hamachi -c /etc/hamachi create network password #Lastly, to go online to the network you joined sudo hamachi -c /etc/hamachi go-online network
*NOTE ABOUT NETWORK PASSWORDS*
I would recommend visiting http://grc.com/passwords for a random string password. They are very strong passwords and adds to the security of your setup.
Now your machine is up and running on it's own Hamachi VPN. The last part of the installation is a script written by Kamel that will allow Hamachi to run on startup.
Open gedit and save the following as /etc/init.d/hamachi
#!/bin/sh
### BEGIN INIT INFO
# Provides: hamachi
# Required-Start: $remote_fs $syslog $network
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start hamachi at boot time
# Description: Starts up hamachi daemon. Networking is required.
### END INIT INFO
hamachi_start() {
echo "Starting hamachi..."
/sbin/tuncfg
/usr/bin/hamachi -c /etc/hamachi start
/bin/chmod 760 /var/run/tuncfg.sock
/bin/chgrp hamachi /var/run/tuncfg.sock
}
hamachi_stop() {
echo "Stopping hamachi..."
killall tuncfg
/usr/bin/hamachi -c /etc/hamachi stop
}
hamachi_restart() {
hamachi_stop
sleep 1
hamachi_start
}
case "$1" in
'start')
hamachi_start
;;
'stop')
hamachi_stop
;;
'restart')
hamachi_restart
;;
*)
hamachi_start
esac
Lastly, you need to make the script executable and add it to startup:
sudo chmod +x /etc/init.d/hamachi sudo update-rc.d hamachi defaults
Follow this section if you want Hamachi to run as a user application and to use the pretty gtk frontend. If you want to have Hamachi run as a system service in the background, go back to section 'D'.
Creating an initial configuration can be done like so:
hamachi-init
Initializing Hamachi configuration (/home/user/.hamachi). Please wait .. generating 2048-bit RSA keypair .. ok making (/home/user/.hamachi directory .. ok saving (/home/user/.hamachi/client.pub .. ok saving (/home/user/.hamachi/client.pri .. ok saving (/home/user/.hamachi/state .. ok Authentication information has been created. Hamachi can now be started with 'hamachi start' command and then brought online with 'hamachi login'.
Okay, next is to start Hamachi:
hamachi start
Now that we are up and running, you need to set your nickname:
hamachi set-nick "YourNickHere"
Next, we need to login to Hamachi and then either login to an existing network or create a new one. Like this:
#Login to Hamachi hamachi login #To join an existing network hamachi join network password #Or to create a new network hamachi create network password #Lastly, to go online to the network you joined hamachi go-online network
*NOTE ABOUT NETWORK PASSWORDS*
I would recommend visiting http://grc.com/passwords for a random string password. They are very strong passwords and adds to the security of your setup.
Now your machine is up and running on it's own Hamachi VPN. The last part of the installation is to install a GUI for Hamachi. Here is how that is done.
First, download hamachi-gui from sourceforge.
Second, simply install the hamachi-gui package.
sudo dpkg -i [downloaded file]
Start the GUI like this:
hamachi-gui
At first I could not ping the other members, and this fixed it:
http://ubuntuforums.org/archive/index.php/t-208692.html
To check if the problem is caused by invalid routing entry do this:
ifconfig
ham0 Link encap:Ethernet HWaddr 00:FF:CA:D0:F5:AA inet addr:5.23.68.35 Bcast:5.255.255.255 Mask:255.0.0.0 UP BROADCAST RUNNING MULTICAST MTU:1200 Metric:1 RX packets:100 errors:0 dropped:0 overruns:0 frame:0 TX packets:244 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:500 RX bytes:26780 (26.1 KB) TX bytes:21076 (20.5 KB)
The IP address of the ham0 interface is the IP of the gateway for all hamachi network bound connections. Check the routing table:
sudo route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
64.238.220.160 0.0.0.0 255.255.255.240 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 eth0
5.0.0.0 5.23.68.35 255.0.0.0 UG 0 0 0 ham0
0.0.0.0 64.238.220.161 0.0.0.0 UG 100 0 0 eth0
If in the Gateway column you don't see the IP of the ham0 interface, as it was the case with me, delete that line and create the correct routing entry for hamachi.
#delete invalid route: sudo route del -net 5.0.0.0 gw 0.0.0.0 netmask 255.0.0.0 dev ham0 #add new route: sudo route add -net 5.0.0.0 gw 5.23.68.35 netmask 255.0.0.0 dev ham0