Asterisk: Difference between revisions

From Wildsong
Jump to navigationJump to search
Brian Wilson (talk | contribs)
m New page: See also Otter == Overview == Otter is a Toshiba Magnia SG20 server running Ubuntu Linux that acts as my firewall / router. === Goals === Replace a pricey $30 / month Packet8 p...
 
Brian Wilson (talk | contribs)
 
(52 intermediate revisions by the same user not shown)
Line 1: Line 1:
See also [[Otter]]
See also the VOIP category and [[Asterisk debugging]].


== Overview ==
== Overview ==


[[Otter]] is a Toshiba Magnia SG20 server running Ubuntu Linux that acts as my firewall / router.
2022-May-13 Asterisk is not just for phones, it's also for ham radio. It's called AllStarLink, which I am using for the [[Repeater linking]] project.  


=== Goals ===
2019-Nov-01 I ran a Vastra (Asterisk + Twilio) phone system at home for a few years but I am tired of it now, so I am shutting it down and forwarding the number to my cellphone.


Replace a pricey $30 / month Packet8 phone with a more flexible system that allows me to use far cheaper services.
I merged together Twilio and Asterisk for a home phone system. I spent 1000 hours developing a commercial grade small buiness Asterisk based system but my business partner and I got cold feet and we quit.


== Planned set up ==
Back story:  I used Packet8 ($30/month) then Les.net (gone) then Grandcentral + GISMO5 (free!) then Google ate Grandcentral AND GISMO5 and gutted them. Then I used only mobile phones for years.
 
Right now for Asterisk, I am using MySQL not PostgreSQL, it's simpler and gets the job done for phone systems.
I have to update the sections below from PG to MySQL.


=== Incoming calls ===
=== Incoming calls ===


[Grand Central] provides me with a free local phone number (DID) for incoming calls. They route the calls to a [Gizmo Project] SIP account.
People can dial in to a Google Voice number and it will hit the PBX and 2 mobiles. I am moving away from that.


I also have a [Freeworld Dialup] account that can receive calls.
They can also dial in to a Twilio number and it will hit the PBX, which then dials out to my mobile.
I want to set up some TWIML to handle the follow me thing in Twilio instead of having it come through the Asterisk PBX.
I'd kind of like the PBX to go away and just use Twilio. [[Replacing Asterisk with Twilio]]


=== Outgoing calls ===
=== Outgoing calls ===


Currently I have some money on account at [http://les.net Les.net].
Again, using Twilio for outgoing calls too.
It's pay-by-minute with no monthly fee. Rates are about $.015
 
== Business Asterisk system ==
 
=== BLF tip ===
 
If you are working with BLF (the "Busy Lamp Field" lights on phone) (for example on the sidecar for the GXV3240),
and you make changes in Asterisk, the hints and the phone can get out of sync. Lights seem to freeze up or not change.
Don't tear your hair out! Reboot the phone first and see if things start working again.
 
=== Grandstream GXV3240 phone ===
 
For business systems, I am working with these phones right now, along with the optional button modules (which I call "sidecars" for some reason.)
 
I have a separate page for them, see [[Grandstream GXV3240]].
 
=== Grandstream GXW4104 ===
 
Used to connect up to four POTS lines.
 
Buggy firmware... bad documentation... avoid.
 
check and update firmware
set hostname
set up syslog
adjust rings before pickup
set time zone and ntp
 
=== Setting up PostgreSQL ===
 
When building Asterisk from source, you must have the postgres dev package installed before you do ./configure.
Asterisk build is not good about telling you what is available when ./configure completes. You can do 'make menuselect'
and see what will be available.
 
CEL = Channel Event Log, more details than CDR (CDR = Call Detail Record)
 
In cel.conf
enable=yes
 
In cel_pgsql.conf, at the bottom
hostname=localhost
port=5432
dbname=asterisk
password=yoursecretpasswordhere
user=asterisk
table=cel          ; SQL table where CEL's will be inserted                                                       
appname=asterisk  ; Postgres application_name support (optional). Whitespace not allowed.                           
 
If you wish, follow suit and fix up res_pgsql.conf and cdr_pgsql.conf too.
 
Create the database, user and appropriate permission
su - postgres
createdb asterisk
echo "CREATE USER asterisk WITH PASSWORD 'yoursecretpasswordhere';" | psql
echo "GRANT ALL ON DATABASE asterisk TO asterisk;" | psql
 
I got this code from voipinfo.org
http://www.voip-info.org/wiki/view/Asterisk+cdr+odbc
 
CREATE TABLE cel (
  id serial,
  eventtime timestamp with time zone NOT NULL DEFAULT now(),
  eventtype character varying(80) NOT NULL DEFAULT ''::character varying,
  userdeftype character varying(80) NOT NULL DEFAULT ''::character varying,
  cid_name character varying(80) NOT NULL DEFAULT ''::character varying,
  cid_num character varying(80) NOT NULL DEFAULT ''::character varying,
  cid_ani character varying(80) NOT NULL DEFAULT ''::character varying,
  cid_rdnis character varying(80) NOT NULL DEFAULT ''::character varying,
  cid_dnid character varying(80) NOT NULL DEFAULT ''::character varying,
  exten character varying(80) NOT NULL DEFAULT ''::character varying,
  context character varying(80) NOT NULL DEFAULT ''::character varying,
  channame character varying(80) NOT NULL DEFAULT ''::character varying,
  appname character varying(80) NOT NULL DEFAULT ''::character varying,
  appdata character varying(80) NOT NULL DEFAULT ''::character varying,
  accountcode character varying(20) NOT NULL DEFAULT ''::character varying,
  peeraccount character varying(80) NOT NULL DEFAULT ''::character varying,
  uniqueid character varying(32) NOT NULL DEFAULT ''::character varying,
  linkedid character varying(80) NOT NULL DEFAULT ''::character varying,
  amaflags integer NOT NULL DEFAULT 0,
  userfield character varying(255) NOT NULL DEFAULT ''::character varying,
  peer character varying(80) NOT NULL DEFAULT ''::character varying,
  CONSTRAINT cel_pkey PRIMARY KEY (id)
);
 
See also source code contrib/scripts/realtime/postgresql/
 


Another good provider is voipjet.com.
for tbl in `psql -qAt -c "select tablename from pg_tables where schemaname = 'public';" asterisk` ; do  psql -c "alter table $tbl owner to asterisk" asterisk ; done


=== Hardware available ===
Sequences:


1 Grandstream Budgetone phone
for tbl in `psql -qAt -c "select sequence_name from information_schema.sequences where sequence_schema = 'public';" asterisk` ; do  psql -c "alter table $tbl owner to asterisk" asterisk ; done


1 Sipura SPA2000 ATA
Views:


1 Desktop running Ubuntu on the LAN with Gizmo Project softphone installed
for tbl in `psql -qAt -c "select table_name from information_schema.views where table_schema = 'public';" asterisk` ; do  psql -c "alter table $tbl owner to asterisk" asterisk ; done


1 Laptop running Windows XP on WiFi
== Auto-attendant set up ==
 
== Intercom style paging ==
 
# Set up an extension eg "499" that will call Page() with a list of phones, eg. Page(SIP/100&SIP/101&SIP/102,s,120)
# Tell the Grandstream that it's okay to be paged, Account->Account 1->Call Settings->Auto Answer=Enable Intercom/Paging
# Set up an MPK button to page. Advanced Settings->MPK EXT1 Settings->Key mode=Call Intercom,User=499
 
== Hardware ==
 
Not using at the moment: 1 Packet8 DTA-310, reflashed to be a Leadtek BVA8051. See http://www.voip-info.org/wiki-Packet8+DTA310+and+Asterisk and http://www.stromcarlson.com/projects/dta-310/
 
I need to plug in my rotary dial and push button phones to this thing.


== Implementation ==
== Implementation ==


I am using the generic asterisk package that is pulled from the Ubuntu repository. To this I make the following configuration changes.
=== Customizations ===
 
As much as possible I keep general changes out of main config files by using include files. This makes updates much simpler. In sip.conf add this line: #include sip-wildsong.conf and in extensions.conf add this: #include extensions-wildsong.conf The voicemail.conf file warns agains this approach so I edit it directly.
 
For each of the extensions, I then add entries in sip-wildsong.conf and extensions-wildsong.conf and voicemail.conf.
 
I edit the web settings for the hard phones and the configuration settings for the Ekiga softphones.


=== Les.net connection ===
That's about it.


Use the instructions with the les.net account to set up iax.conf
[[Category: Telephones]][[Category:Network]]
and extensions.conf files.

Latest revision as of 15:47, 31 August 2022

See also the VOIP category and Asterisk debugging.

Overview

2022-May-13 Asterisk is not just for phones, it's also for ham radio. It's called AllStarLink, which I am using for the Repeater linking project.

2019-Nov-01 I ran a Vastra (Asterisk + Twilio) phone system at home for a few years but I am tired of it now, so I am shutting it down and forwarding the number to my cellphone.

I merged together Twilio and Asterisk for a home phone system. I spent 1000 hours developing a commercial grade small buiness Asterisk based system but my business partner and I got cold feet and we quit.

Back story: I used Packet8 ($30/month) then Les.net (gone) then Grandcentral + GISMO5 (free!) then Google ate Grandcentral AND GISMO5 and gutted them. Then I used only mobile phones for years.

Right now for Asterisk, I am using MySQL not PostgreSQL, it's simpler and gets the job done for phone systems. I have to update the sections below from PG to MySQL.

Incoming calls

People can dial in to a Google Voice number and it will hit the PBX and 2 mobiles. I am moving away from that.

They can also dial in to a Twilio number and it will hit the PBX, which then dials out to my mobile. I want to set up some TWIML to handle the follow me thing in Twilio instead of having it come through the Asterisk PBX. I'd kind of like the PBX to go away and just use Twilio. Replacing Asterisk with Twilio

Outgoing calls

Again, using Twilio for outgoing calls too.

Business Asterisk system

BLF tip

If you are working with BLF (the "Busy Lamp Field" lights on phone) (for example on the sidecar for the GXV3240), and you make changes in Asterisk, the hints and the phone can get out of sync. Lights seem to freeze up or not change. Don't tear your hair out! Reboot the phone first and see if things start working again.

Grandstream GXV3240 phone

For business systems, I am working with these phones right now, along with the optional button modules (which I call "sidecars" for some reason.)

I have a separate page for them, see Grandstream GXV3240.

Grandstream GXW4104

Used to connect up to four POTS lines.

Buggy firmware... bad documentation... avoid.

check and update firmware
set hostname
set up syslog
adjust rings before pickup
set time zone and ntp

Setting up PostgreSQL

When building Asterisk from source, you must have the postgres dev package installed before you do ./configure. Asterisk build is not good about telling you what is available when ./configure completes. You can do 'make menuselect' and see what will be available.

CEL = Channel Event Log, more details than CDR (CDR = Call Detail Record)

In cel.conf

enable=yes

In cel_pgsql.conf, at the bottom

hostname=localhost
port=5432
dbname=asterisk
password=yoursecretpasswordhere
user=asterisk
table=cel          ; SQL table where CEL's will be inserted                                                        
appname=asterisk   ; Postgres application_name support (optional). Whitespace not allowed.                             

If you wish, follow suit and fix up res_pgsql.conf and cdr_pgsql.conf too.

Create the database, user and appropriate permission

su - postgres
createdb asterisk
echo "CREATE USER asterisk WITH PASSWORD 'yoursecretpasswordhere';" | psql
echo "GRANT ALL ON DATABASE asterisk TO asterisk;" | psql

I got this code from voipinfo.org http://www.voip-info.org/wiki/view/Asterisk+cdr+odbc

CREATE TABLE cel (
 id serial,
 eventtime timestamp with time zone NOT NULL DEFAULT now(),
 eventtype character varying(80) NOT NULL DEFAULT ::character varying,
 userdeftype character varying(80) NOT NULL DEFAULT ::character varying,
 cid_name character varying(80) NOT NULL DEFAULT ::character varying,
 cid_num character varying(80) NOT NULL DEFAULT ::character varying,
 cid_ani character varying(80) NOT NULL DEFAULT ::character varying,
 cid_rdnis character varying(80) NOT NULL DEFAULT ::character varying,
 cid_dnid character varying(80) NOT NULL DEFAULT ::character varying,
 exten character varying(80) NOT NULL DEFAULT ::character varying,
 context character varying(80) NOT NULL DEFAULT ::character varying,
 channame character varying(80) NOT NULL DEFAULT ::character varying,
 appname character varying(80) NOT NULL DEFAULT ::character varying,
 appdata character varying(80) NOT NULL DEFAULT ::character varying,
 accountcode character varying(20) NOT NULL DEFAULT ::character varying,
 peeraccount character varying(80) NOT NULL DEFAULT ::character varying,
 uniqueid character varying(32) NOT NULL DEFAULT ::character varying,
 linkedid character varying(80) NOT NULL DEFAULT ::character varying,
 amaflags integer NOT NULL DEFAULT 0,
 userfield character varying(255) NOT NULL DEFAULT ::character varying,
 peer character varying(80) NOT NULL DEFAULT ::character varying,
 CONSTRAINT cel_pkey PRIMARY KEY (id)
);

See also source code contrib/scripts/realtime/postgresql/


for tbl in `psql -qAt -c "select tablename from pg_tables where schemaname = 'public';" asterisk` ; do  psql -c "alter table $tbl owner to asterisk" asterisk ; done

Sequences:

for tbl in `psql -qAt -c "select sequence_name from information_schema.sequences where sequence_schema = 'public';" asterisk` ; do  psql -c "alter table $tbl owner to asterisk" asterisk ; done

Views:

for tbl in `psql -qAt -c "select table_name from information_schema.views where table_schema = 'public';" asterisk` ; do  psql -c "alter table $tbl owner to asterisk" asterisk ; done

Auto-attendant set up

Intercom style paging

  1. Set up an extension eg "499" that will call Page() with a list of phones, eg. Page(SIP/100&SIP/101&SIP/102,s,120)
  2. Tell the Grandstream that it's okay to be paged, Account->Account 1->Call Settings->Auto Answer=Enable Intercom/Paging
  3. Set up an MPK button to page. Advanced Settings->MPK EXT1 Settings->Key mode=Call Intercom,User=499

Hardware

Not using at the moment: 1 Packet8 DTA-310, reflashed to be a Leadtek BVA8051. See http://www.voip-info.org/wiki-Packet8+DTA310+and+Asterisk and http://www.stromcarlson.com/projects/dta-310/

I need to plug in my rotary dial and push button phones to this thing.

Implementation

Customizations

As much as possible I keep general changes out of main config files by using include files. This makes updates much simpler. In sip.conf add this line: #include sip-wildsong.conf and in extensions.conf add this: #include extensions-wildsong.conf The voicemail.conf file warns agains this approach so I edit it directly.

For each of the extensions, I then add entries in sip-wildsong.conf and extensions-wildsong.conf and voicemail.conf.

I edit the web settings for the hard phones and the configuration settings for the Ekiga softphones.

That's about it.