An extension in asterisk is a user that is able to connect and use the system to place or receive calls, use voicemail and other features of asterisk. In order to define asterisk extension we should edit users.conf (Asterisk 1.4), iax.conf and sip.conf files. As you can see each extension starts with name in square brackets, like [100] here, next come some definition on what that extension is, its credentails and some asterisk specific options you have to setup. Let’s talk about each of this option:
- username is the username that this extension will use for registering with asterisk. Usually you will want to leave it same as name, which 100 in this case. The difference between name and username is that asterisk will use name to refer to extension through dialplan, but username is used to register with it. Leaving both of them the same will not make a mess out of your dialplan.
- secret is a password that extension will use to register with asterisk. Be sure to choose a good one, so nobody can guess it.
- host parameter can be either an ip address or “dynamic”. If you know your extension’s ip address and are sure that it will not change it, then you can fill it here, otherwise leave it as “dynamic”. The difference between setting ip address and “dynamic” is that asterisk will be able to place calls to extension even if it is not registered.
- nat stands for “Network Address Translation” which is a technique that allows a number of computers be connected to internet sharing the same ip address. For asterisk that means that there can be more then one extension sharing the same ip, so asterisk should take care of it.
- type parameter is used to define what extension can do in relation to asterisk. There are 3 values for this parameter: “user”, “peer’ and “friend”, “user” means that extension will be able to place calls only, “peer” means that extension will be used only for dialing out and “friend” means that extension will be used for both placing and receiving the calls. Usually you will have to set “friend” as extension type
- qualify parameter is used to monitor extension’s reachability, meaning that asterisk will send some info to extension from time to time with a hope to receive it back, so it can be sure that extension is alive.
- context parameter is one of the most important one. It tells asterisk where to place in dialplan incoming call from that extension.
There are a lot of other options you can set for your extension, you can check them in sample sip.conf file that is shipped with asterisk. Also those sample files are very well documented, so you can use it for reference.
Let’s take a look at the iax.conf . As you can see here we use the same parameters as in sip.conf, but extensions that will be defined here are using IAX technology to connect to asterisk.
Connect to asterisk console and check your extensions. If you have started asterisk before you have made changes to your files, then you have to tell asterisk that they are changed. If you have edited just one file, for example sip.conf, then you can simply type “sip reload”, as you can see asterisk re-read all the files that are SIP related. The same applies to IAX, just type “iax2 reload” and asterisk will re-read all the configuration files that are related to IAX.
On the other hand if you have edited a lot of files and you want to apply all the changes at once, you can type “reload” and hit enter, this will make asterisk to re-read all it’s configuration files at one. There is another command that makes asterisk re-read files it is called “restart”, this command is used when you want to restart your asterisk system. There are 2 ways to restart asterisk – first one - “restart now” will make asterisk drop all current calls and do immediate restart – obviously not the way we want it, the second one “restart when convenient” makes asterisk to wait when all the calls will be finished and then restart itself, definitely a better way to go.
Lets check what asterisk knows about your extensions. The “sip show users” command will show you all SIP extensions that asterisk handles, in a similar manner “iax2 show users” will show you what asterisk know about its IAX extensions. As you can see in addition to list of extensions list asterisk present you with a wide range of information like passwords, context used and many other information.
Written by Simon Calder: hotbutteredit.com