Start Hamachi as a System Service
***Update*** – Just made a new blog post about the current situation with Hamachi’s Linux Support. I highly suggest reading this here instead of messing with LogMeIn’s disregard for Linux support.
Now that we’ve been able to get Hamachi installed. We are ready to create a startup script to allow it to start automatically when the computer boots. You may have noticed that during the installation process we ran the ‘hamachi‘ command with ‘-c /etc/hamachi’ . This was simply to force Hamachi to place the configuration files into a directory of our choice. Otherwise it would have placed them in a hidden directory in the home directory of the user who installed and configured Hamachi.
- To begin we must create an new file
- Open the newly created file.
- Insert the following script into the ‘hamachi’ file via copy and paste.
- Save and exit nano (Ctrl-O to save, Ctrl-X to exit). Now set the ‘hamachi’ file as executable.
- Add the ‘hamachi’ script to the defaults startup process
$ sudo touch /etc/init.d/hamachi
$ sudo nano /etc/init.d/hamachi
#!/bin/sh
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$ sudo chmod +x /etc/init.d/hamachi
$ sudo update-rc.d hamachi defaultsExpected output
update-rc.d: warning: /etc/init.d/hamachi missing LSB information update-rc.d: see Adding system startup for /etc/init.d/hamachi ... /etc/rc0.d/K20hamachi -> ../init.d/hamachi /etc/rc1.d/K20hamachi -> ../init.d/hamachi /etc/rc6.d/K20hamachi -> ../init.d/hamachi /etc/rc2.d/S20hamachi -> ../init.d/hamachi /etc/rc3.d/S20hamachi -> ../init.d/hamachi /etc/rc4.d/S20hamachi -> ../init.d/hamachi /etc/rc5.d/S20hamachi -> ../init.d/hamachi
That should complete the process. Now when you reboot your computer it will now start Hamachi automatically as the root user. Remember that if you do wish to manually run any of the Hamachi commands, you must run them with the ‘-c /etc/hamachi’ prefix. Otherwise it will not be looking in the right place for the configuration data. Below is good example and a bad example.
- Good…
- Bad…
$ sudo hamachi -c /etc/hamachi start
$ sudo hamachi start





















26 Comments
hello im new in linux so i need help in this >>> when i want to start doing this guide then i fail in 1. task ‘ $ sudo modprobe tun ‘
when i write it then nothing happens so please help me how to continue :)
thanks
Tomas