Monday, January 3, 2011

Dialing via phone line through VoIP

Happy new year! :-)

It's time for my final installment of this tutorial, finally what we've been heading towards -
calling from a cellphone via a cheap PSTN (Public switched telephone network) in simple words, land line.

I assume you have:

  1. The SPA3102 unpacked and ready to setup.
  2. A router which has at least a one free RJ45 jack.

Setting SPA3102 IP


The first thing that needs to be done is to setup a LAN IP for the SPA3102 so trixbox
will be able to access it directly through LAN.

  1. Connect the SPA3102 to a power outlet.
  2. Connect the RJ45 supplied with the SPA3102 via the Ethernet jack and to a computer:

  3. In the computer, open up a browser and go to the SPA's Web based
    configuration UI via http://192.168.0.1
  4. Once there, click Wan Setup and then Advanced at the top of the page:



  5. Once in Wan Setup make the following changes:

    • Connection type - Static IP, the IP entered here will remain permanent.
    • Static IP - An IP of your choosing which matches your router's IPs,e.g, my router gives IPs formatted 10.x.x.x (due to the netmask255.0.0.0 and it's gateway),
      I chose 10.0.0.8.
    • Gateway - Your router's IP, to figure that one outyou can type
      ipconfig in cmd and get the Default Gateway from
      the NIC you're getting your network from.
    • Netmask - Match to your router's netmask, mine is 255.0.0.0
    • Enable WAN Web Server - Set this to Yes since we'll need access to the web ui.

    Click the Submit All Changes when done:


  6. Disconnect the RJ45 cable from both the computer and the SPA.
    Reconnect the cable in the following manner:
    From the SPA's Internet jack to a free ethernet
    port in router:




When this is done, test out the connection, try and access from your browser
to the IP you've setup e.g http://10.0.0.8.
In case you fail, redo the steps above.

NOTE: If you by mistake misconfigure you SPA3102 and unable to connect to it at all you can reset it using a phone - connect
a phone to the phone jack in the spa, and hit **** 73738# 1
this will reset the device.

SPA 3102 Configuration


Now we're going to configure the SPA3102 so asterisk will be able to connect to it.


  1. Open a browser and go to http://[your-spa3102-ip]/admin/voice/advanced (e.g http://10.0.0.8/admin/voice/advanced) or alternatively
    go to the Voice tab, then choose Admin Login and Advanced on the top right corner of the page:

  2. Now, we need to disable the port which corresponds to the phone jack in the SPA
    because we don't want to get any connected phone ringing when a call comes in.
    Go to the Line 1 tab and set Line Enable to No:

  3. Head into the PSTN Line tab and set the following settings:

    • Proxy and Registration
      • Proxy - This is the trixbox IP you've setup in section 2 of this tutorial, mine is 10.0.0.4.
      • Ans Call Without Reg - Set this to yes.

    • Dial Plans
      • Dial Plan 1: (x.<:@gw0>)

    • VoIP-To-PSTN Gateway Setup
      • Line 1 Fallback DP: 1
      • VoIP Caller Default DP: none

    • FXO Timer Values (sec)
      • PSTN Answer Delay: 1

    • PSTN Disconnect Detection
      • If you live in israel set Disconnect Tone: 400@-6,400@-19;3(.5/.5/1+2)

    • International Control
      • FXO Port Impendance: 220+820||120nF (Works well in Israel, leave as is if problematic)
      • PSTN To SPA Gain (I've changed to to increase volume coming from the land line): 12

  4. Now, click Submit All Changes.


Adding SPA3102 to trixbox

In this stage we'll let trixbox know of our SPA3102 by adding it as a 'trunk'.
A trunk is basically a device which gives certain VoIP service.

  1. Open up the trixbox web ui using http://[trixboxip] e.g http://10.0.0.4, go to
    PBX>PBX Settings via the top menu:
  2. From the left menu choose Trunks and the on the right choose Add SIP Trunk:



  3. Fill in the following fields:
    • Outbound Caller ID: SPA3102 (or anything you want, either way it's not really used)
    • Maximum Channels: 1
    • Dial Rules: X. (including the dot at the end)
    • Trunk Name: SPA3102
    • PEER Details:
      canreinvite=no
      context=from-internal
      host=[spa ip address - e.g 10.0.0.8]
      nat=no
      port=5061
      type=friend
      qualify=yes
      dtmfmode=rfc2833


  4. Click Submit Changes when done.
  5. In order to use the newly added trunk we'll create an Outbound route which will say the following: each number which begins with 0 will be passed on to the SPA3102.
    Go to Outbound Routes from the left menu and fill the following fields:

    • Route Name: bezeq (anything you like)
    • Dial Patterns: 0. (zero dot)
    • Trunk Sequence: SIP/[trunk name] - e.g SIP/SPA3102

  6. Commit the new configuration and restart asterisk by clicking the orange
    Apply Configurations Settings bar at the top of the page and confirm restart:




Calling Cheap

Now we're set to go, open up sipdroid and dial any number which begins with a zero,
call your friends and tell them what you just accomplished.

Opening NAT Ports

If you wish to use this system outside of your local home network (which is the whole point)
and you are behind NAT (which you most likely are) then you'll have to open the following ports
and direct them to trixbox's IP address:

  • 5060 UDP - This is the standard port for the SIP protocol.
  • Range: 10000 - 20000 UDP - RTP ports, it's the protocol responsible transferring voice, if
    these ports are closed you or the party you call won't hear a thing.

Final Words

Thanks for bearing with me on this long tutorial, if you've reached thus far it means you've
accomplished something pretty cool.
If you like this tutorial pass it on.
If you encounter any problems don't hesitate to leave comments and ask.

Cheers, Max.

6 comments:

  1. Hello,

    I've tried to install elastix's module and I have a problem with external extensions. Can you help me?
    Do you have a private email, please ?!

    Ando, Israel

    ReplyDelete
  2. Hi, I'm not really aquainted with external
    extensions other than the SPA3102.

    I suggest you take a look in the
    Asterisk: The Future of Telephony book which is
    available for free here:
    http://astbook.asteriskdocs.org/en/2nd_Edition/asterisk-book-html/asterisk-book.html

    Also, I found irc channels helpful, (mIRC or any other irc client is required): irc://irc.freenode.net/asterisk

    ReplyDelete
  3. The blog was absolutely fantastic! Lot of great information which can be helpful in some or the other way. Keep updating the blog, looking forward for more contents...Great job, keep it up..
    Long distance calls

    ReplyDelete
  4. It’s really very informative that I wanted ever, thanks for this.

    Metropolitan Networks Ltd

    ReplyDelete
  5. Hey Max!

    I have completed 2 out of three tutorials. The third one i will start when i get my hands on the SPA3102. I am facing a problem with these two though. After creating 7 extensions, I tried it on my home network. Works a charm! Then i skipped to the last part of tutorial 3: Opening NAT Ports to use only the extensions outside the home network. But I am not able to get it working. No PSTN connected yet. I think I made a mistake while opening ports, so I am posting the data i entered here. Please check and help me out. Thanks

    Name: Port 1
    Protocol: UDP
    Source IP: 192.168.0.X - (the one i use for trixbox)
    Destination IP: - (predefined)
    Source Port: 5060
    Destination Port: - (Again, predefined)
    Action: ACCEPT

    Name: Port 2
    Protocol: UDP
    Source IP: 192.168.0.X - (the one i use for trixbox)
    Destination IP: - (predefined)
    Source Port: 10000
    Destination Port: 20000
    Action: ACCEPT

    Regards from India!

    ReplyDelete
  6. Great post ! If you want to Buy online Quality International Calls
    You can also try : Buy online Quality International Calls

    ReplyDelete