0 - FreePBX - Setup Free Voip using Google Voice

Google Voice and FREEPBX version 3 beta 
======================================

NOTE: Firewall settings just need ALL OUTBOUND ALLOWED. it worked for me without messing with my firewall
This is my own guide on how to setup google voice and freepbx with an Xlite softphone which will have an extension and calls will be recorded. All those Programs are Free (Expect VMworkstation, so if you dont have it, just install freepbx on vmware player - although you cant autostart vms at windows logon with vmware player - or just run freepbx on a real computer hardware box).

Obivious Side note:
Note where  I put 10.11.12.33, thats just what I chose for my ip for my pbx server, Where I put 1234 thats just what I chose for my extension and where I put koss, well thats my name, change it to match whatever name you want.

This is ment more for a guide for me

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My network is 10.11.12.x
Instead of 192.168.1.x
So bare with me and use your brain to figure out the numbers for your network.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#### SECTION A ####
---presetup freepbx (i set it up on a vm but you could just as well set it up on a pc)----
1) download the freepbx beta 3 version distro
2) install the operating system as a vm (using vm workstation 9), make sure that vm(give the vm at least 8gbn harddrive and 512mb ram) auto loads when windows starts. Make a text file called. runfreepbxatstart.txt and rename it to runfreepbxatstart.bat and put it in your START-STARTUP folder so that this code below runs when windows starts, so put the code below in that file:
     @echo off
     chdir "C:\Program Files\VMware\VMware Workstation"
     vmrun start "C:\Users\koss\Documents\Virtual Machines\FreePBX-beta\FreePBX-beta.vmx"
     taskkill /IM vmware.exe
3) install it with default settings, when asks for network settings, leave it at default dhcp (you will set a root/admin password note it down)
     FREEPBX admin/root: password
4) once loads, log in to the command line screen with the given password, thats your run "ifconfig" to see the ip you will access the freepbx web server with ex: 10.11.12.115
5) with another pc go to browser and access 10.11.12.115, in "PBX Administrator"--(at this step you will be interupted like this parenthesis and prompted to make a main admin user aside from admin/root, remember its username and password)-->"admin"->"system admin"->"Network settings". Change the settings to be like so if your using a similar network subnet[which i doubt you are]:
IP address: 10.11.12.33
SUBNET MASK: 255.255.255.0
GATEWAY: 10.11.12.1
MAC ADDRESS: Blank (you will notice alot of fields in all of the freepbx/trixbox apps settings pages, keep in mind most of them can be kept blank)
Hit Submit or Apply (notice after you apply the settings, you might need to hit another apply button, I will not remind you everytime you need to click apply in these guides, but where ever I can I will, because that is just rediculus)

# SECTION B
---presetup google voice and google chat----
SIDE NOTE: My case was more complex, I dont use username@gmail.com, i have my own domain username@kossboss.com. However this still works with "google apps" just as it would with regural gmail. Note with my domain(Thru godaddy) I only have the MX record for email set to point to google <- but that is irrelevant to voice, if all else fails, make a gmail account. The only setting that all this has any affect on is when you add your google voice to the motif setting on freepbx. motif is the module that drives google voice. Instead of setting my username as "username@gmail.com" I set it as "username@kossboss.com". Thats all I wanted to mention in this side note, just incase you have your own domain with google apps and you werent sure how to tweak the settings to work for you, so now you know. Its just the username field in that one setting.

1) with you google account log into to gmail and go to settings and go to chat tab and change the following:
Auto-add suggested contacts:    
     Automatically allow people I communicate with often to chat with me and see when I'm online. <-- uncheck (this is the default option that we dont want)
     Only allow people that I've explicitly approved to chat with me and see when I'm online. <-- check
2) go to voice.google.com and log in with your google account. It will want to set a number to verify with, set your cell phone number, it will call your cell and verify with a 2 digit number that will be on the screen. Once verified you can then select a phone number of your liking based either on a keyword (like I picked KOSBOS and it found me a number like 555KOSBOS7) or on location (so if you select utah it will pick 435 or 801 or 385). For the purposes of this tutorial I will use the phone number 5553334444. Then the final thing which I will explain 3 times: (1) go to Google Voice Settings and make sure the Number forwards to CHAT instead of your PHONE.(2) Very important. Make sure your google voice number points to GOOGLE CHAT and not your PHONE NUMBER that you activated google voice with. (3) Again thats set through the voice.google.com and go to settings(gear icon) and in the Phones tab make sure the Forwards calls to setting is set to google chat and not your phone number.
- NOW YOU ARE SET ON THE GOOGLE SIDE OF THINGS

#### SECTION C ####
---back to freepbx---
0) Log in to the Freepbx using the browser so ip 10.11.12.33 and CLick PBX Administrator and Log in with the Username and PAssword you set up section A step 4 (the username that the PBX system made you create in the browser and not during setup of the Operating system)
SET UP THE MEAT OF IT (this auto sets up the trunk and all the crazy settings that make it work)
1) Go to "connectivity"->"Google Voice Motif" settings, and add
Google Voice Username: username@kossboss.com (again if you use username@gmail.com then put "username@gmail.com" and not just the username)
Google Voice Password: put your google account password
Google Voice Phone Number: 5553334444 (put the number that you picked with Google Voice, make sure you dont include dashes or the leading 1)
CHECK Edit Trunk
CHECL Outbound Routes
UNCHECK Send Unanswered to GoogleVoice Voicemail
Hit Submit

MAKE THE EXTENTION
2) go to "Applications"->"Extensions" Add a Generic SIP Device. Here there will be alot of confusing fields, most can be left blank here is what I set and make sure you remeber this ,as these will be set on the XLITE softphone in the future

extension: 1234
display name: KOSS
DEVICE OPTIONS: secret(THIS IS IMPORTANT AS THIS WILL AUTHENTICATE THE PHONES/SOFTPHONES, THIS NEEDS TO HAVE LOWERCASE LETTERS AND NUMBERS): pass1234
CHECK add to isymphony
UNDER ISYMPHONY PROFILE SETTING: create profile CHECK AND profile password OF YOUR CHOOSING IN THIS CASE I SELECTED pass1234 as well, SO AS NOT TO CAUSE CONFUSION

CONNECTIVITY - INBOUND ROUTES(note outbound routes are automade when we did the motif step in step 1)
3) "Connectivity"->"Inbound routes" THis will direct where a phone call will go because it can go to an IVR, a Directory, directly to an extension etc. In this case I will send it directly to the extension we made above
Description: route1
Call Recording: Allow
Set Destination: Extensions and select your extension <1234> KOSS
SIDE NOTE:  IF YOU SET THE DESTINATION TO DIRECTORY or PHONE BOOK, and submit you can then test if your setup works so far. At this point with another phone you should be able to call on your google voice number and reach some sort of directory, which of course wont work but you know that your freepbx routes correctly(inbound direction wise) and etc.

APPLICATION: for this guide, we are going to record all the conversation to extension 1234
4) "Applications"->"Record KOSS", hit add and set up the following:
Description "Record1234" Call Recording Mode: ALlow, Destination Extensions <1234> KOSS

iSYMPHONY:
5) "admin"->"iSymphony" Admin Username: admin <-- leave as default, Admin PAssword: pass1234 <-- or whatever you want, something that noone but you has access to. THe rest at default and hit submit, so the only setting I changed was the password.

SIDE NOTE:
This whole time the FREEPBX SYSTEM STATUS SCREEN ("reports->freepbx system status") gives me a warning "SYMLINK from modules failed" (/etc/asterisk/chan_dahdi.conf from dahdiconfig/etc (Already exists, not a link....) but EVERYTHING STILL WORKS. So some errors are okay to ignore.

#### SECTION D ####
---back to XLITE---
1) Download the latest XLITE
2) Softphone Menu-> Account Settings:
Account NAme: My PBX <-- left at default
Protocol: SIP <- left at default
USER DETAILS:
User ID: 1234 (the extension I used)
DOMAIN: 10.11.12.33 (the ip of the PBX server)
PASSWORd: pass1234 (The device password set at step 2 in SECTION C)
Display Name: KOSS(probably needs to match the step 2 settings)
Authorization name: 1234 (Matches USER ID from above just the extension)
OK
And now you should be able to call out from the softphone and call in
VOILA

THere are many more settings to mess around with, check out youtube videos on freepbx (and trixbox - trixbox is a similar to freepbx the interface even looks alike) and etc.

### FREEBEE: SECTION E ###
In this Setup Xlite Phone in another Remote Network
Note all of the above before this section was taking place in my home network. The Xlite Phone was on a windows PC and the FreePBX was on a Virtual Machine (also running on the Windows PC but thats irrelevent)
Surprisingly The call quality was Amazing. This requires some port forwards (and port triggers if you want to be safe).

--FREEPBX--
Setup Another Extension For WORK Phone Using Instructions from above.  For testing purposes Just change the Inbound Route to point to this extension for now. After you need to Change the Inbound Route to point to an IVR or a Phone Book so you can access both Extensions.

--ROUTER AT HOME NETWORK WHERE FREEPBX IS---
Every router is different for this and not all routers support port triggering (this NETGEAR WNDR3400v2 home router does and works great with this)
* Port Forward: Port 5060 UDP --> LAN IP of FREEPBX port 5060 UDP 
* Port Trigger: 5060 UDP --(opens)--> 10000 UDP to 20000 UDP to LAN IP of FREEPBX
(or if you cannot do Port Triggering then Port Forward 10000 UDP to 20000 UDP to the same ports of your FREEPBXs LAN IP)
* No need for Router Setup At Work/Remote Network: Note at Remote Network You just need to have all outbound allowed - Im behind a couple "NAT"s and it still works wonderfully

--XLITE ON WINDOWS PC AT WORK--
1) Download the latest XLITE
2) Softphone Menu-> Account Settings:
Account NAme: My PBX <-- left at default
Protocol: SIP <- left at default
USER DETAILS:
User ID: 4321 (the extension I used for WORK)
DOMAIN: www.kossbosshouse.com (You can use the Public/WAN Ip of your Router - This uses UDP 5060 to talk to the FREEPBX)
PASSWORD: pass1234 (The device password set at step 2 in SECTION C)
Display Name: Work (probably needs to match the step 2 , extension, settings in SECTION C)
Authorization name: 4321 (Matches USER ID from above just the extension, equal to extension number)
Comments