Configuring IP phones as Asterisk PBX extensions

A first look at the SIP.CONF file

It is assumed here that your IP phones all use the SIP protocol to register, make and receive calls. Before an IP phone can connect to Asterisk and operate as an extension, it is necessary to configure user account details on the Asterisk server. The configuration file of greatest relevance in this process is SIP.CONF. In this file you define some general server related settings – such as the port that your Asterisk server will listen on – and the user accounts and other details for each IP phone.

It is worth noting that Asterisk also allows user settings to be defined in the configuration file called USERS.CONF, but the format of the user data in both SIP.CONF and USERS.CONF is largely identical so the descriptions that follow only refer to SIP.CONF. You may find that some Asterisk GUI interfaces actually make updates to SIP.CONF for the general server settings and to USERS.CONF for the users and their telephone extensions.

For the impatient…

Try scrolling to the bottom of the sample SIP.CONF file where you should find some example configurations (commented out) for about four different types of IP phone or softphone. Take a copy of the definition for [polycom] including all the entries down to but not including “progressinband”, and paste it into the bottom of the file. Uncomment it, and change the device name from [polycom] to whatever extension number you want to use – for example [4001]. Now adjust the settings for username and secret – set username to the same extension number as the device name. Set secret to a complex password containing letters and digits that cannot be easily guessed, (you will need to put the same one into the phone in a moment).

[4001] type= peer
context= from-sip
host= dynamic

Save the changes to SIP.CONF, open the Asterisk CLI and enter the command “sip reload”.

On the IP phone, you will need to configure the default SIP account – depending on the make and model of phone, this may be called “Account 1”, “Identity 1”, “Line 1”, “User 1” or sometimes “Global SIP Account”. Set the account password to the same one that you just used for the “secret” parameter above. The extension number (4001 in the example above) should be given for all and any fields called “Username”, “Authentication name”, “Authentication number”, “Phone number”, “Account”, “SIP User ID” or “Authenticate ID”. Set the field called “SIP Domain”, “Registrar”, “SIP Server” or “Proxy Server” to the IP address of your Asterisk server; do the same for the “Outbound Proxy”/”Outbound Proxy Server” field. Reboot the phone. If you are lucky, the IP phone will now register with Asterisk. To be able to make and receive calls you will need to configure appropriate dial plan contexts, but that is not explained here.

…and beyond

That was the quick-start guide and while it might be enough to get one extension phone registered, it is unlikely to be adequate over the longer term. Certainly, if you want to get the most out of Asterisk and avoid future problems it is much better that you get a more fundamental understanding of the way Asterisk supports IP phones. The text that follows identifies those elements within SIP.CONF that are most relevant to IP phone registrations on an Asterisk PBX. We also provide information and examples for the settings on some commonly used IP phones.

A more leisurely look at the SIP.CONF file

General settings

At the beginning of the SIP.CONF file you will find a large section that starts with the line [general]. Within this section, various server related parameters are set and also some system-wide defaults can be defined that are used in later sections. We are not going to attempt to describe every setting here, but will take a look at some of the settings most relevant to the successful integration of IP phones as local extensions.

port and bindaddr
The settings for the parameters “port” and “bindaddr” are used to tell Asterisk which port and which ethernet interface to listen on. The default port for SIP is 5060 and unless you have a good reason to change it, just leave it as 5060. The “bindaddr” can be set to if you want Asterisk to listen on all interfaces/IP addresses.

SIP Domains
Asterisk allows you the option to support or not support SIP domains.
If you are trying to get an IP phone to register with Asterisk and the registration is being rejected, it may be because the SIP domain being used by the phone does not match any of the SIP domains defined for Asterisk. Even if the phone is configured to register at an IP address rather than a host or domain name, you may still need to add the IP address as a SIP domain in Asterisk (unless SIP domains are completely disabled).

Asterisk SIP domains are explained in detail here.

We recommend the use of a proper SIP domain name when registering IP phones on Asterisk rather than the lazy option of using the IP address of the Asterisk server. Named SIP domains have the following advantages:

  • They are easier to remember and program into the phone
  • They provide easier maintenance, especially if you ever want to move the Asterisk server to a new IP address
  • They allow improved security for Asterisk
  • DNS-SRV client-side redundancy can be accommodated

However, if you do not have access to DNS or you don’t know how to set up DNS, then you’ll have to stick to using IP addresses.

SIP Peer and User settings for IP phones on the local network

The definitions for IP phones are generally located towards the end of the SIP.CONF file. It is usual to set the peer type to “friend” and the value for “host” to dynamic. This allows an IP phone with the correct user credentials to register on the Asterisk server from any IP address.

A typical definition for an IP phone being used as a local extension would be similar to this – in this example the extension number is 4001:

[4001] type= peer


Some of the settings given here will need to match settings that you program into the IP phone.

Configuring IP phones that are on the local network

Here we describe how to connect an IP phone to Asterisk as a local extension, assuming that the IP phone and Asterisk are on the same subnet or at least are on subnets that can easily reach each other without having to pass through a firewall or NAT.

Setting the SIP Domain name on the IP phone

Different makes of IP phone use different names for the SIP user account settings.

Please click here to view a list of the settings on various makes of IP phone. Find the setting that is used on your IP phone for the following:

SIP Server/Proxy Server/Proxy/Registrar

If your Asterisk server is using SIP Domains, then this field must be set to a value that matches one of the SIP Domains known to Asterisk. You can check what domain names Asterisk is using by typing the command “sip show domains” at the Asterisk CLI.

If your Asterisk server is not using SIP Domains, then you may set this field to the IP address of the Asterisk server.

Setting the location of the Asterisk server

This should already have been achieved when you set the value for “SIP Server” above. However, if for some reason you were unable to define a domain name that could be resolved to an IP address, then it is also possible to force the phone to send all SIP requests to a particular network location by entering the IP address in the “Outbound Proxy” field.

Setting the User Account ID and Password

Find the fields on your IP phone where you can set the “Authentication Username”, “Password” and “Main Account ID” – it may help to re-open the page on this link again to see what the field is called on your make of IP phone.

Set the password to the same value that you assigned to the “secret” parameter in SIP.CONF. Set both the “Account ID” and the “Authentication Username” to the extension number that you set in SIP.CONF. If you are uncertain about the values you used when configuring Asterisk, these can be checked easily by typing “sip show users” at the Asterisk CLI.

Save settings and force the IP phone to register

Most IP phones require a Save button to be clicked (assuming you are using the web interface). The new settings do not usually take effect immediately – for most makes of IP phone a reboot is needed, but the Snom phones are more advanced and can be re-registered by clicking the appropriate button on the web interface.

Now check if the IP phone has registered with Asterisk – go to the Asterisk CLI and type “sip show peers”. You should see a list of all the extensions you defined in SIP.CONF. If a phone has registered correctly, then it will have an IP address in the column “Host”.