May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

Registering Asterisk with VOIP provider

The default configuration directory of Asterisk is /etc/asterisk/.

We will need to create the following files.

There are many many other configuration files, but only the above are required for minimal configuration.

All Asterisk config files are very similar to .ini files. This makes for simple machine and human usage. For example:


This would be considered the sample context and the keyword would be set to value.

Create each Asterisk config file.


logger.conf – Establishes the types of messages that you see on the CLI, Syslog or in discreet files. We will start by only sending messages just to the Asterisk CLI (console)

console = warning,notice,error

This instructs Asterisk to display the warning, notice and error message types. There is also a debug message type, however the amount of information that is generated is usually only interesting to a developer or someone attempting to diagnose a problem.

modules.conf – Instructs Asterisk which modules get loaded.


More advanced configurations of Asterisk can disable the loading of specific modules. For this configuration the autoloading of modules is the simplest method to get started.


; Useful CLI commands to check peers/users:
; sip show peers Show all SIP peers (including friends)
; sip show users Show all SIP users (including friends)
; sip show registry Show status of hosts we register with

sip.conf – This details the SIP configuration for Asterisk. We will configure two SPA-942s and use a fictional account at the VoIP Provider that we have selected.





The above contexts define some general configuration details, plus 3 SIP entities.

The general context instructs Asterisk to use the common SIP port of 5060 and to bind to any available network port. The disallow and allow directives define the specific codec(s) that are to be used. For this configuration we will utilize only G.711 uLaw.

The 100 and 200 contexts define our two SP942 VoIP Phones.

host=dynamic instructs Asterisk that our SIP Phones will be registering to us, perhaps because they use a dynamically assigned IP address.

secret is the shared secret that we will use to authenticate each phone.

context is where in the dialplan (extensions.conf) calls for this device will get sent. We will discuss this option in more detail below.

mailbox defines the voicemail box to use. context is the specific extensions context to be used for this device.

The [VoIPProvider] context defines the configuration as dictated by your VoIP Provider’s SIP Device Tutorial.

username and fromuser setup specific variables within the SIP protocol that allows authentication.

canreinvite=no is a specific option informing Asterisk to not attempt to re-invite or change any settings of the call. Re-invites are typically one cause of one-way audio or no audio at all, when behind NAT or firewalls.


extensions.conf – Extensions are groups of actions that instruct Asterisk exactly how to deal with your telephone calls. Extensions typically consist of a number of priorities containing multiple actions, which are grouped inside of contexts. Each context contains a logical grouping of actions (extensions) that make your dialing plan. The extensions concept of Asterisk is very flexible and powerful, which can be used to create complex telephony applications.

In this configuration, we establish two extensions for our SIP Phones and matching extensions to call out via NuFone using a layout that will provide the necessary foundation to build more complex dialplans in the future.

exten => s,1,Dial(SIP/${MACRO_EXTEN},25)
exten => s,n,Goto(${DIALSTATUS},1)
exten => ANSWER,1,Hangup
exten => CANCEL,1,Hangup
exten => NOANSWER,1,Voicemail(${MACRO_EXTEN}@default,u)
exten => BUSY,1,Voicemail(${MACRO_EXTEN}@default,b)
exten => CONGESTION,1,Voicemail(${MACRO_EXTEN}@default,b)
exten => CHANUNAVAIL,1,Voicemail(${MACRO_EXTEN}@default,u)
exten => a,1,VoicemailMain(${MACRO_EXTEN}@default)


exten => 100,1,Macro(phone)
exten => 200,1,Macro(phone)
exten => 4242,1,VoicemailMain(default)

exten => _NXXNXXXXXX,1,Dial(SIP/VoIPProvider/1${EXTEN})
exten => _1NXXNXXXXXX,1,Dial(SIP/VoIPProvider/${EXTEN})

exten => _NXXXXXX,1,Dial(SIP/VoIPProvider/1212${EXTEN})

include => stations
include => local
include => long-distance

The macro-phone context defines a group of priorities that creates a standard telephone for our PBX. Utilizing a Macro avoids a serious amount of duplicated configuration and reduces mistakes when adding or changing features. We implement the detection of Busy and No Answer situations using the ${DIALSTATUS} channel variable and the Goto action. Hopefully, this gives you some early insight as to the power of the Asterisk Extension Logic. We will discuss the many uses of Channel Variables and Goto’s in future articles.

The stations context establishes the 100 and 200 extensions of our PBX. Future SIP Phones would get added into this context. We call the ‘phone’ Macro to provide each telephone similar a featureset without any duplicate configuration. We also define extension 4242 which allows you to check your voicemail.

The long-distance context establishes a matching pattern extension that matches any valid 10 or 11 digit telephone number. This is the standard method to dial long distance telephone numbers from the US or Canada.

The local context creates a matching pattern extension for local dialing. In this example we add ‘1212′ before sending the call out to match what NuFone expects. You will need to add your own local area code to make this code relevant for your situation.

The users context is a landing context. If you recall, in sip.conf we instruct Asterisk to use the users context for our two SIP phones — meaning calls from your SIP Phones will land in the users context. In this simple configuration, we include the stations, local and long-distance contexts. More advanced configurations could have other similar landing contexts to restrict certain phones from calling long-distance or to only call other stations, etc.

voicemail.conf – As you may have guessed, this file configures the voicemail boxes for your PBX.

[email protected]
emailsubject=New Voicemail message ${VM_MSGNUM}
emailbody=A ${VM_DUR} long message from ${VM_CALLERID}, on ${VM_DATE}\n
emaildateformat=%A, %d %B %Y at %H:%M:%S

100 => 100,Mailbox 100,[email protected]
200 => 200,Mailbox 200,[email protected]

The general context defines the most common settings.

You need to set a valid serveremail value to ensure your mail agent will deliver the email.

attach=yes tells Asterisk you want to attach the actual voicemail recording to the email that gets sent out.

fromstring is the From header that the email will appear to be sent by.

The emailsubject, emailbody and emaildateformat are highly configurable using built in variables.

The default context defines the actual mailboxes using the format of:

mailbox => password,Mailbox Name, Email Address to send voicemail notification

Set valid email addresses to ensure proper email delevery.

You can now start Asterisk for the first time.

voip:/etc/asterisk# asterisk -vvvgc

Leave Asterisk running. Lets now configure the twp SPA-942s to communicate with your Asterisk PBX.

Determine the IP Address of the SIP phone. The simplest way is to press the configuration button and scroll down to the network option (or press 9).

We will be configuring these SIP Phones using their web interface. Point your favorite web browser to the IP address you just determined.

In the upper right hand section click on the Admin Login link and then click on the advanced link. This will provide more configuration options, which we will need to utilize.

Starting on the SIP tab, set Handle VIA Received and Handle VIA rport to Yes in the NAT Support Parameters. Handle VIA Received instructs the SIP phone to respond to the appropriate server, which called VIA in the SIP Headers. Handle VIA rport tells the SIP phone to communicate using the ‘rport’ value. These two settings assist the SIP Phone in dealing with NAT and/or Firewall situations.

On the Phone tab, set a Station Name and set the Short name on Line Key 1 to “Line 1″, otherwise the default setting may confuse less technically savvy users, in my opinion.

On the Ext1 tab, set the Proxy to the IP or hostname of your Asterisk box and set both the User ID and Password to 100 (200 for the second SIP Phone). In the Audio Configuration section ensure that G711u is selected.

Click on Submit All Changes and your phone will reboot. When it comes back on-line you should be registered with your Asterisk PBX and can call to the other SIP Phone or out via NuFone.

I hope this has provided you with a solid understanding of how to compile and configure a simple installation of Asterisk. Granted this is not by any means a comprehensive guide to Asterisk. However, this How To should get you up to speed, allowing you to deploy a more advanced configuration of Asterisk without such a steep learning curve.

Old News

Get Started

Asterisk is an open source PBX designed to switch calls, manage routes, enable features and connect callers with the outside world over IP, analogue and digital connections. This guide describes how to configure your Asterisk installation to work with your Localphone account.

To view this guide with your Localphone account details filled in, please log in or register.

This guide should work for Asterisk version 1.2.4 and above. You will need to edit two configuration files on your Asterisk server; sip.conf and extension.conf. These files are usually located in the directory /etc/asterisk/.

  1. Check the sip.conf Asterisk Configuration File

    Open sip.conf and check that the [general] section contains the following configuration values:

    port      = 5060
    bindaddr  =
    qualify   = no
    disable   = all
    allow     = alaw
    allow     = ulaw
    dtmfmode  = rfc2833
    srvlookup = yes
  2. Register with the Localphone Service

    Next, configure Asterisk to register with the Localphone service. This will enable Localphone’s proxy to route incoming calls to your Asterisk server.

    register => [SIP ID]:[SIP Password][SIP ID]
  3. Create the Localphone Account

    Add your Localphone service to Asterisk. Add the following to the bottom of sip.conf:

    type        = friend
    insecure    = very
    nat         = no
    canreinvite = no
    authuser    = [SIP ID]
    username    = [SIP ID]
    fromuser    = [SIP ID]
    fromdomain  =
    secret      = [SIP Password]
    host        =
    dtmfmode    = rfc2833
    context     = localphone-in ;extensions.conf context for inbound calls
    disallow    = all
    allow       = ulaw
    allow       = alaw
  4. Test Your Configuration

    Check that your Asterisk server has successfully registered with the Localphone proxy. At the Asterisk console enter the command sip reload, followed by the command sip show registry. The output should resemble the following:

    localhost*CLI> sip reload
     Reloading SIP>
      == Parsing '/etc/asterisk/sip.conf': Found
      == Parsing '/etc/asterisk/users.conf': Found
      == Parsing '/etc/asterisk/sip_notify.conf': Found
    localhost*CLI> sip show registry
    Host                 Username  Refresh  State       Reg.Time  [SIP ID]  105      Registered  Sat, 2 Jan 2010 03:40:54
  5. Create the Incoming Context

    Configure Asterisk to send calls to your chosen device(s) when a call is received via your Localphone account. You do this by creating the context specified in step #3. Add the following to extension.conf:

    exten => [SIP ID],1,Dial(SIP/sipphone,60,tr) ; phone must be registered
    exten => [SIP ID],2,Hangup
  6. Create the Outgoing Context

    Now Asterisk is able to receive calls, we need to set it up to make outbound calls. To do this you need to create an outgoing context similar to [localphone-out] defined below.

    exten => _9.,1,Dial(SIP/${EXTEN:1}@localphone-out,30,tr)
    exten => _9.,2,Playback(invalid)
    exten => _9.,3,Hangup

    The above example assumes the user of the phone connected to your Asterisk server presses 9 to get an outside line.

    Please note that the [localphone-out] context will need to be included in the dial-plan for the individual device(s) that you intend to use with the Localphone service.

Following the steps above, you should now be able to connect to Localphone and make and receive calls. For further information about configuring Asterisk, or for help with troubleshooting, please see:

This guide is provided for assistance. If you discover any errors in this page, please send us your comments and we will update the guide as soon as possible.



Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy


War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes


Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law


Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D

Copyright © 1996-2021 by Softpanorama Society. was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to to buy a cup of coffee for authors of this site


The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: March, 12, 2019