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
  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
    • 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
    • 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
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 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
      • 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, 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:
      host=[spa ip address - e.g]

  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.


  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

  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:

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

  3. I am living in London (uk) and I make lots of calls For Personnel as well as business purpose. So I am looking for cheap phonel calls plan Service provider. Please suggest me something about it. Like this Service provider

  4. 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

  5. We provide Phony Systems to businesses across the UK, working with world-class manufacturers to offer a full range of telephony systems that can be tailored to your needs. We cater for businesses of any size, and offer a diverse product range from basic two-user phone systems through to multi-feature systems.

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

    Metropolitan Networks Ltd

  7. 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!

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