Help with Asterisk and external FXO/FXS? (newbie)

My company is adding VoIP to our existing satellite network system. We will be using AudioCodes FXS at the remote satellite sites and AudioCodes FXO or Mediant at the hub site (which connects to the PSTN). We’ve previously had the FXO/FXS network working properly, but now we need to expand to using Asterisk to handling the routing, because we have too many remote (FXS) sites for the FXO/Mediant to manage.

I’ve compiled and installed Asterisk 1.2 on a linux 2.6 machine, and have modified the FXO/FXS to use Asterisk as the Proxy, and indeed when I try to place an outgoing from an FXS, I see packets being routed to the Asterisk machine. So far all good!!

However, I’m overwhelmed when it comes to what I need to do to configure Asterisk properly… I’ve read the relevant chapters of “Asterisk - the Future of Telephony” (hereafter referred to as TFOT), looked at extensions.conf and sip.conf, and looked at the Starting Out page on voip-info, but I’m lost regarding the basic things I need to configure to just place an incoming and outgoing call.

Frankly, the Starting Out page just makes my eyes glaze over!! almost three screens of links to other pages, and none of the entries is clearly what I’m looking for. Some of the questions that I need to answer are:

  • How, specifically, do I route an incoming call to a remote FXS?? Presumably I want to use an ‘exten’ entry in extensions.conf, but there isn’t a route() function… so the obvious

    exten => 703*,1,Route(172.18.10.23)

to get to the FXS (at 172.18.10.23) whose extensions are 70301-70324, doesn’t work like that - how does it work??

Similarly with outgoing calls; with the FXO/FXS environment, I told the FXS to Route 802xx to 172.18.100.23 (the FXO IP address), when when it called 80201, it indeed got a dialtone. How does that work via Asterisk??

  • What is Registering (from the FXO/FXS standpoint, and from Asterisk’s standpoint) ?? do I need to do that to make this work?? Does Asterisk register with the FXO/FXS, or they with it??

  • Relative to the Asterisk server, are the FXO and FXS(s) all peers?? users?? neither?? TFOT says “users place calls to us, while we place calls to our peers”… but I can look at this in different ways - to the user, they are never calling Asterisk, they’re calling the FXO/FXS. To the FXO/FXS, I guess it looks like they are always calling the server, so they are users… good… but wait!! The server will have to call the FXO to reach the PSTN, so it’s a peer!! or is it?? I’m very confused.

I’m sure these questions have been asked a thousand times before by other users, so if anyone wishes to just respond by posting links to other relevant conversations, that’s fine. Otherwise, any simple, clear clarification would be gratefully accepted!!! In the meantime, I’ll keep searching these forums, and I’ll try reading some of the voip-info tutorials to look for insight.

Dan Miller

Hi Dan,

Firstt of all, you have to figure out that asterisk is using channel for eveything. So the main step are :

  • Create a channel for your FXS interface and register it. You can do this in the SIP.conf file if you want to use the sip protocol.

  • You also have to create an channel for your FXO (for incomming call). Same thing, if you want to use the SIP protocol, you have to do this in the SIP.conf files.

Then, to route your the call, you have to use the Dial() function.

Ex: Dial(ChannelProtol/Channel name)
Dial(SIP/John)

For outgoing call, you have to create a trunk to your FXO interface. Using SIP.conf if you are using SIP protocol.

Then, you can create an extension like :

exten => 222,1,Dial(SIP/5555555@OutgoingTrunk)

So if a VoIp phone enter thoses digits (222) Asterisk will call the outgoing trunk an ask it to dial 555-5555.

I far as I know, you must register any device so Asterisk know how the communicate with the device.

The main point are there, if you need more specific info, ask.

Dimitri

thank you!! That is very clear and helps alot. I’ll try this out and post my results soon.

Well, okay, Here’s what I tried…

in sip.conf I added:

[general]
context=default ; Default context for incoming calls

[test_fxs]
type=friend
host=10.1.10.23
canreinvite=no

[fxo]
type=friend
host=192.168.1.23
canreinvite=no

in extensions.conf, I added:

[general]

exten => 80201,1,Dial(SIP/80201@fxo)
exten => 70301,1,Dial(SIP/70301@test_fxs)

[globals]
CONSOLE=Console/dsp
IAXINFO=guest
;TRUNK=Zap/g2 ; Trunk interface
TRUNK=SIP/fxo
TEST_FXS=SIP/test_fxs

When I reload asterisk (asterisk -vvvgc), I note (in the voluminous output) that both sip.conf and extensions.conf were loaded. However, “show channels” shows nothing…

So obviously I didn’t create the channels properly, which is why nothing else works. Aren’t the entries in sip.conf supposed to create those channels?? If so, what is wrong with my format??

One thing I may be doing wrong is editing the existing configuration files; maybe I should start with empty files which only have my data??

Can I just try:
exten => 70301,1,Dial(SIP/70301@10.1.10.23)

to tell Asterisk the IP address associated with that extension??

Well, I answered my own last question; that exten statement does nothing. When I try to dial in, the FXO sends an INVITE to Asterisk, containing:
From: sip:80201@fxo;tag=1c1320128932
To: sip:70301@asterisk;user=phone
and Asterisk just responds with $SIP/2.0 404 Not Found

next try:
I changed the entries in sip.conf to:

[test_fxs]
type=friend
secret=passwd
qualify=yes
nat=no
host=dynamic
canreinvite=no
context=fxs_general

[fxo]
type=friend
secret=passwd
qualify=yes
nat=no
host=dynamic
canreinvite=no
context=fxo_general

And created the required contexts in extensions.conf:

[globals]
CONSOLE=Console/dsp ; Console interface for demo
IAXINFO=guest ; IAXtel username/password
TRUNK=SIP/fxo
TEST_FXS=SIP/test_fxs

[context]

[incoming]
exten => 703XX,1,Dial(${TEST_FXS})

[fxs_general]
exten => 802XX,1,Dial(${TRUNK})

[fxo_general]
exten => 703XX,1,Dial(${TEST_FXS})

However, none of this had any effect on the result.
In your original message, you said to create a channel “and register it” … I don’t know what you meant there, nor does the chapter on Configuring SIP in TFOT.

I tried setting the fxo/fxs to register with the proxy server, and now I’m getting errors from Asterisk saying :
Dec 14 13:15:29 NOTICE[25142]: chan_sip.c:10815 handle_request_register: Registration from ‘sip:70302@test_fxs’ failed for ‘10.1.10.23’ - Username/auth name mismatch

for every existing port. Is this what you meant??

You should to the configuration step by step. For the moment, are you able to register two phone and call each other ?

If yes, you should first configure your outgoing trunk. Is your FXO device an external device or a digium PCI card ?

A channel mean a path to the device. So, if you want to communicate with a SIP phone, you have to create a SIP channel for the phone(SIP.conf). Then you configure your phone to register to the * server.

Same thing for the FXO device, you have to create a channel (SIP?) to the device then, you configure your device (assuming it’s external) to register. After this, asterisk know how to communicate with the FXO because there is a channel and by registring, the device tell asterisk that he’s and the end of the channel and listening.

You can now, route a call by using the Dial() fonction to the device because there is a path (channel) and the device is there and ready (registred).

The error you have :
Dec 14 13:15:29 NOTICE[25142]: chan_sip.c:10815 handle_request_register: Registration from ‘sip:70302@test_fxs’ failed for ‘10.1.10.23’ - Username/auth name mismatch

mean clearly that the registring process failes because the username/auth name or password is not valid.

I will post and exemple of a SIP.conf and extension.conf soon.

Okay, I defined two users in sip.conf:

[test_fxs]
type=friend
username=test_fxs
secret=passwd
qualify=no
nat=no
host=dynamic
canreinvite=no
context=outgoing

[fxo]
type=friend
username=fxo
secret=passwd
qualify=no
nat=no
host=dynamic
canreinvite=no
context=incoming

When I do “sip show users”, I see:
Username Secret Accountcode Def.Context ACL NAT
fxo passwd incoming No RFC3581
test_fxs passwd outgoing No RFC3581
… so this apparently worked.
I do have [incoming] and [outgoing] contexts in extensions.conf:

[context]

[incoming]
exten => 703XX,1,Dial(SIP/test_fxs)

[outgoing]
exten => 802XX,1,Dial(SIP/fxo)

After getting some help from AudioCodes, I fixed how they register, and I no longer get the authorization errors.

The fxo appears to be successfully registering, but I’m getting “401 Unauthorized” errors from * when the fxs tries to register.

In the meantime, “show channels” still shows nothing, even though the fxo has registered. What else do I have to do to get channels created??

Hi Dan,

I’m kind of curious what show channels is supposed to show. It comes back empty from my (up and running and working) asterisk server, so I don’t think that’s necessarily indicating a problem with your configuration.

I don’t know anything about audiocodes or its remote FXS features, so I can’t help there. But it might be helpful if you can set up a simple, local configuration to test with and validate that asterisk is running and configured properly. Then you can rule out any such basic problems before figuring out what’s up with the more complicated integration effort. Either a sip phone or an ATA with an analog phone would be best, but a softphone would also work.

With one of them configured (much like you configured the testfxs entry in sip.conf; note that you’ll have to figure out how to do the “client side” configuration for any of these devices as well; the sipura 2000/3000 (or its equivalent, the Linksys PAP2 are common ATAs with well-known Asterisk configurations; I’ve also gotten the soft phone sjphone to work from windows and linux), you should be able to run some simple tests to see if you can get in/out of your FXO port.

Your simple dial plan looks OK, though I might be tempted to try something really simple, like:.

[outgoing] exten => 1,1,noop(*** In extension 1) exten => 1,n,Answer exten => 1,n,Playback(goodbye) exten => 1,n,hangup
Then maybe try the echo application to make sure you’re getting 2-way voice.

You did try out the demo/sample extensions.conf that lets you call the digium server, right? :wink:

Post the output you get from the asterisk console when you dial any of the extensions in your dial plan for more review/comments.

Thanks for your suggestions, greyhound!!

Well… I can’t actually try your “exten => 1” idea directly, because I don’t have any phones which actually connect directly to the * box, or to the network that it’s on. I added your suggestion to my config file and restarted, but when I dialed into the system (which connects me to the fxo), I got a dialtone from the fxo, but dialing the extension just caused another “401 Unauthorized” error; it appears that the fxo/fxs are not responding to this message as they should.

I downloaded the SJPhone, but I’ll need to get a microphone for my computer before I can test it; I’ll try that tomorrow. that’s a good idea!!

Can I run the Digium demo even if I have no phones connected to * ??? I’ll admit, I didn’t even try; I’ll look into this further.

In the meantime, I will enclose the results of my attempt to dial into the system from outside and call my remote fxs (extension 70301). I hope this isn’t too long!!

<-- SIP read from 192.168.1.23:5060:
ACK sip:70301@192.168.1.123;user=phone SIP/2.0
Via: SIP/2.0/UDP 192.168.1.23;branch=z9hG4bKac1719517937
Max-Forwards: 70
From: sip:80201@192.168.1.23;tag=1c1719516457
To: sip:70301@192.168.1.123;user=phone;tag=as6e8cc14b
Call-ID: 1719516188212000211842@192.168.1.23
CSeq: 1 ACK
Contact: sip:80201@192.168.1.23
Supported: em,timer,replaces,path
Allow: REGISTER,OPTIONS,INVITE,ACK,CANCEL,BYE,NOTIFY,PRACK,REFER,
INFO,SUBSCRIBE,UPDATE
User-Agent: Audiocodes-Sip-Gateway-MP-104 FXO/v.4.60A.016.003
Content-Length: 0

— (12 headers 0 lines)—

<-- SIP read from 192.168.1.23:5060:
INVITE sip:70301@192.168.1.123;user=phone SIP/2.0
Via: SIP/2.0/UDP 192.168.1.23;branch=z9hG4bKac1719546181
Max-Forwards: 70
From: sip:80201@192.168.1.23;tag=1c1719516457
To: sip:70301@192.168.1.123;user=phone
Call-ID: 1719516188212000211842@192.168.1.23
CSeq: 2 INVITE
Proxy-Authorization: Digest username=“80201”,realm=“asterisk”,
nonce=“251a4f88”,uri="sip:70301@192.168.1.123",algorithm=MD5,
response="492c0a43a7307babc5dd45161c59f0e7"
Contact: sip:80201@192.168.1.23
Supported: em,100rel,timer,replaces,path
Allow: REGISTER,OPTIONS,INVITE,ACK,CANCEL,BYE,NOTIFY,PRACK,REFER,
INFO,SUBSCRIBE,UPDATE
User-Agent: Audiocodes-Sip-Gateway-MP-104 FXO/v.4.60A.016.003
Content-Type: application/sdp
Content-Length: 321

v=0
o=AudiocodesGW 1719510425 1719510360 IN IP4 192.168.1.23
s=Phone-Call
c=IN IP4 192.168.1.23
t=0 0
m=audio 4000 RTP/AVP 4 18 0 96
a=rtpmap:4 g723/8000
a=fmtp:4 annexa=no
a=rtpmap:18 g729/8000
a=fmtp:18 annexb=no
a=rtpmap:0 pcmu/8000
a=rtpmap:96 telephone-event/8000
a=fmtp:96 0-15
a=ptime:30
a=sendrecv

— (14 headers 15 lines)—
Using INVITE request as basis request - 1719516188212000211842@192.168.1.23
Sending to 192.168.1.23 : 5060 (non-NAT)
Found peer 'fxo’
Dec 15 09:43:19 NOTICE[27241]: chan_sip.c:10292 handle_request_invite:
Failed to authenticate user sip:80201@192.168.1.23;tag=1c1719516457
Reliably Transmitting (no NAT) to 192.168.1.23:5060:
SIP/2.0 403 Forbidden
Via: SIP/2.0/UDP 192.168.1.23;branch=z9hG4bKac1719546181;received=192.168.1.23
From: sip:80201@192.168.1.23;tag=1c1719516457
To: sip:70301@192.168.1.123;user=phone;tag=as6e8cc14b
Call-ID: 1719516188212000211842@192.168.1.23
CSeq: 2 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Max-Forwards: 70
Contact: sip:70301@192.168.1.123
Content-Length: 0


<-- SIP read from 192.168.1.23:5060:
ACK sip:70301@192.168.1.123;user=phone SIP/2.0
Via: SIP/2.0/UDP 192.168.1.23;branch=z9hG4bKac1719546181
Max-Forwards: 70
From: sip:80201@192.168.1.23;tag=1c1719516457
To: sip:70301@192.168.1.123;user=phone;tag=as6e8cc14b
Call-ID: 1719516188212000211842@192.168.1.23
CSeq: 2 ACK
Contact: sip:80201@192.168.1.23
Supported: em,timer,replaces,path
Allow: REGISTER,OPTIONS,INVITE,ACK,CANCEL,BYE,NOTIFY,PRACK,REFER,
INFO,SUBSCRIBE,UPDATE
User-Agent: Audiocodes-Sip-Gateway-MP-104 FXO/v.4.60A.016.003
Content-Length: 0

— (12 headers 0 lines)—
Destroying call ‘1719516188212000211842@192.168.1.23’

I have to set the default route on the * machine to be a particular machine other than what dhcp is telling it. The reason is that our company dhcp server doesn’t know about our engineering network, which is accessed via one of our machines here. On my Windows workstation, I manually add routes to our remote subnets via that engineering server, but the * server doesn’t know anything about that!!!

So, when it tries to connect to 10.1.10.23 (test_fxs), it doesn’t get any useful routing info… sigh…

This is a Linux issue, not an Asterisk issue…

If I still have problems after handling this, I’ll start a new topic with new information…