Not Logged in - No Account?

Don't have an account? Registering an account with us allows you to post to the forums, easily track new posts, subscribe to threads, pm (private message) other forum members, and receive periodic news letters (you can opt out if you desire). Once you are logged in this message will no longer appear. If you don't have an account, you can create one by registering here. Lost your password, request a new password. We respect your privacy which means we collect minimal information when you register and we do not resell that information or use it in any objectionable way. You can review our privacy policy for full details.


How to add Hamachi Moderated VPN for remote administration/softphone access

in

Basically, what this howto is intended to do is to teach you how to get hamachi to run as a service.

Why would you want to run Hamachi? Once installed on your CentOS 4.5/5.X system and installed on a workstation (perhaps a laptop) you can access your server remotely via VPN for http or ssh administrative tasks. You can also use the private network to connect softphones and even set up DUNDi trunking over this VPN.

For client installation see this link.

 

Installing hamachi as a linux system service is quite simple. You first follow the regular steps of installation of hamachi.

  • Download the file from http://files.hamachi.cc/linux/hamach...-20-lnx.tar.gz and then execute the following command (see http://files.hamachi.cc/linux/ for other options):

    Code:
    # tar -zxvf hamachi-0.9.9.9-20-lnx.tar.gz

    (Note: You do not have to do these next 3 commands, it's just a good idea to keep your hard drive organized)

    Code:
    # mkdir /usr/src/hamachi
    # mv hamachi-0.9.9.9-20-lnx /usr/src/hamachi
    # cd /usr/src/hamachi/hamachi-0.9.9.9-20-lnx

    Once done with this, you need to do your standard hamachi installation command:

    Code:
    # make install

    Once installed, you need to first run the program "tuncfg". (Note: tuncfg is a program which makes the hamachi network adapter and must always be running while hamachi is running in order for hamachi to work)

    Code:
    # tuncfg

Now to get hamachi running as a system service and make your setup scripts:

First and foremost, you need to put your hamachi
configurations in a global directory as opposed to your home directory.
hamachi-init creates scripts in your home directory in a folder called
.hamachi by default, but we are going to specify the configuration
directory of /etc/hamachi. (note also that hamachi itself can be run under a non-privileged user. tuncfg, however, needs to be run as root).

Code:
# hamachi-init -f -c /etc/hamachi
# hamachi -c /etc/hamachi start
# hamachi -c /etc/hamachi login
# hamachi -c /etc/hamachi create network password

NOTE: Start thinking about how telephony might use a VPN when naming.

Next:

# hamachi -c /etc/hamachi set-nick nickname
# hamachi -c /etc/hamachi go-online network

Once done with this, we will need to make a hamachi runtime script.

Use your favorite text editor to make a file called hamachi-start.

Code:
# nano /usr/bin/hamachi-start

This file will be a shell script. For those who aren't well versed in
linux, just copy exactly what I tell you to and it should work
perfectly fine. If you feel like modifying it any, feel free -- it will
still work. The most important thing is, start tuncfg, then start hamachi.

Here is the contents of hamachi-start:

Code:

#!/bin/sh

hamachi_start() {
echo "Starting hamachi..."
/sbin/tuncfg
/usr/bin/hamachi -c /etc/hamachi start
}

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

Not done yet, now you need to chmod it to give it executable permissions:

Code:
# chmod a+x /usr/bin/hamachi-start

To add Hamachi as a startup item you manually edit /etc/rc.local -- be sure to back this up before poking around in there though.

Code:
# cp /etc/rc.local ~/rc.local.bak

Then edit it (Again, use your favorite text editor instead of nano. If nano doesn't work, you can always try pico)

Code:
# nano /etc/rc.local

At the very bottom of this file, add the following lines:

Code:

if [ -x /usr/bin/hamachi-start ]; then
. /usr/bin/hamachi-start
fi

Crtl-x and Crtl-y then press enter and viola! You have Hamachi as a service when you restart.

SOME ADDITIONAL NOTES:

I found the easiest way to manage a Hamachi
network is to use the free Windows version (Better still to purchase a
full version) and create all networks from that workstation.

We want to use a global configuration file... So, you need to always
specify the file's location. Therefore, instead of "hamachi join
network password" and so on, the commands will look like this:

Code:
# hamachi -c /etc/hamachi set-nick nickname
# hamachi -c /etc/hamachi login
# hamachi -c /etc/hamachi create network password
# hamachi -c /etc/hamachi join network password
# hamachi -c /etc/hamachi go-online network
# hamachi -c /etc/hamachi list
# hamachi -c /etc/hamachi go-offline my-net


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

setting up hamachi

etech3's picture

super!!!!!

worked first time

I have been using hamachi for years and had installed it on my debian servers and windoze "servers"but i had not gotten to the freepbx server.


Glad to hear another Hamachi success

cosmicwombat's picture

You can use it with DUNDi too.