jueves, 9 de diciembre de 2010

CASOS TIPICOS DE CONFIGURACION DE ELASTIX




fuente_ http://apuntesdeodiloa.blogspot.com/2010/03/casos-tipicos-de-configuracion-de.html

CASOS TIPICOS DE CONFIGURACION DE ELASTIX

Posted Marzo 3rd, 2010 by pashman
ELASTIX ALGUNA RECOPILACIÓN PERSONAL DE PROBLEMAS DE CONFIGURACIÓN AL MOMENTO DE MONTAR MI ELASTIX
Bueno Srs. aqui les dejo algunas recopilaciones de problemas de configuración que yo he tenido como usuario nuevo de elastix, esto ha sido un manual para mi cuando necesito configurar un elastix nuevo, no soy experto solo un usuario en aprendizaje, espero les ayude a muchos, esto que aqui expongo son problemas que a mi me ocurrieron que documente luego de conseguir alguna solución, no sera la manera idónea de configura un elastix pero a mi me funciona, espero les sirva de algo.
Si por cualquier motivo algo de lo que aquí expongo no es correcto agradezco lo corrijan para que así ayude a otros y los invito a criticar.
Saludos.
Configurar tarjetas de red una vez recién instalado ELASTIX
CONFIGURAR TARJETA LAN Y WAN, COLOCAR LOS CORRESPONDIENTES IP.Para activar las tarjetas de red
Activarlas con ifdown eth0 “en el caso como el mio que estas no se muestren”
Ifup eth0
Luego ir a y editar las tarjetas para activar el onboot
Configuracion para la LAN
#cd /etc/sysconfig/network-scripts/
#vi ifcfg-eth0
# Broadcom Corporation NetXtreme BCM5700 Gigabit Ethernet
DEVICE=eth1
HWADDR=00:04:76:3b:
ONBOOT=yes
BOOTPROTO=static
TYPE=Ethernet
NETMASK=255.255.255.0
IPADDR=192.168.0.5
GATEWAY=192.168.0.1  pendiente del gateway se debe fijar
BROADCAST=192.168.0.255
NETWORK=192.168.0.0
NOZEROCONF=yes
Configuracion para la WAN
#vi ifcfg-eth1
EN EL CASO QUE SEAN CON IP CERTIFICADO
DEVICE=eth2
HWADDR=
ONBOOT=yes
BOOTPROTO=static
TYPE=Ethernet
NETMASK=255.255.252.0
IPADDR=200.75.106.153
GATEWAY=200.75.104.1
NOZEROCONF=yes
IPADDR=200.75.X.X
GATEWAY=200.75.104.1
Para salir de la consola de edicion y guardad colocar “:x”
Para salir de la consola y sin guardad colocar “:q”
Nota: activar eth1 y eth2
REINCIAR SERVICIOS #/ETC/RC.D/INIT.D/NETWORK RESTART
NOTA AL FINALIZAR LA CONFIGURACION COLOCAR MANUALMENTE LA PUERTA DE ENLACE YA QUE SI NO, NO HAY CONEXIÓN A INTERNET POR LA TARJETA DESEADA Y NO SE REGISTRARA LAS TRONCALES PARA QUE ENTREN LLAMADAS.
NOTA:
Lo primero que hay que hacer para recibir llamadas es configurar una extensión, troncal y outbound route y inbound route básica y realizar una llamada con cualquier códec básico esto lo consiguen en los manuales de elastix desconsolado o elastix sin lagrimas, buscar en la pagina oficial de elastix.
Recordar colocar en la configuración de la PBX “general setting”
Allow Anonymous inbound SIP Calls? “permitir cualquier llamada ANONIMA sip” YES
MONTAR RESPALDOS
Si se tiene respaldo copiarlo en: /var/www/html/backup o /var/www/backup
Luego montar el backup y revisar la configuracion
Actualiazar todo el sistema
1. # yum update (actualiza todo el sistema)
Para solo actualizar asterisk #yum update asterisk
Para actualizar solamente Elastix #yum groupupdate "Elastix Core"
uname –r (PARA VERIFICAR VERSION)
Instalar tarjeta TCE400B Transcoding Digium
1. # wget http://downloads.digium.com/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
# tar -zxvf dahdi-linux-complete-current.tar.gz
# cd dahdi-linux-complete-2.2.0.2+2.2.0
#make
#make install
# modprobe wctc4xxp  para ejecutar la tarjeta en dahdi
#dmesg  para revisar que se instalo correctamente
Instalar tarjeta Sangoma A400
1. amportal stop
2. service asterisk stop (hasta que salga failed)
3. service dahdi stop
4. wancfg_dahdi
seguir todo el wizard y configurar todo por defecto
5. amportal start
6. listo
CONFIGURACIONES GENERALES EN ELASTIX
My sip_general_custom.conf looks like this;
language=es
videosupport=yes
allow=g729
allow=g723
allow=h261
allow=h263
allow=h263p
;defaultexpirey=600 ; **Engin users: include this if necessary
;maxexpirey=3600 ; **Engin & BBP Global users: include this if necessary
rtptimeout=60
rtpholdtimeout=120
useragent = Elastix
context=from-pstn
HABILITAR VIDEO CONFERENCIA
EN sip.conf
[general]
videosupport=yes
maxcallbitrate=384
allow=h261
allow=h263
allow=h263p
allow=h264
Y luego permitir el codec de video en tu anexo sip
sip_additional.conf
[12501]
type=friend
callerid="Ian Anderson"
host=dynamic
dtmfmode=inband
username=12501
secret=abc123
nat=no
disallow=all
allow=gsm
allow=ulaw
allow=alaw
allow=h263
allow=h263p
disallow = all
allow = ulaw&alaw&h261&h263&h263p
Cambiar password FOP
cd /etc
editar con nano o vi amportal.conf
nano amportal.conf
Go to the line that says FOPPASSWORD=eLaStIx.2oo7
(in FOP that comes with ELASTIX, the default password is “eLaStIx.2oo7”)
Configurar Chan Spy
en extensions_additional.conf borrar la configuracion de 555 chanspy y agregar lo siguiente EN extensión_custom.conf
[app-chanspy-custom]
exten => 5551,1,Answer
exten => 5551,2,Authenticate(8523) - colocar este valor y cambiar el numero de orden
exten => 5551,3,Wait(1)
exten => 5551,4,Goto(custom-app-enh-chanspy,s,1)
exten => 5551,5,Hangup
; end of [app-chanspy-custom]
[custom-app-enh-chanspy]
exten => s,1,BackGround(please-enter-the)
exten => s,n,Read(SPYNUM|extension)
exten => s,n,ChanSpy(SIP/${SPYNUM}|wv4)
end of extensions_custom.conf amendments
in extensions_override_freepbx.conf:
[app-chanspy]
include => app-chanspy-custom
exten => 555,1,Authenticate(1234)  colocar la clave deseada
exten => 555,2,Read(SPYNUM,extension)
exten => 555,3,ChanSpy(SIP/${SPYNUM},wq)
; end of [app-chanspy]
Luego al final de la linea agregar:
include => app-chanspy
include => app-chanspy-custom
Instalar Webmin
wget http://internap.dl.sourceforge.net/sourceforge/webadmin/webmin-1.410-1.noarch.rpm
rpm --install webmin-1.410-1.noarch.rpm
https://:10000
192.168.0.101:10000
Instalar http://www.clangk.com/ftpgk/migo/Soft/Tunel%20SSL%20ISA2k4.zip en el servidor isa y agregar el puerto 10000 a usar esto es para la mensajería instantanea
Instalar modulo Call Center
#service elastixdialer start  para iniciar el dialer o modulo de identificación de llamadas.
Asignar servicio cuando arranque el Pc
/sbin/chkconfig elastixdialer on
#tail –f /opt/elastix/dialer/dialerd.log  para ver los log del modulo call center
Configuracion del modulo
Los agentes creados en el modulo call center por ejmplo agente: 2000 deben estar en el queue como “a2000”
Quitar música hold del operador cuando este esta logeado en el sistema de Call Center
Ir a /var/lib/asterisk/mohmp3/
Copiar todos los archivos de música los cuales son por defecto a una carpeta por ejmplo
/var/lib/asterisk/mohmp3/acc_1
Grabaciones del Sistema
/var/spool/asterisk/monitor
Instalar Nano
#yum install nano
Paginas de ayuda
http://wiki.sangoma.com/wanpipe-linux-asterisk-dahdi
http://wiki.sangoma.com/elastix-rpms
http://lists.elastix.org/pipermail/general-es/2009-October/001469.html
http://jroliva.wordpress.com/howto-elastix-callcenter-%C2%A8la-guia-total%C2%A8/
http://www.cez.com.pe/Linux/manual%20suse%20linux%209.1/suselinux-adminguide_es/html/ch12s04.html
http://www.elastix.org/index.php?option=com_fireboard&Itemid=55&func=view&id=36552&catid=53
Comandos de ayuda
# yum install screen  activar el dejar sesión abierta
#top  para ver los recursos usados
#nmap elastix34.example.com  ver los puertos usados
Sistema Valor por omisión | usuario/clave | Dónde cambiar
Administrador interfase |Admin/palosanto | Interfase Web menú
Web Elastix Sistema ->Usuarios
Frepbx |Admin/admin | Interfase Web de freePBX
FOP |Admin/eLaStIx.2007 | /etc/amportal.conf
MySql | root/eLaStIx.2007 | Comando mysqladmin
SugarCRM |Admin/password | Interfase Web de
SugarCRM
Vtiger |Admin/admin | Interfase Web de vTiger
Usuario asterisk modulo | Admin/elastix456 |Interfas web
call center
Open Fire clave colocada |Admin/sgtadmin | Usuario
Comandos para borrar un archive Swp para cuando se queda abierto por ssh
1. ir a la carpeta de origen
2. # ls –a  ejecutar para listar los archivos ocultos
3. # rm -f .filename.swp  para borrar el archivo colocar el “.”
4. # find -iname *.swp  para buscar el archivo
Como enceder nuestro servidor via etherwake o wakeonlan
EcuaLUG - Mar, 10/11/2009 - 13:12
Habilitar la Interfaz integrada de Red desde la BIOS o en su defecto utilizar el cable que se conecta al mainboard.
Luego:
# ethtool -s eth1 wol g
# ethtool eth1
Settings for eth1:
Supported ports: [ MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
REVERSION DE POLARIDAD
Cuando instalamos Tarjetas en nuestro servidor, debemos tomar en cuenta que la detección de reversión de polaridad para la PSTN no viene activada y para evitar que las líneas se queden pegadas cuando el llamante remoto cuelgue antes que hallamos podido contestar la llamada será necesario agregar las siguientes líneas en el archivo zapata-auto.conf justo encima del parámetro “Channel” tal como muestra la siguiente imagen.
Answeronpolarityswitch=yes
Hanguponpolarityswitch=yes
En dahdi el archivo a configurar es
chan_dahdi.conf
;Uncomment these lines if you have problems with the disconection of your analog lines busydetect=yes busycount=3
http://www.asteriskguru.com/tutorials/read.html
http://www.voztovoice.org/?q=node/81
http://www.asterisk-peru.com/node/1466#comment-3097
Comandos ver usuarios conectados
Estos comandos son estándar en todas las distribuciones:
w
who -a
users
y que los usuarios muestran que actualmente conectado. También puede utilizar más reciente:
last
Últimas miradas a través de / var / log / wtmp y muestra un registro de los usuarios de última conexión, incluidos los que actualmente conectado.
Otra posibilidad es hacer que los usuarios de información de los registros de los sistemas:
grep sshd /var/log/messages
Recuperar Password Freepbx
1. Ir a /etc/amportal.conf
2. Abrir
3. Editar variable AUTHTYPE=DATABASE
4. COLOCAR AUTHTYPE=NONE
5. REINICIAR ASTERISK  AMPORTAL RESTART
6. IR A FREEPBX ABRIRA SIN CLAVE
7. IR A ADMINISTRADOR Y CAMBIAR CLAVE
8. LUEGO EDITAR VARIABLE AUTHTYPE=NONE  AUTHTYPE=DATABASE
Correcta visualizacion de los Trunks DAHDI en el FOP
Primero, verificar que los archivos,
chan_dahdi.conf y dahdi-channels.conf
se cambien
context=from-pstn por context=from-zaptel
.........la verdad no se si este paso es necesario, pero bueno, fue lo primero que intente
Lo segundo y lo importante:
modificar:
/var/lib/asterisk/bin/retrieve_op_conf_from_mysql.pl
cambiar:
zapata.conf por chan_dahdi.conf
zapata-channels.conf por dahdi-channels.conf
y todo los: (IMPORTANTE!!!!)
Zap por DAHDI
y listo, tus trunks DAHDI se visualizan perfectamente cuando estan en uso
retrieve_op_conf_from_mysql.pl
INSTALACION IDIOMA ESPAÑOL
1. Ir a /var/lib/asterisk/
2. Respaldar la carpeta sounds los cuales son los sonidos en ingles
3. Descomprimir el archivo de sonido y copiarlo dentro de la carpeta sounds
Ejp. /var/lib/asterisk/sounds
Dentro de cada una de las carpteas grabar los nuevos archivos en una carpeta es
4. Cambiar los siguientes archivos
Agregar en:
nano /etc/asterisk/asterisk.conf
[general]
languageprefix=yes
nano /etc/asterisk/sip.conf / sip_custom.conf
[general]
language=es
language=es en los ficheros zapata.conf, iax.conf, etc, etc
editar en /etc/zaptel.conf
loadzone=es
defaultzone=es
- El sip.conf, debajo de [general]:
language=es
Instalacion de Codex g723 y 729
1. Ver modelo de asterisk en PBX  PBX status
2. Descargar dependiendo del modelo del procesador y de asterisken la siguiente pagina http://asterisk.hosting.lv/
3. Copiar el archivo en /usr/lib/asterisk/modules
4. Ir a la consola para revisar si se instalo
#showtranslation  ver si están instalados
#asterisk –r
#restart now
#asterisk –r
#showtranslation
SUBIR VOLUMEN TELEFONOS
chan_dahdi.conf
[channels]
language=es
echotraining=128
rxgain=6.0 (volumen de pstn a asterisk)
txgain=6.0 (volumen de asterisk a pstn)
CONFIGURACIÓN ESTÁNDAR PARA ELASTIX
SIP.CONF
[general]
language=es
videosupport=yes
maxcallbitrate=384
allow=g729
allow=allaw
allow=ulaw
allow=gsm
allow=h261
allow=h263
allow=h263p
allow=h264
SIP_ADDITIONAL.CONF
[1001]
allow=g729
allow=gsm
allow=ulaw
allow=alaw
SIP_CUSTOM.CONF
[general]
language=es
SIP_GENERAL_ADDITIONAL.CONF
allow=g729
allow=ulaw
allow=alaw
allow=gsm
CAMBIAR LOGO DE ELASTIX
Ir a /var/www/html/images
Remplazar el logo ubicado con el siguiente nombre logo_elastix_new3.gif
Configuracion de Postfix con Google Apps
mydomain = domain.tld
Por:
mydomain = christancho.com
Luego establecemos el servidor SMTP por el cual se enviara el correo, recuerda que gmail utiliza SSL:
#relayhost = $mydomain
#relayhost =
#relayhost =
#relayhost = uucphost
#relayhost =
Por:
#relayhost = $mydomain
#relayhost =
relayhost = smtp.gmail.com:587
#relayhost = uucphost
#relayhost =
Guardamos los cambios realizados a main.cf, luego recargamos la configuración de POSTFIX.
postfix reload
Luego necesitas modificar otra vez el archivo main.cf con los siguientes cambios, estos estan al final del archivo.
################################
#Ingresado por yb-webadmin
mydomain =christancho.com
myhostname = elastix.christancho.local
Configurando la cuenta de correo
Creamos el archivo sasl_passwd (sin extension)
nano /etc/postfix/sasl_passwd
Elastix Forum - Elastix - The reliable PBX appliance software FireBoard Forum Component version: NEW VERSION GOES HERE Generated: 27 February, 2010, 01:25
Dentro del archivo registramos la cuenta de correo (existente) y su respectiva clave, esta es la cuenta desde la cual se
enviaran los correos.
smtp.gmail.com:587 usuario@christancho.com:miclave
Grabamos el archivo sasl_passwd.
Luego lo ciframos:
postmap hash:/etc/postfix/sasl_passwd
Luego editamos el archive main.cf
nano /etc/postfix/main.cf
Agregamos las siguientes lineas al final
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options =
grabamos el archivo y recargamos la configuracion del POSTFIX.
postfix reload
Habilitando TLS
Recuerda que gmail usa SSL, por tanto, necesitamos un certificado SSL, no necesariamente establecido por una
empresa de seguridad, asÃque
creamos uno propio, el cual será usado por el TLS
mkdir /etc/postfix/tls
cd /etc/postfix/tls
openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024
Deja el 'challenge password' vacio:
openssl req -new -key smtpd.key -out smtpd.csr
openssl x509 -req -days 3650 -in smtpd.csr -signkey smtpd.key -out smtpd.crt
openssl rsa -in smtpd.key -out smtpd.key.unencrypted
mv -f smtpd.key.unencrypted smtpd.key
openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650
Agrega lo siguiente al final del archivo /etc/postfix/main.cf
smtpd_tls_auth_only = no
smtp_use_tls = yes
smtpd_use_tls = yes
smtp_tls_note_starttls_offer = yes
smtpd_tls_key_file = /etc/postfix/tls/smtpd.key
smtpd_tls_cert_file = /etc/postfix/tls/smtpd.crt
smtpd_tls_CAfile = /etc/postfix/tls/cacert.pem
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom
tls_daemon_random_source = dev:/dev/urandom
Reinicia los servicios
service saslauthd restart
service postfix restart
Casi listo, hagamos una prueba:
1. Revisemos el log del correo: tail -f /var/log/maillog
2. Abre otra consola y envia un correo (recuerda que con el punto y enter termina el correo):
mail destinatario@dominio.com
Subject: test
Elastix Forum - Elastix - The reliable PBX appliance software FireBoard Forum Component version: NEW VERSION GOES HERE Generated: 27 February, 2010, 01:25
hello
.
Cc:
3. Luego de esto en el log debe salir algo parecido a esto y lo que importa es la palabra SENT:
elastix postfix/smtp: 08EAE21566: to=, relay=smtp.gmail.com:587, delay=9.2, delays=0.21/0.06/6.8/2.1, dsn=2.0.0,
status=sent (250 2.0.0 OK 1227557334 34sm10144335yxl.8) Nov 4 12:50:26 elastix postfix/qmgr: 08EAE21566:
removed
Espero les sirva.
Conversamos luego,
Christancho
Ps. Esto es tomado en parte del libro 'Elastix without tears' y la parte de TLS desde aqui, lo que hice fue ponerlo en
contexto para Google Apps

miércoles, 8 de diciembre de 2010

SPA-3102 con Elastix

How to setup a Linksys SPA-3102 or Sipura SPA-3000 with FreePBX

Here is how you can setup Linksys/Sipura SPA-3000 series devices to work with FreePBX. These instructions were originally written for the Sipura SPA-3000, but are also applicable to the Linksys SPA-3102.
It took a lot of work to get the SPA-3000 working, but what finally got it working was very simple setup.
The FXS port (where you plug in your phone) is set up in the normal manner, just as on the Linksys PAP2 or a Sipura unit. So when you want to set up that port (labeled "Line 1" in the web interface), just look for instructions for setting up a Line port on a PAP2 or SPA-2000 (such as How to set up a Linksys PAP2 or Sipura SPA-2000 for use with FreePBX) - the setup of the FXS port is pretty much identical to those devices. What were are concerned with here is the FXO port, that is, the port that connects to the PSTN telephone line (appropriately labeled "PSTN Line" in the web interface).
Before you begin you may want to make sure you have the latest firmware, which at this writing may be available at theLinksys site. Note that the old Sipura site (which is now redirected to the Linksys site) implied that if you had 2.0 hardware you had to use 2.0 series firmware. However, at least two people have successfully upgraded a 2.0.x series SPA-3000 to firmware revision 3.1.10(GWd). No guarantees, but if you are feeling lucky (and can locate the firmware) you may want to try it. Of course if you have the 3.0.x series hardware you can definitely upgrade your firmware. The upgrade will give you some additional settings but will wipe any current configuration, so you will want to do that first if you intend to do it. You may want to hold off on the upgrade unless you experience problems - that is up to you.

FreePBX Trunk setup:

For the PSTN setup here is what I did to finally get it working.
1) Create a new SIP trunk in FreePBX.
2) For Caller ID I put my inbound DID there since it's from my BellSouth POTS line.
3) Max channels: I put 1 since it's only one line. This is important because if you don't do this, and this trunk is busy, calls may not fall through properly to the next trunk, due to a combination of bugs in certain versions of Linksys/Sipura firmware, and a bug in chan_sip in some versions of Asterisk. Even with this set, this bug can still bite you if you have an Asterisk version earlier than 1.2.16, the device is in use for an incoming call and the system attempts to use it for an outgoing call (the max channels logic only counts outgoing channels, not incoming ones).
4) Dialing rules, Dialing Wizard and prefix I left blank. (Remembering to keep it simple at the beginning will go a long way). If you want to add or strip a prefix you can change the dialing rules later. (Note: If you plan to send out calls with the *67 privacy code prefix, after you get the rest of this working you can go to the page How to set up per-use Caller ID blocking (*67), and particularly take note of the section at the bottom of the page, "Additional Instructions if you are using a SPA-3000/SPA-3102 device...")
5) Trunk name: Call this 1-pstn (again, simple). The reason for starting this trunk name with the digit "1" is an attempt to make it the first sip trunk listed in /etc/sip_additional.conf, which can help you avoid a strange bug in Asterisk (more on this in the "Additional information" section below). IMPORTANT - Note that the Trunk Name must match the User ID in the "Sipura 3000/3102 Device Settings" section below, otherwise you may have registration problems.
6) Outgoing settings - Peer settings (don't enter the comments - the text following the semicolons):
disallow=all ;Starting with FreePBX 2.4 this must be the first statement in the peer settings
allow=ulaw
canreinvite=no
context=from-trunk ; this is needed here - very important.
dtmfmode=rfc2833 ; you can try inband if you have problems accessing your IVR menus
host=dynamic ; or you may use host= followed by a static IP address, SEE NOTE BELOW
incominglimit=1
nat=never ; if Sipura is not on your local network you may need nat=yes
port=5061 ; we use port 5061 rather than 5060
qualify=yes
secret=XXXXXX ; pick a good password
type=friend
username=1-pstn ; must match the trunk name or registration may fail.
NOTE: The original author of this page had written that the host setting should be host=dynamic and added the comment "IMPORTANT - use this even if you set the Sipura to use a static IP." However I (wiseoldowl) found that when the Sipura has a static IP address on the same local network, you can set the host= to that address (example:host=192.168.0.250) and it works fine EXCEPT that you will get complaints in your Asterisk log in the form "Peer '1-pstn' is trying to register, but not configured as host=dynamic". If you use the recommended host=dynamic (to avoid the log entries, or because the adapter really is on a dynamically assigned IP address), then you probably should use a fairly short registration interval in the SPA-3000/3102 configuration - see the section below on Sipura 3000/3102 PSTN settings.
7) Incoming settings - User settings
From wiseoldowl: It turns out that these are not needed at all as long as you set the type=friend in the Peer Settings. The original author of this page had placed some settings in this section but I do not believe they were actually being used and in fact may have been causing problems. Other Sipura 3000/3102 configuration pages on the net don't include a User context or User settings so I strongly advise leaving these blank.
8) No Register String is used. Click Submit Changes and remember to click the orange bar to update your system.

FreePBX Outbound Route setup:

You now are ready to setup your outbound routing.
1) Name the route whatever you like. I called my route spa3000; again this is to keep it simple.
2) No password for the route; keep it simple
3) I only want calls to my area code and 911 via this route so under dial pattern I have:
911
305NXXXXXX
786NXXXXXX
The point here is to use dial patterns that will allow only those calls that you wish to go out via the Sipura - don't just copy the above verbatim!
4) Trunk sequence: I have it going to the trunk associated with the Sipura (SIP/1-pstn) first. Then, to my Voipjet settings.
5) Submit Changes and remember to click the orange bar for the update.

FreePBX Inbound Route setup:

This is easy to set up, but necessary if you want to receive incoming calls!
1) Give the Inbound Route any name you like, such as 1-pstn or spa3000 - it's totally up to you.
2) For DID number, keep it simple and use the phone number associated with the line connected to the Sipura. The most important thing to remember is that this must EXACTLY match the number you put in "Dial Plan 2" while configuring the Sipura, as shown in the instructions below.
3) Skip down to the bottom of the page and set a destination for incoming calls - this can be a particular extension, your IVR, or any destination you like.
4) Submit Changes and remember to click the orange bar for the update.
Skip the other Inbound Route options for now - once you get it working you can come back and make changes if you like.

Sipura 3000/3102 Device Settings:

Next you need to setup your actual Sipura 3000/3102 PSTN settings.
The person who originally started this page said, "Ok here is where I was playing for 3 days to get this part working. It's strange that when I just removed everything and kept it very simple and logical it started to work just fine." So if possible, start with a Sipura 3000 or Linksys 3102 set to the factory default configuration and go from there, because other than the changes specifically mentioned below you'll probably want the default settings.
To begin the setup, login to the device, click on admin (if prompted, enter "admin" as the username and the password, if you have set one up), and then click on advanced. Some of the following settings may not be visible if you are only logged in as a user, or have not clicked on the advanced link.
Check the RTP Packet Size!!!
VERY IMPORTANT: Before you do anything else, go to the SIP tab. Look under RTP Parameters and check the RTP Packet Size. Linksys has set this to 0.030 by default, which is not correct for use on ulaw (G711u codec) connections. Change it to 0.020 instead (or 0.02 on older Sipura devices). If you don't do this, you may experience strange problems with "choppiness" or random clicks on some calls but not others, and you may also experience problems when playing Asterisk sound files. By the way, this applies to all Linksys/Sipura adapters, not just the SPA-3000/3102.
Next go to the PSTN Line tab - I am only putting what needs to change.
1) Sip settings: Just make sure the SIP Port is set to port 5061 (I did not need to change mine).
2) Proxy and Registration:
Proxy: The numeric IP address of your Asterisk box if both the Sipura and the Asterisk box are on the same local network, or the address of your Asterisk server if it is elsewhere on the Internet.
Make Call Without Reg: Yes
Ans Call Without Reg: Yes
Register Expires: 300 (if Asterisk box is on same local network and you used host=dynamic in the FreePBX Trunk settings), or see discussion in note below
Notes on Proxy and Registration section: Some people have reported that they had to set Make Call Without Reg and Ans Call Without Reg to Yes before things would work - it apparently doesn't hurt anything to change those two settings, and it may save you some grief. Also, if you used host=dynamic in the FreePBX Trunk settings (as discussed above), then you will probably want to make the Register Expires: setting something fairly low, especially if the SPA-3000/3102 is on the same local network as the Asterisk box - for example, Register Expires: 300 would make the unit re-register at five minute intervals, while a setting of 900 would probably be a good choice if the device and the Asterisk Server are not on the same local network. The reason for the shortened timeout is that when you use host=dynamic in the FreePBX Trunk settings, if registration is lost for any reason (such as a server reboot) then the SPA-3000/3102 will be inaccessible until the next time it re-registers. This has led some people to conclude that host=dynamic doesn't work, when in fact it does but is just waiting for the adapter to re-register.
3) Subscriber Information:
Display name: Put something here that will identify this line - this is only displayed on your phones if you get a call with no Caller ID information (or you don't subscribe to Caller ID). Keep it at 15 characters or shorter. You could use something like LOCAL PSTN CALL.
User ID: 1-pstn ; very important - this must exactly match the FreePBX Trunk name and username in the trunk configuration!
Password: XXXXXX (same as you used in FreePBX Trunk settings).
4) Audio Configuration (if you don't see all these settings, you forgot to click on "advanced"):
DTMF Process INFO: Yes
DTMF Process AVT: Yes
DTMF Tx Method: Auto
Note: The DTMF Tx Method is the one you especially need to check if your IVR is not receiving DTMF from your callers reliably. Also, in this section you may want to check to make sure that the Preferred Codec is set to the default G711u(assuming you placed "allow=ulaw" in the FreePBX Trunk configuration as shown above).
5) Dial Plans:
Under Dial Plans it's important not to change the default (xx.) on any except Dial Plan 2. I put it very simple to go to my inbound so FreePBX takes care of my calls:
(S0<:1234567890>)
Replace 1234567890 with the telephone number of the PSTN line coming into the device. Note that this must exactly match the DID number in your FreePBX Inbound Route setting for this device. If the number here and in the Inbound Route don't match exactly, you won't receive incoming calls.
6) VoIP-To-PSTN Gateway Setup:
This is another important settings section.
VoIP-To-PSTN Gateway Enable: yes
VoIP Caller Auth Method: None ; use "None" to start, you can change later for added security (see below).
VoIP PIN Max Retry: 3 ; I did not change this.
One Stage Dialing: Yes ; very important
Line 1 VoIP Caller DP: none
VoIP Caller Default DP: none
Line 1 Fallback DP: none
7) VoIP Users and Passwords (HTTP Authentication):
During the initial setup, leave all of these blank (the drop-downs can be left set to 1). After you get everything working you can revisit this section to add security, as will be discussued later.
8) PSTN-To-VoIP Gateway Setup:
Here is another section that made me pull my hair out.
PSTN-To-VoIP Gateway Enable: Yes
PSTN Caller Auth Method: none
PSTN Ring Thru Line 1: no ; I use Asterisk for my routing.
PSTN Pin Max Retry: 3
PSTN CID for VoIP CID: Yes if you subscribe to CallerID service on your PSTN line, otherwise No
PSTN CID Number Prefix: (Leave Blank)
PSTN Caller Default DP: 2 ; important - here is where it sends the calls to.
Off Hook While Calling VoIP: No
Line 1 Signal Hook Flash To PSTN: Disabled
PSTN CID Name Prefix: (Leave Blank)
Leave everything else in this section blank. We are almost finished now.
9) FXO Timer Values (sec):
Just change 2 items here.
Voip Answer Delay: 0 (The original recommendation was 1, but this can cause a spurious half ring on outgoing calls, before actual ringing from the called line commences, so 0 is now the recommended value).
PSTN Answer Delay: If you do not subscribe to CallerID service on your PSTN line, this can be set to 0. Most users will want to set it to at least 3 so that the incoming CallerID data is captured. In rare situations you may need a slightly longer delay (5 should be more than enough).
10) PSTN Disconnect Detection:
Skip the PSTN Disconnect Detection section unless you know what type of PSTN disconnect signal(s) are used on your PSTN line and wish to change the settings so that those signals (and only those signals) are detected. Generally you should only tweak this section if the Sipura isn't properly detecting disconnected calls on the PSTN side. The "Disconnect Tone" is by default set to detect the "fast busy" signal usually sent after a call has ended in North America - you may wish to tweak this setting if the switch serving your PSTN line sends a different tone after disconnect.
11) International Control
Check the settings here - each country uses different values for PSTN lines. If you live in Australia, Canada, the United States or most other countries with modern telephone systems you probably won't have to change anything except perhaps the gain levels, so we'll only deal with them for now. The default values for both the SPA To PSTN Gain and the PSTN To SPA Gain are 0 (zero), and that's where you should leave them when you're first setting up the SPA-3000/3102. But just so you know, here's some information on those settings:
If the SPA to PSTN gain is set too low, the parties on the PSTN side of the connection will probably complain about your volume being too low, or will ask you to speak up or talk closer to the phone. If it is set too high, however, you are more likely to hear echo, and outgoing calls may fail because the level of DTMF tones sent by the SPA-3000/3102 will be too "hot" to register properly at the PSTN switching equipment.
If the PSTN To SPA Gain is set too low, you'll hear low volume levels on PSTN calls. If it's set too high, the people on the PSTN side of the connection will be more likely to hear echo (they may hear their own voices echoed back from your end). Also, any echo that has been reflected back to you will be heard at a higher volume level, and will therefore be more objectionable.
While the default levels are usually adequate, we found that boosting both values up to 3 produced a more "natural" sounding volume level in both directions. However, this is very much dependent on the characteristics of the PSTN line - if you're on a very short loop, values of 0 may be adequate for both settings, if on a very long loop you may need to go even higher than 3. The valid range is -15 dB to 12 dB in 1 dB increments (but just enter a numeric value, do not enter "dB" in the text field). If you have actual test equipment available you can fine-tune the volume settings for best results.
We'll talk a bit more about settings in this section under "Troubleshooting", below. For now, that's it. Submit and it should register and you should be able to use the PSTN port on the Sipura. Note that if you used host=dynamic in the FreePBX Trunk setting, the adapter may take some time to register, and it will not be accessible until it does (as discussed above). If you're in a hurry, you can power-cycle the adapter to force it to re-register (but make sure that you have first submitted your changes, and that the adapter's web page has refreshed!).

Troubleshooting

If you are connecting VoIP adapters back-to-back (SPA-3000 PSTN port to a line port on another device, perhaps because you are wanting to access a line from a commercial VoIP provider that insists you use a VoIP device that they provide) and if their device ever sends caller ID names with a single quotation mark, those calls will either simply ring and never answer, or will be answered but then disconnected after a few seconds, due to a bug in the SPA-3000 firmware. This problem usually presents itself if the other device is a Cisco ATA-186. You can either have your provider send you a newer device (they may charge you for this) OR you can disable CallerID passthru (which will throw away the incoming Caller ID). To do the latter, set PSTN CID for VoIP CID to NO, and you may as well set PSTN Answer Delay to 0 since there will be no need to wait for CallerID. A third option involves patching Asterisk itself but that is beyond the scope of this article (however, see the added comment at the bottom of this article).
If you have problems getting the SPA-3000 to register with your Asterisk box, try setting the Sipura up on a static IP address instead of letting your router assign it one via DHCP. Go to the System tab, and the Internet Connection Type settings:
DHCP: No
Static IP: (pick an address on your local network that will not conflict with your router's DHCP assignments, such as192.168.0.250)
NetMask: (usually 255.255.255.0 unless you have a large network)
Gateway: (usually either 192.168.0.1 or 192.168.1.1, unless your local net is numbered differently - for home users, this is generally the same address you use to get to your router's configuration page)
Skip down to Primary DNS: (you will probably want to put the same address as you used in Gateway here - usually both functions are handled by your router. Or, you can use a third-party DNS service such as OpenDNS).
While you are here you may want to set a Primary NTP Server so that your Sipura will know the time. Usually you can point this to any NTP server on your local network (such as your Asterisk box) and it will be close enough, but you could also use a public "pool" NTP server. But if you do this you will also want to set a time zone, and that setting is found under the "Regional" tab at the bottom of the page (if you have the latest firmware you can also include a Daylight Savings Time rule). It is NOT necessary to set up a time server to get this unit to operate as a PSTN gateway; I only mention this so that people who do want to set the time will know where the settings are.
There are two other settings under the PSTN tab, in the International Control section that you should be aware of if you are having problems. If you can't seem to get calls to go out (and in particular, if Asterisk reports that there are no circuits available), try setting the Line-In-Use Voltage to a lower value, such as 15. Some telephone companies use "pair gain" or "subscriber carrier" equipment to put multiple subscribers on the same loop. If you have the great misfortune to receive telephone service through such equipment, your on-hook line voltage may be less than 30 volts, and if that is true the Sipura will think the line is always in use unless the Line-In-Use Voltage setting is lowered. In the U.S.A. and Canada, nominal on-hook voltage is about 45 to 48 volts, and in that situation the 30 volt setting is correct. But if you are "served" using pair gain or subscriber carrier equipment (or are unsure of the telephone line voltages used in your locality), you may want to use a voltmeter to measure both PSTN on-hook voltage and off-hook voltage (the latter being the voltage on the line when a phone is taken off-hook), and set the Line-In-Use Voltage setting to a value about halfway between those two measured voltages. That's also a report that a particular fixed cellular terminal designed for making calls over GSM only produces 14 volts on-hook voltage - one user had to set the SPA-3102 Line-In-Use Voltage to 10 to get it to work properly with that device.
Also, the FXO Port Impedance default setting is 600 ohms is correct for many places in the world. Some places use 900 ohms. You really should try to find out the standard impedance setting for the PSTN line you are connected to, since an improper setting can cause some frequencies to be higher or lower in volume than others. Mismatched impedance can also be a source of echo and DTMF recognition problems. However, determining the best/most correct setting can be something of a black art, as this Cisco document illustrates. That said, if you don't know the correct impedance, the 600 ohm setting will generally work well, especially on loops of about one mile/1.5 km or less. If you have noticeable echo, try also the 900 ohm setting to see if that reduces or eliminates the echo.

Adding security

Once you have it working satisfactorily using the above instructions (test it with both incoming and outgoing calls), you can try adding additional security - most users seem to have had success doing this, but occasionally someone has problems, however it's easy to reverse the procedure if you do have any issues. Go to the adapter's PSTN Line tab and make the following changes:
In the VoIP-To-PSTN Gateway Setup section, change VoIP Caller Auth Method to HTTP Digest.
In the VoIP Users and Passwords (HTTP Authentication) section, change the following:
VoIP User 1 Auth ID: 1-pstn
VoIP User 1 DP: none
VoIP User 1 Password: XXXXXX (same as you used in trunk settings).
After making the above changes test to make sure that both incoming and outgoing calls still work as expected. That's all the security changes under the PSTN tab.
However, the Sipura's web pages are still wide open (unless you have already set up passwords) and if anyone on your local network goes there (or someone manages to hack their way in) they can go to the Sipura's web pages, and see and change all your settings. So you will probably want to password protect the settings pages. Note that there are separate user and admin passwords - you can set these in the System Configuration section of the page accessed through the System tab. BE CAREFUL - take your time and think about what you are doing here, because if (for example) you make a typo in a password and don't catch it, you could lock yourself out of your Sipura!

Additional information

If your adapter is at a remote location, or for some other reason you would like incoming calls on the PSTN line to ring through directly to "line 1" (the phone port) WITHOUT first passing through Asterisk (but still having the ability to send the call to voicemail if no one answers), set PSTN Ring Thru Line 1 to Yes, set PSTN Answer delay to whatever number of seconds delay you wish before the call goes to voicemail, and then set PSTN Caller Default DP to 1 and set Dial Plan 1 as (<:*extensionnumber@asterisk_ip:port>) - the * in front of the extension number tells FreePBX to send the call directly to that extension's voicemail without building a inbound route. So, incoming calls from the PSTN should ring directly into any telephones connected to the phone port, but if not answered in the specified time they will still get transferred to the extensions voicemail (thanks to "cyberglobe" for suggesting this in the IRC channel).
The reason we used a trunk name starting with the digit "1" is an attempt to make it the first sip trunk listed in /etc/sip_additional.conf (which seems to have trunk names sorted alphanumerically). This can help some users avoid a strange bug in Asterisk. In some versions of Asterisk, if there are one or more SIP trunks configured and Internet connectivity is lost, it becomes impossible to place any SIP call, including calls between SIP extensions that are on the same local network as the Asterisk server (and which therefore should be unaffected by the Internet outage - sadly, that is not the case)! Note that calls using protocols other than SIP are unaffected. There have been some reports that if the first SIP trunk (listed in /etc/sip_additional.conf) is accessible, Asterisk will be happy and continute to complete calls on the local network. Therefore, we suggested using 1-pstn so that the adapter would be the first SIP trunk and (assuming it's on the same local network as the Asterisk server) always accessible, even during an Internet service outage, thereby (hopefully) avoiding the issues when the Internet connection goes down. If you have more than one adapter, or don't need this attempted protection against Internet service outages, then you can change ALL instances of 1-pstn to some other string, but just make sure that ALL instances mentioned above are changed to the EXACT SAME string (otherwise the adapter will not be able to register with Asterisk).