[asterisk-users] Sharing my Asterisk + SPA3102/PAP2 setup: What I've learned in 1 week.

Rodolfo Alcazar Portillo rodolfo.alcazar at padep.org.bo
Thu Oct 16 07:31:24 CDT 2008


(Im' answering cc the list, so the knowledge keeps there, and maybe some more qualified 
answers become).

Am Mittwoch, den 15.10.2008, 18:00 -0700 schrieb Francisco del rosario:
> Hey Rodolfo... Need some help from you ...
> I need to know what hardware do I need to make SIP calls if I set-up 
> asterisk
> So the situation is that I have a PC and configure the software of my PC to provide 
> ASTRISK software... In terms of additional hardware, what do I buy ?

Im' a linux geek (many years), but an asterisk newbie (less than a week). Anyway, this is what 
I've get and done (my setup is fully experimental, just to learn, then scale to a full 35 
users/ 8 PSTN lines setup for starting). All of this are my notes. Previous: Definition of FXS, FXO:
http://www.3cx.com/PBX/FXS-FXO.html

NOTE: I assume no responsability, if you damage one equipment or person or cat. You are working with 
voltages which get sometimes higher as 100 volts. Dogs know nothing about telephones.

I have:

* studied a lot. DO THAT. if you find an error, you will not find the cause if you do not know 
where to look, where to change something, where to disable something.

* Someone ponted me to this document, which I started with. Nice to start.
http://www.viagenie.ca/publications/2007-03-apricot-asterisk-primer-blanchet.pdf

* Fedora 9 (my desktop and the same at home). IP: 192.168.1.141. IPTables disabled.
* installed asterisk as a fedora root user: 
	# yum install asterisk asterisk-sounds asterisk-voicemail

I bought:

* 1 Linksys SPA3102 (1 FXS, 1 FXO)
* 1 Linksys PAP2 (2 FXS)
* 3 old panasonic analog telephones
* 1 telephone line (also called POTS, PSTN) from my city provider.
* Connected between them (easier as connecting your microwave oven). Phones go to the FXS/PHONE ports. 
POTS/PSTN go to the WALL/LINE/FXO port. Ethernet ports go all to a hub. SPA3122 yellow port keeps 
empty.
* Programmed them first with a telephone connected (both Linksys features a menu with voices):
        Enter voice menu        ****
        Factory Reset           73738# 1

        IP Data                 CHECK   SET
        -----------------------------------
        STATICIP                100#    101# 1# 1
        WAN IP                  110#    111# 192*168*1*223# 1
        WAN MASK                120#    121# 255*255*255*0# 1
        WEB SERVER                      7932# 1# 1
        (Hangup: ATA will reboot)

(192.168.1.223 is the SPA3102, 192.168.1.222 is the PAP's. All IPs must match your office's)

* Once configured, programmed them with a web browser:

http://192.168.1.223

WAN Eth PORT
============
        ROUTER  WAN SETUP       Gateway: 192.168.1.1
                                Primary DNS: 192.168.1.1

FXS Ports: (Example for SPA3102 FXS Line)
=========================================
        SIP Port:       5060
        Proxy:          192.168.1.141 (my own computer)
        Display Name:   103
        User ID:        103
        Password:       green

FXO (Example for SPA3102 FXS PSTN)
==================================
        SIP Port:               5061
        Proxy:                  192.168.1.141
        Outbound Proxy:         192.168.1.141
        Use Outbound Proxy:     yes
        Display Name:           201
        User ID:                201
        Password:               green
        Dial Plan 8:            (S0<:192.168.1.141>)


        VoIP-To-PSTN Gateway Setup
        --------------------------
        VoIP-To-PSTN Gateway Enable:    Yes
        VoIP Caller Auth Method:        HTTP Digest

        VoIP Users and Passwords (HTTP Authentication)
        ----------------------------------------------
        VoIP User 1 Auth ID:            201
        VoIP User 1 Password:           green

        PSTN-To-VoIP Gateway Setup
        --------------------------
        PSTN-To-VoIP Gateway Enable:    yes
        PSTN Ring Thru Line 1:          no
        PSTN Caller Default DP:         8

        FXO Timer Values (sec)
        ----------------------
        PSTN Answer Delay:              0

        International Control
        ---------------------
        Line-In-Use Voltage:            30 (lowered to 25 for testing behind my current Panasonic)

* Installed twinkle, a softphone:
	Konto:          Asterisk
	Registrar:      192.168.1.141:5061
	Benutzer:       104
	Passwort:       green
	Auth-name:      104
	Zeitlimit:      3600

* Ok, now to configure asterisk in the fedora BOX:

# vi /etc/asterisk/sip.conf

        [101]; port 1 FXS on PAP2
        type=friend
        secret=green
        regexten=101
        qualify=1000
        nat=no
        host=dynamic
        context=padep
        registertrying=yes
        mailbox=101

        [102]; port 2 FXS on PAP2
        type=friend
        secret=green
        regexten=102
        qualify=1000
        nat=no
        host=dynamic
        context=padep
        registertrying=yes
        mailbox=102

        [103]; port 1 FXS on SPA3102
        type=friend
        secret=green
        regexten=103
        qualify=1000
        nat=no
        host=dynamic
        context=padep
        registertrying=yes
        mailbox=103

        [104]; my computer's softphone (ekiga, twinkle)
        type=friend
        secret=green
        regexten=104
        qualify=1000
        nat=no
        host=dynamic
        context=padep
        registertrying=yes
        mailbox=104

        [201]; call from FXS extension --> PSTN
        type=peer
        host=dynamic
        port=5061
        secret=green
        context=padep
        dtmfmode=rfc2833
        canreinvite=no

        [201]; call from PSTN --> 101
        type=user
        host=dynamic
        port=5061
        secret=green
        context=padep
        dtmfmode=rfc2833

* extensions.conf, commented, contains:

	[padep]
	; Everyone of this three groups is for one extension. Means:
	; - Connect the call to the extension
	; - wait 12 seconds
	; - go to voicemail
	; - Hangup
	exten => 101,1,Dial(SIP/101,12,rt)
	exten => 101,2,Voicemail(101)
	exten => 101,3,Hangup

	exten => 102,1,Dial(SIP/102,12,rt)
	exten => 102,2,Voicemail(102)
	exten => 102,3,Hangup

	exten => 103,1,Dial(SIP/103,12,rt)
	exten => 103,2,Voicemail(103)
	exten => 103,3,Hangup

	exten => 104,1,Dial(SIP/104,12,rt)
	exten => 104,2,Voicemail(104)
	exten => 104,3,Hangup

	;Voicemail
	; When the user dials 500, has his voicemail menu
	exten => 500,1,VoiceMailMain()

	; When an incoming call from PSTN-FXO-SPA3102 arrives, redirect to extension 101
	; From PSTN to 101:
	exten => s,1,Transfer(101)

	; When user dials 7#, starts an echo test
	exten => 7,1,Answer
	exten => 7,2,Echo()
	exten => 7,3,Hangup

	; to get external PSTN line Dial 9#, authenticate with 1111#
	exten => 9,1,Answer
	exten => 9,2,Authenticate(1111)
	exten => 9,3,Dial(SIP/201)

	; A simple test: dial 2# and get a "hello world" answer. I recorded my own voice, and put 
	; hello-world.wav in the sounds dir
	exten => 2,1,BackGround(hello-world)
	exten => 2,2,Hangup

	; Some notes
	;exten => _91XX!,11,Authenticate(1111); How to authenticate
	;exten => _91XX!,20,AGI(agi.bash); How to run an AGI script
	;exten => _91XX!,30,GotoIf($["${numero}" = "22"]?4:5); How to return the number from AGI script
	;exten => _91XX!,40,Dial(SIP/201/${EXTEN:${GLOBAL(TRUNKMSD)}}); Dial a number like 9125, behind my panasonixPBX
	;exten => _91XX!,50,Hangup; this is really complicated.

* Example for my AGI script:

	# cat /usr/share/asterisk/agi-bin/agi.bash 
	#!/bin/bash
	checkresults() {
	while read line
	do
		case ${line:0:4} in
		"200 " ) echo "$line" >> /tmp/agi.log
		         return;;
		*      ) echo $line >&2;;
	esac
	done
	}
RESULT='SET VARIABLE numero 22'
echo "$RESULT" > /tmp/agi.log
# former line is my log, to verify AGI runs....
echo "$RESULT"
checkresults
---------------------------------------------------------
That's all. I studied a lot, since saturday. You must do that, if you find an error, 
I'm sure you will not solve it, if you didn't studied.

> Where do I connect the phones? to PC ? How to connect Linksys with PC ?

When you buy the ATAs (linksys), you'll find that easy as connecting your TV. 
That's simple. Both include full-colored diagrams. 

> Do you have a visio diagram or powerpoint that you can share with me 

No. I prefer reading and writing. Read above. Read your equipment manuals. 
Look for google images of the ATAs. Is really simple. You are worrying without having
read anything... Read, google what you don't understand from my mail.

Good luck. Ask, if you need something more.

-- 
Rodolfo Alcazar
Responsable red y datos

Deutsche Gesellschaft für
Technische Zusammenarbeit (GTZ) GmbH

Programa de Apoyo a la Gestión Pública Descentralizada y
Lucha Contra La Pobreza - PADEP
Av. Sánchez Lima 2226
La Paz, Bolivia

Tel: +591 22417628 (121)
Fax: +591 22417628 (126)
Web: www.padep.org.bo
Email: rodolfo.alcazar at padep.org.bo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20081016/650adcd1/attachment.htm 


More information about the asterisk-users mailing list