Posts Tagged ‘Asterisk’

Google Voice + Asterisk + SipGate DID = Free USA VOIP Service

August 8th, 2009 No comments

This detailed, newbie friendly tutorial was originally written by MrMuffin from forum. So full credit goes to MrMuffin. However, I made several minor changes that I found necessary for my setup to work.

[Some Basic Terminology]

  • PBX

    PBX is short for Private Brach Exchange. It is a private telephone network commonly used in businesses. It is what lets them have extensions, voicemail, features such as call forwarding, call transfer, conference calling, etc. It manages the entire phone system.

  • Asterisk, FreePBX, PBX in a Flash

    Asterisk is a free, open source, software PBX. You install it in Linux. It is not very user friendly as it uses text files for all of its configuration.

    FreePBX is Asterisk but bundled with a nice web user interface for managing it. It is much more user friendly. This can be installing in a Linux installation.

    PBX in a Flash (PiaF) is actually an entire Linux installation. It installs Linux for you first, then FreePBX inside of that. It is the easiest method and what I will use for this tutorial.

  • VMWare

    VMWare Server is a piece of free software that lets you run a virtual machine (VM) within a computer. For our purposes, it will let us run Linux (and FreePBX) inside of Windows.

    This tutorial uses VMWare Server for Windows. If you do not want to use VMWare and wish to install PBX in a Flash on its own computer, please skip all the VMWare steps.

[Getting and Installing VMWare Server]

  1. Go to
  2. VMWare Server is free, but they require you to register to get a product key and to download. Register and download the software for Windows, which is a 507mb exe file. Make sure you save your product key somewhere safe.
  3. Once the file is done downloading, run it and install VMWare Server with all default options.
  4. Put in your product key at the end of the install, then reboot your PC!

[Getting and Installing PBX in a Flash]

  1. Download
  2. Move the above file into C:\Virtual Machines\. This directory should have been created by VMWare Server when it was installed.
  3. Download and extract this zip file to the same directory as above:
  4. Open Firefox and go to
  5. You should be able to log in with any Windows user/password combination. If you do not have a password set on your Windows account I do not know if it will take blank passwords. Set a password on your Windows account and try to login here again.
  6. This is the VMWare Server web interface. On the toolbar at the top click “Virtual Machine->Add Virtual Machine to Inventory” In the “Inventory” column click on “standard”. Now in the “contents” column you should see “PBX-in-a-Flash.vmx”. Click on this and click “OK” at the bottom.
  7. On the right side there should be a little box called “Commands”. You should see “Edit Virtual Machine Startup/Shutdown” in blue. Click on this. In this new box that opened, check “Allow virtual machines to start and stop automatically with the system”. At the bottom click on “PBX-in-a-Flash” so that the entire row turns blue. On the right click on “Move Up”. The entire row should move up so that it is under the “Any Order” section. Click “OK”.
  8. Find the “Console” tab in the middle and click on it. You will get a message about the VMWare remote console plugin not being installed. Click “Install Plug-In” in orange. A bar will appear in Firefox at the top saying “Firefox prevented this site…blah blah”. Click on the “Allow” button. Click “Install”. Restart Firefox when prompted. You may or may not have to log back into VMWare’s web interace. Once you are back at the Console there should be a large white triangle in the center of it.
  9. Click the triangle to power on the virtual machine. Click the console a second time to open the virtual machine’s video in a new window. The virtual machine will automatically boot from the CD. You may have to click inside of this window to be able to type. To release your mouse and keyboard from this window hold CTRL+ALT. Again, click in the window to type, CTRL+ALT to release.
  10. At the prompt type “ksalt” and press enter. “US” is selected as the default on the next page, tab over and hit enter on “OK”. Select your timezone and tab over and press enter on “OK”. Enter a password twice here. DO NOT FORGET IT. Tab to “OK”.
  11. Pizza break while this installs.

[FreePBX Installation]

  1. When the setup is complete, linux (CentOS 5) will boot for the first time. After it boots you will be presented with options A, B, C and Q. Press “A” on your keyboard. This will initial the download and installation of FreePBX inside of your new linux virtual machine. Time for some more pizza, this takes a while too.
  2. Once this completes, the system will reboot and you will be presented with a pbx login. Put in “root” as the login and the password you entered twice during setup.
  3. Once logged in, type “update-scripts” and press enter. Read what this next screen says and press enter. Same thing on the next screen. On the third screen read what it says and press “Y”. Once this completes you will see a message that says “You really need to run update-fixes NOW!”. If you do not get this message something went wrong so just run “update-scripts” again and follow the directions.
  4. Now type “update-fixes” and press enter. Read what this says and press “Y”. Now just wait and the next screen will continue automatically. After this completes it prompts you for a password. Put in the same as your root password and press enter. Do it again and press enter. Press “N” when asked about the log file.
  5. Now at this point I highly recommend that you set up the linux installation with a static ip. It will make things easier. If have no idea what a static ip is, then perform step 5a). If you want to configure a static ip, go to step 5b).

    a) Type “ifconfig” and press enter. You will get a bunch of confusing information. Find “eth0” in the top left corner. Look on the second line beneath that and find “inet addr:”. Write down IP address after the colon. It will be 4 numbers seperated by periods. Continue to step 6.

    b) Type “netconfig” and press enter. Press enter on “yes”. Tab down to the IP address field and put in the static ip you want to assign. Tab down through all the fields and put in your specific information. I cannot help you with this as it is specific to each network. Tab to “OK” and press enter when done. Back at the command prompt type “service network restart”. This applies the new static ip.

  6. Open a new tab in Firefox and browse to http://ip.of.pbx/admin <--insert either the number from the last step. Either from ifconfig or whatever you configured as a static ip. The user/password is maint/password, respectively. This brings up the FreePBX configuration page. This is the easy part!

[SipGate Signup]

  1. Open a new tab in Firefox. Go to Click “Sign Up” on the toolbar. Select “I am a residential user”. Fill out the form and click the “Sign up now” button at the bottom.
  2. Check your email and click on the link from SipGate. This page will generate a phone number for you, probably with area code 415. Get a sheet of paper and write the following at the top: “SipGate Info”. Underneath that write “SipGate Phone #” and next to that put the 415 number you were just given. Click “Proceed with the selected number”, then “Proceed with the next step”, then “Skip this step”, then lastly “Proceed to account”. You will be at a very email-like inbox.
  3. Click “Settings” in the top right corner. You will be taken to a page that has a small picture of a phone and underneath it says “Phone of ” Place your mouse on this phone image and on the menu that appears, click “SIP Credentials”. Get your “SipGate info” paper and write down the SIP-ID and the SIP-Password, we will need them later.
  4. You can totally close the SipGate site now, so just close this tab and return to the FreePBX webmin.

[FreePBX Configuration]

  1. On the left toolbar click “Module Admin”. Now click “Check for updates Online”. Now click “Upgrade All” and then “Process”. Click “Confirm” on this page. An orange box pops up and it starts updating the modules. Scroll down inside of this orange box and click on “Return” when it appears. You will be returned to Module Administration where you need to click on “Check for updates online” again. Click on “Download All” and then “Process”. Click “confirm” on this page again, the orange box re-appears and performs the install. Scrolls to the bottom of the orange box and click “Return” when it appears.
  2. At the top of the page you will see “Apply Configuration Changes” with an orange background. Click this and choose “continue with reload”. We will have to do this often, so know to perform these steps when I say to “reload configuration”.
  3. On the left toolbar, near the bottom click on “Parking Lot”.
    * Check “Enable Parking Lot”.
    * Change the “Number of Slots” to 5.
    * Change the “timeout” to 30.
    * Click the radio button for “Terminate Call”. Make sure it says “Busy” in the dropdown.
    * Leave everything else at defaults and click “Submit Changes”.
    * Reload.
  4. At the top of the left toolbar click “Tools”. Click on “Custom Destinations”.
    * For “Custom Destination” enter “custom-park,s,1”.
    * For “Description” enter “Custom GV-Park”.
    * Click “Submit Changes”.
    * Reload.
  5. At the top of the left toolbar click “Setup”. Click “Extensions”.
    * Leave as “Generic SIP Device” and click “Submit”.
    * For “User Extension” enter “221”.
    * For “Display Name” enter “Home”.
    * For “secret” put in a simple password and remember it for later.
    * Leave everything else as default and click “Submit”.
    * Reload.
  6. Click “Trunks” on the left toolbar. There is probably a link on the right that says “Trunk ZAP/g0”. Click this and delete it. You return to “Add a trunk”. Click “Add Custom Trunk”.
    * For “Outbound Caller ID” enter your google voice number.
    * For “Custom Dial String” enter “local/$OUTNUM$@custom-gv”.
    * Click “Submit Changes”.
    * Reload.
  7. You should be back at “Add a Trunk”. Click “Add SIP Trunk”.
    * For “Outbound Caller ID” enter your google voice number again.
    * For “Trunk Name” enter “SipGate Truck”.
    * In the large “PEER Details” area paste the following, but we will have to modify it to suit you:

    * Get out the “SipGate Info” sheet of paper I had you write all that info on. Change “username” and “fromuser” to the “SIP-ID”. It will be in the same format, 7 numbers followed by e0. Change “secret” to the “SIP-Password” you wrote down. It will also be 6 characters, numbers and letters.

    * In the large “USER Details” area paste the following. Again, change “fromuser” and “secret” to your “SIP-ID” and “SIP-Password”.


    * For “Register String” enter:

    * Modify this with the details from your “SIP Info” paper. The format is “”.

    Click “Submit Changes” and reload.

  8. Click “Outbound Routes” on the left toolbar. There is probably a link on the right that says “0 9_outside”. Click this and delete it. You return to the Add Route page.
    * Name this route “GoogleVoice”.
    * For “Dial Pattern” enter “NXXNXXXXXX”.
    * For “Trunk Sequence” select from the first dropdown “local/$OUTNUM$@custom-gv”.
    * Click “Submit Changes”.
    * Reload.
  9. Click “Inbound Routes” on the left toolbar. It will bring up a page to add an incoming route:
    * Description: GV-Ringback.
    * DID Number: gv-incoming.
    * Caller ID Number: BLANK.
    * Scroll to the bottom and click the radio button next to “Extensions” and make sure “<221> Home” is selected in the dropdown.
    * Click “Submit”.
    * Reload.
  10. On the top right click “Add Incoming Route”. This is the same step as #7 but with different settings:
    * Description: Regular Incoming Calls.
    * DID Number: BLANK.
    * Caller ID Number: BLANK.
    * Scroll to the bottom and click the radio button next to “Custom Destinations” and make sure “Custom GV-Park” is selected in the dropdown.
    * Click “Submit”.
    * Reload.

[Installing Google Voice Script]

  1. You should have the VMWare PBX-in-a-Flash remote console still running. Bring it up. The screen may be black, so just click on it then press escape. If you no longer have it up, go back in the tutorial and find the instructions for logging into the VMWare Server web interface and bringing up the remote console then continue here.
  2. Enter the following commands, one by one, each line followed by the enter key
    cd ~
    chmod +x install-gv-new

    Answer the questions about your google voice.
    The last two questions are confusing:

    “11 digit ringback DID”. This is your SipGate phone number, so enter the entire 10 digit number, with a 1 at the front. Example: 14157286154.

    “Parking Lot Magic Number” is “75”.

    After you have entered all the info press enter to continue with the installation.

  3. Once installation is complete type in this command followed by enter:
    /var/lib/asterisk/bin/module_admin reload

[ATA Configuration]

Access the configuration for your particular ATA. Here are some generic settings:

Port: 5060
Proxy: <ip-of-linux-vm> (either static or the one you wrote down)
User: 221
Pass: <somepass> (this was the "secret" you entered when creating extension 221)
Use AuthID: yes
AuthID: 221

This is all I had to enter on my Linksys PAP2-NA to get it to connect to asterisk as extension 221.

You should now be able to call the SipGate 415 number from any phone and asterisk should ring your ATA and any phone connected to it. If you go to and add the 415 and enable forwarding to it, all calls to your GV # will ring through to your ATA. Make sure to disable Call Screening and Call Presentation in the GV settings. Also make sure Caller ID is set to “Display caller’s number”.

That’s it. Enjoy.