Asterisk
Jump to navigation
Jump to search
Asterisk 1.8 Google Voice
/etc/apt/sources.list.d/asterisk.list
# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1EE8660B deb http://ppa.launchpad.net/dajhorn/pkg-voip/ubuntu lucid main deb-src http://ppa.launchpad.net/dajhorn/pkg-voip/ubuntu lucid main
/etc/asterisk/
gtalk.conf
[general] context=default ;bindaddr=192.168.0.100 ;externip=99.99.99.99 allowguest=yes [guest] disallow=all allow=ulaw context=asterisk
jabber.conf
[general] debug=no autoprune=no autoregister=yes [asterisk] type=client serverhost=talk.google.com username=username@gmail.com/gmail secret=password port=5222 usetls=yes usesasl=yes statusmessage="I am available" timeout=100
sip.conf
[general] context=default allowoverlap=no udpbindaddr=0.0.0.0 tcpenable=no tcpbindaddr=0.0.0.0 ;srvlookup=yes ;localnet=192.168.0.0/255.255.255.0 ;externaddr=99.99.99.99 [222] type=friend context=default username=222 secret=password host=dynamic canreinvite=no dtfmode=rfc2833 disallow=all allow=ulaw subscribecontext=default mailbox=222@internal nat=yes directmedia=no [333] type=friend context=default username=333 secret=password host=dynamic canreinvite=no dtfmode=rfc2833 disallow=all allow=ulaw subscribecontext=default mailbox=333@internal
extensions.conf
[general]
static=yes
writeprotect=no
clearglobalvars=no
[globals]
CONSOLE=Console/dsp
IAXINFO=guest
TRUNK=DAHDI/G2
TRUNKMSD=1
[default]
; INBOUND calls
exten => s,1,Answer() ; Pickup GV calling, pending pressing option #1 or #2
exten => s,n,Dial(SIP/222,23,D(:1)) ; When answered fire a #1 to GV only(:1)
exten => s,n,SendDTMF(2) ; Else fall through to tell GV to goto voicemail #2
; OUTBOUND calls
; Long Distance dialing 1+
exten => _1XXXXXXXXXX,1,dial(Gtalk/asterisk/+${EXTEN}@voice.google.com,,)
; Long Distance add +1
exten => _NXXNXXXXXX,1,dial(Gtalk/asterisk/+1${EXTEN}@voice.google.com,,)
; Local dialing
exten => _NXXXXXX,1,dial(Gtalk/asterisk/+1515${EXTEN}@voice.google.com,,)
exten => 222,1,Dial(SIP/222,,)
extensions_custom.conf
This is for utilizing FreePBX and still using google voicemail
[from-google]
exten => s,1,Answer()
;exten => s,n,Wait(2)
;exten => s,n,SendDTMF(1)
exten => s,n,Set(CALLERID(num)=${CUT(CALLERID(name),@,1)})
exten => s,n,Set(CALLERID(name)=${CUT(CALLERID(name),/,1)})
exten => s,n,Goto(from-trunk,15159781570,1)
exten => s,n,SendDTMF(2) ; Else fall through to tell GV to goto voicemail #2
;exten => s,h,Hangup
manager.d/admin.conf
[admin] secret = SuPeRsEcReTpAsSwOrD read = system,call,log,verbose,command,agent,config,read,write,originate write = system,call,log,verbose,command,agent,config,read,write,originate
SNMP
#!/usr/bin/perl -w
use strict;
use IO::Socket;
use Getopt::Long;
$|=1;
my $host = "localhost";
my $username = "admin";
my $password = "SuPeRsEcReTpAsSwOrD";
my (
$version, $response, $message, $line, $chan1, $chan2,
$verbose, $help, $command,
$warning, $critical,
%warnval, %critval,
%channels,
$sock,
$key,
$s,
$i,
);
my $stop = 0;
my $port = 5038;
my $exitcode = 0;
my $cause = "";
sub warning {
$s = shift;
$s =~ s/[\r\n]//g;
print "WARNING: $s\n" if ($verbose);
exit(1);
}
sub error {
$s = shift;
$s =~ s/[\r\n]//g;
print "ERROR: $s\n" if ($verbose);
exit(2);
}
sub unknown {
$s = shift;
$s =~ s/[\r\n]//g;
print "UNKNOWN: $s\n" if ($verbose);
exit(3);
}
sub syntax {
$s = shift;
unless ($s =~ m/Help:/) {
$s = "Error: (".$s.")" or $s = 'Unknown';
}
print "$s\n" unless ($help);
print "Syntax: $0 -h <host> -u <username> -p <password> [-cwv]\n";
print "* --username -u Username\n";
print "* --password -p Password\n";
print "* --host -h Host\n";
print " --port -P n Port (if not using $port)\n";
print " --chan1 -1 xxx Display channel xxx as 1.\n";
print " --chan2 -2 xxx Display channel xxx as 2.\n";
print " --verbose -v Verbose\n";
print " --help -H This help\n";
exit(3);
}
Getopt::Long::Configure('bundling');
GetOptions
("p=s" => \$password, "password=s" => \$password,
"u=s" => \$username, "username=s" => \$username,
"h=s" => \$host, "host=s" => \$host,
"P=s" => \$port, "port=s" => \$port,
"H" => \$help, "help" => \$help,
"v" => \$verbose, "verbose" => \$verbose,
"chan1=s" => \$chan1, "1=s" => \$chan1,
"chan2=s" => \$chan2, "2=s" => \$chan2);
syntax("Help:") if ($help);
syntax("Missing username") unless (defined($username));
syntax("Missing password") unless (defined($password));
syntax("Missing host") unless (defined($host));
syntax("Missing channels") if (!defined($chan1) or !defined($chan2));
if (defined($warning)) {
foreach $s (split(/,/, $warning)) {
syntax("Warning value given, $s, is invalid")
unless ($s =~ /^(\w+)=(\d+)$/);
$warnval{$1} = $2;
print "Clear to give WARNING after $2 connections on $1\n" if ($verbose);
}
}
if (defined($critical)) {
foreach $s (split(/,/, $critical)) {
syntax("Critical value given, $s, is invalid")
unless ($s =~ /^(\w+)=(\d+)$/);
$critval{$1} = $2;
print "Clear to give CRITICAL after $2 connections on $1\n" if ($verbose);
}
}
unless ($sock = IO::Socket::INET->new(PeerAddr => $host, PeerPort => $port, Proto => 'tcp')) {
print("Could not connect to asterisk server ".$host.":".$port."\n") if ($verbose);
exit(2);
}
$version = <$sock>;
print $version if ($verbose);
print $sock "Action: Login\r\nUsername: $username\r\nSecret: $password\r\nEvents: off\r\n\r\n";
print "Action: Login\r\nUsername: $username\r\nSecret: $password\r\n\r\n" if ($verbose);
$response = <$sock>;
$message = <$sock>;
$s = <$sock>;
print $response.$message if ($verbose);
print $s if ($verbose);
exit(1) unless ($response =~ m/^Response:\s+(.*)$/i);
exit(1) unless ($1 =~ m/Success/i);
print $sock "Action: Status\r\n\r\n";
print "Action: Status\r\n\r\n" if ($verbose);
$response = <$sock>;
$message = <$sock>;
print $response.$message if ($verbose);
&unknown("Unknown answer $response (wanted Response: something)") unless ($response =~ m/^Response:\s+(.*)$/i);
&unknown("$response didn't say Success") unless ($1 =~ m/Success/i);
&unknown("Unknown answer $response (wanted Message: something)") unless ($message =~ m/^Message:\s+(.*)$/i);
&unknown("didn't understand message $message") unless ($1 =~ m/Channel status will follow/i);
$stop=0;
while (($stop == 0) && ($line = <$sock>)) {
print "$line" if ($verbose);
if ($line =~ m/Channel:\s+(\w+)\//) {
$channels{$1}++;
print "Found $1 channel\n" if ($verbose);
}
if ($line =~ m/Event:\s*StatusComplete/i) {
$stop++;
}
}
# Log out
print $sock "Action: Logoff\r\n\r\n";
undef($s);
for ($i=0;$i<2;$i++) {
if (defined($channels{$chan1})) {
print $channels{$chan1} . "\n";
} else {
print "0\n";
}
if (defined($channels{$chan2})) {
print $channels{$chan2} . "\n";
} else {
print "0\n";
}
}
FreePBX
SipGate Trunk Behind NAT
host=sipgate.com fromdomain=sipgate.com username=10599999 secret=s3cr3t type=peer insecure=very defaultuser=10599999 fromuser=10599999 qualify=yes disallow=all allow=ulaw&alaw dtmfmode=rfc2833 caninvite=no canreinvite=no nat=yes context=from-trunk
OLD INFORMATION
SipGate Configuration
FreePBX
- SIP Trunk
- Trunk Name
- SipGate
- PEER Details
- allow=ulaw&alaw
- caninvite=no
- canreinvite=no
- context=from-trunk
- disallow=all
- fromdomain=sipgate.com
- fromuser=12345678e
- host=sipgate.com
- insecure=invite
- nat=no
- secret=MYPASSWD
- type=peer
- username=12345678e
- USER Details
- Delete ALL
- Register String
- 9999999e0:LK8K3O@sipgate.com/9999999999
- Trunk Name
- Inbound Route
- Description
- SipGate
- DID Number
- 9999999999
- Set Destination
- Extension(Pre-created)
- Description
Google Voice
gvoice setup
[root@voice ~]# asterisk-gvoice-setup
This script installs Google Voice support on your PBX.
You must have a system that is compatible with PBX in a Flash.
WARNING: No error checking is provided.
By using this script, you agree to assume ALL RISK.
NO WARRANTY, EXPRESS OR IMPLIED, OF ANY KIND IS PROVIDED.
If you make a typo while entering values below, press Ctrl-C and start over.
Before starting, make sure you have removed any original [custom-gv] context
Asterisk dialplan configuration file
[Default /etc/asterisk/extensions_custom.conf]:
Your Google Voice entries are stored in /etc/asterisk/extensions_custom.conf
Edit that file and reload your Asterisk dialplan if you make future changes.
10-digit Google Voice phone number (e.g. 9871234567): 1234567891
Google Voice email address: cashmoney@gmail.com
Google Voice password:
11-digit Ring Back DID (e.g. 16781234567): 11234567891
Parking Lot Magic Number: 75
We are now ready to begin the installation.
Confirm your entries below or press Ctrl-C to abort and try again.
CONFIG: /etc/asterisk/extensions_custom.conf
GVNUM: 1234567891
ACCTNAME: cashmoney@gmail.com
RINGBACK: 11234567891
CALLPARK: 75
Hit Enter key to proceed
Installing Google Voice support for your PBX. One moment please...
Installation script is finished. Do NOT run it again on this system!
You can now reload your Asterisk dialplan configuration with the following command
asterisk -rx "dialplan reload"
For complete documentation, see the following Nerd Vittles article:
http://nerdvittles.com/?p=635
[root@voice ~]# asterisk -rx "dialplan reload"
Dialplan reloaded.