Calling via remote SIP Provider

Dear Members,

I have a question regarding the subject. Please take a look at the below example and kindly guide me.

Two Asterisk Boxes “A” & “B”, let say “A” be in USA and “B” be in UK
Trunk between the two boxes "IAX2"
Box “A” is connected with a SIP Provider and has a DID
Call between the two boxes is working fine.
Both Boxes have VOIP Phones configured with SIP

My Question:

I want to call from Asterisk “B” box to a US City Via SIP Provider connected with Asterisk “A”

Basically i would like to know how to transfer call over IAX2 trunk from one location to another and call out via SIP Provider making local calls between US and UK.

Kindly advise what to do and where i need to make the changes.

Thanks in Advance

Kind Regards

You don’t need to transfer the call you need to route the call.

If the trunk between the systems is in the from-internal context (as it should be), any calls matching the outbound routes on system A will be routed out system A’s resources. When a call arrives from system B the call must be formatted to match the outbound routes on system A.

With a little planning the routing can be elegant and transparent to the users.

You do not need to route the call from B to A as it adds latency.Instead configure on B the same “trunk” you have on A, but leave the registration empty. This will allow you making outbound calls. You can remove more stuff from the trunk definition which is not important for outbound only, like context or qualify.

Obelisk makes a good point. My comment is more relevant if you had POTS lines or a PRI in the other cities rate center.

With a SIP trunk you can send traffic from as many hosts as you need as long as you don’t register and mess with your inbound routing.

Good catch.

Ok, i added the same SIP trunk and configs in Server B, but nothing.

I added this line in /etc/asterisk/extensions_custom.conf

[from-internal]
exten=> _0.,5,Dial(SIP//${EXTEN:1}@,r)
;exten=> _X.,5,hangup()

and it gave me this, when i try to call any number

TRUNK Dial failed due to CONGESTION - failing through to other trunks"

You need to create an outbound route. btw, the line you added has a wrong priority - 5.

Thanks a lot for the replies. Let me explain my failure:

  1. I added the same SIP settings as of Server A in Server B and Created out-bound route , by selecting the SIP Trunk and adding the line
    [from-Internal]
    exten=> _0.,1,Dial(SIP/SIPTRUNK/${EXTEN:1}@,r)
    exten=> _X.,1,hangup()

  2. If i add IAX2 settings the calls reach to the Server A from Server B , but does not goes through SIP.

[from-Internal]

exten=> _0.,1,Dial(IAX2/IAXTRUNK/${EXTEN:1}@,r)
exten=> _X.,1,hangup()

And the Error appears with IAX2
"silence/1&cannot-complete-as-dialed&check-number-dial-again|noanswer") in new stack

Could you please explain exact places where i have to make the changes.

Thanks Again.

Regards

Where are you entering that custom code?

What are your trunk settings?

Why are you using the custom code and not an outbound route?

I am adding the Custom code to /etc/asterisk/extensions_custom.conf

Trunk for IAX2 is setup in /etc/asterisk/iax_additional.conf [Basically i added the trunk via GUI and not Edited iax_additional.conf as freepbx phrohibits that.]
Trunks Settings for IAX2 on server B are as under

[TrunkB]
host=
username=20000
type=peer
qualify=yes
secret=secret

SIP is not working entirely.

IAX2 is working but not going trough SIP of server A.

Regards,

You need to follow my directions.

Do not use any custom code.

Put your trunks in the from-internal context.

Use outbound routes module.

Dear Skyking, forgive me as i am little confused.

If you are asking for a custom context, or outbound route module, Where should i add it? In Server A or Server B ? coz i am using IAX2 Trunk Setup to connect two machines and the trunk are connected via extensions 20000 and 20001. With this setup internal extensions and Legacy pbxes connected with both Server A and B are working now when i try to call any external number from Server B , IAX2 comes in action and the Call is Simply going to Server B from Server A but then i become lost as i don’t know what to do e.g if i call number 123456, the call goes to Server A as IAX2/123456-1967 , Now my question is how to Forward this IAX2/123456 to SIP.

Where to put outbound route

Totaly Lost !!!

If you could advise any document or any video it would be highly appreciated.

He already told you not install any custom modules. Everything you are trying to do can be accomplished via stock FreePBX.
When configuring outbound route on B, forget about A, and configure routing to US numbers via the trunk you already defined. The only problem you might have could be the fact the SIP trunk at your provider is pinned to A’s ip address, so you might want to remove that restriction if it is in place. Other than that you might want read a little about configuring routes :wink:

Additionally you don’t need any extensions, just a trunk between the systems in the from-internal context.

Thanks Obelisk for the Reply. So as per your recommendation, I should:

  1. Remove all Custom Content
  2. Create the Same SIP trunk in B as in Server A , without Registration
  3. Create an outbound route on Server B and forget about sending it to A

and it should work right ?

If this is the case I will give it a try and will report back.

Thanks Agains and Regards.

You need to use registration unless you have static IP’s

Please note the context must be from-internal. Any calls arriving on the trunk will have access to the internal dial plan.

I would use an IAX trunk instead of a SIP trunk. With a single port (UDP 4569) you can send media and signaling.

I have a static IP from my SIP Provider. I am already using IAX2 Trunk to Connect two Asterisk Boxes. But, As per Obelisk, i need to create the same SIP trunk in Server B as i Have in Server A.

Isn’t this correct?

You need to separate your goals.

As Obelisk pointed out you can directly originate calls on server B if you setup an identical SIP trunk and not register it, just use it for outbound. That way you don’t even need server A to relay the traffic.

The IAX trunk is for extension to extension calling between the offices.

Dear Members,

I tried to install SIP Trunk on Server B, with and without registration, But no Luck. I deleted all of the custom configs.

Asterisk> sip show registry [shows unregistered, when i even try to configure SIP Trunk with Registration in Server B] Means my SIP Provider has my external IP binding Enabled.

I Even tried to Configure only Outbound route and selected IAX2 trunk, but no luck.

Any one with a document or tutorial or any website stating how to call via remote SIP or Longdistance Toll bypass, please advise.

Best Regards,

There is a chance your provider will not let you send traffic from an address that is not registered.

Send us the output of iax2 show peer xxx where xxx is the name of the trunk to server b.

Also send call trace when initiating a call from server b to server a.

The trunk on server a must be in from-internal context.

There is nothing special about intermachine dialing, you just need to make sure you are sending the correct digits that match the outbound route on the target server.

Here is the output from office server for a trunk that connects to my server at home. I can call both extensions and make outbound calls from this trunk:


maieast*CLI> iax2 show peer shhome


 * Name       : shhome
  Secret       : <Set>
  Context      : from-internal
  Parking lot  :
  Mailbox      :
  Dynamic      : Yes
  Callnum limit: 0
  Calltoken req: No
  Trunk        : No
  Encryption   : No
  Callerid     : "" <>
  Expire       : 3224899
  ACL          : No
  Addr->IP     : 107.x.x.x Port 4569
  Defaddr->IP  : 0.0.0.0 Port 0
  Username     : shhome
  Codecs       : 0x2 (gsm)
  Codec Order  : (gsm)
  Status       : OK (38 ms)
  Qualify      : every 60000ms when OK, every 10000ms when UNREACHABLE (sample smoothing Off)

maieast*CLI>

Here is the peer detials, (note if static IP use host = ip address, I am registering my system as I have port 4569 opened up for remote access.

disallow=all
allow=gsm
username=shhome
context=from-internal
secret=xxxxxxxx
host=dynamic
qualify=yes
type=friend

Asterisk>iax2 show peer ata-ala

  • Name : ata-ala
    Secret :
    Context : from-internal
    Mailbox :
    Dynamic : No
    Trunk : No
    Callerid : “” <>
    Expire : -1
    ACL : No
    Addr->IP : 192.168.x.x Port 4569
    Defaddr->IP : 0.0.0.0 Port 0
    Username : 9000
    Codecs : 0xe (gsm|ulaw|alaw)
    Codec Order : (ulaw|alaw|gsm)
    Status : OK (46 ms)
    Qualify : every 60000ms when OK, every 10000ms when UNREACHABLE (sample smoothing Off)

Plase note my Cell N0.is 1112982060

When i make call from Server B to Server A , below are the Logs on Server A

– Executing [1112982060@from-internal:5] Wait(“IAX2/9000-1345”, “1”) in new stack
– Executing [1112982060@from-internal:6] Congestion(“IAX2/9000-1345”, “20”) in new stack
== Spawn extension (from-internal, 1112982060, 6) exited non-zero on ‘IAX2/9000-1345’
– Executing [h@from-internal:1] Macro(“IAX2/9000-1345”, “hangupcall”) in new stack
– Executing [s@macro-hangupcall:1] GotoIf(“IAX2/9000-1345”, “1?skiprg”) in new stack
– Goto (macro-hangupcall,s,4)
– Executing [s@macro-hangupcall:4] GotoIf(“IAX2/9000-1345”, “1?skipblkvm”) in new stack
– Goto (macro-hangupcall,s,7)
– Executing [s@macro-hangupcall:7] GotoIf(“IAX2/9000-1345”, “1?theend”) in new stack
– Goto (macro-hangupcall,s,9)
– Executing [s@macro-hangupcall:9] Hangup(“IAX2/9000-1345”, “”) in new stack
== Spawn extension (macro-hangupcall, s, 9) exited non-zero on ‘IAX2/9000-1345’ in macro ‘hangupcall’
== Spawn extension (from-internal, s, 1) exited non-zero on ‘IAX2/9000-1345’
– Hungup ‘IAX2/9000-1345’


Calls are reaching Server A, but Not going out via SIP

I have a prefix 0 on Server A, Therefore on outbound route of Server B, i also used prefix of 0.

Please advise

Best Regards,
Darklord