VoIP: Cara Mengkonfigurasi Dial Out Melalui Trunk di Asterisk
Sumber: http://www.beardy.se/how-to-set-up-a-sip-trunk-in-the-asterisk-pbx
In my previous article we configured Asterisk with some SIP-devices, and created a basic dialplan so that they could dial eachother. We also created two additional extensions for test purposes. This time I will show you how to configure a SIP trunk, and add extensions in the dialplan so that the telephones can dial out through the trunk. And if you also have a telephone number (DID) associated with the trunk, for others to be able to dial your phones, through your Asterisk PBX.
[myphones] ; Call POTS numbers through Foo Provider (any number longer than 5 digits starting with 9) exten => _9XXXX.,1,Log(NOTICE, Dialing out from ${CALLERID(all)} to ${EXTEN:1} through Foo Provider) exten => _9XXXX.,n,Dial(SIP/fooprovider/${EXTEN:1},60) exten => _9XXXX.,n,Playtones(congestion) exten => _9XXXX.,n,Hangup()
There are a couple of things that might need explanation in the above. We use the Dial() application again, to dial the number we entered in our phone, but “${EXTEN:1}” uses the entered number, after the first digit, that is the meaning of “:1″. “60″ is the number of seconds to let it ring, until we give up and let Asterisk play congestion tones to us, increase the time value if you think it is too short. You also exchange “fooprovider” with the name of your real provider that you configured in sip.conf.
Test it
For our configuration to take effect we either have to reload it from Asterisk’s command-line interface, or restart Asterisk. To reload the SIP configuration and the dialplan, connect to the running Asterisk’s command-line:
asterisk -vcr
And run:
sip reload dialplan reload
Verify that your Asterisk server registers with your provider correctly:
sip show registry
If necessary, troubleshoot the registration, use the following Asterisk CLI commands:
sip set debug on
Now at last, test the configuration. Dial your Asterisk server from your mobile phone, and hopefully your first SIP telephone will ring. Also watch the Asterisk console and see the Log() notice that we added appear and make you smile.
If that works, proceed with dialing out to your mobile phone from any of your configured and registered SIP phones, remember to dial 9 in front of the actual phone number.
While the call is going on, run the following command to see the two channels that are created, and switched together in your Asterisk: One channel to/from your SIP phone, and one through your trunk, to your mobile phone:
core show channels
Full example reference configuration files
Here are the full contents of sip.conf and extensions.conf, from the previous article, with the configuration from this article added, making up a fully working, basic, but yet complete Asterisk configuration.
sip.conf:
[general] context=incoming allow=ulaw allow=alaw allow=gsm ; Register and get calls from Foo Provider, to our number 1-555-455-1337 register => 15554551337:password123@sip.provider.foo [fooprovider] type=friend secret=password123 username=15554551337 host=sip.provider.foo dtmfmode=rfc2833 canreinvite=no disallow=all allow=ulaw allow=alaw allow=gsm insecure=port,invite fromdomain=sip.provider.foo context=incoming ; ------------------------------------ [1000] type=friend secret=replacethis123 dtmfmode=rfc2833 callerid="First Phone" <1000> host=dynamic ; The device must always register canreinvite=no ; Deny registration from anywhere first deny=0.0.0.0/0.0.0.0 ; Replace the IP address and mask below with the actual IP address and mask ; of the computer running the softphone, or the address of the hardware phone, ; either a host address and full mask, or a network address and correct mask, ; registering will be allowed from that host/network. permit=192.168.1.0/255.255.255.0 context=myphones [1001] type=friend secret=replacethis321 dtmfmode=rfc2833 callerid="Second Phone" <1001> host=dynamic ; The device must always register canreinvite=no ; Deny registration from anywhere first deny=0.0.0.0/0.0.0.0 ; Replace the IP address and mask below with the actual IP address and mask ; of the computer running the softphone, or the address of the hardware phone, ; either a host address and full mask, or a network address and correct mask, ; registering will be allowed from that host/network. permit=192.168.1.0/255.255.255.0 context=myphones