A step-by-step guide on binding a SIP number to Elastix (FreePBX, Asterisk) using the example of a Megaline iDPhone provider
- From the sandbox
Good day to all.
IP telephony is generally quite an interesting thing, but for a person who has encountered such a system for the first time, the setup process may seem frighteningly difficult. You can read more about how and why to install software IP-PBXs elsewhere (there is plenty of information on this issue ), but I wanted to dwell in more detail on the issue of its integration with the city SIP numbers of one Kazakhstan provider.
I think it’s worth mentioning right away that I have nothing to do with this provider (except that I am a user of their services).
What we need:
- Elastix 2.4.0 Stable 32 bit
- software background zoiper or native client for Android
- Telnet / SSH Client
- SFTP client
- second network card
- Kazaktelecom - Kazakhstan Internet and SIP provider
- Megaline - ADSL Internet from Kazaktelecom
- ID Phone - SIP-telephony from Kazaktelecom
So. Our company received at its disposal 2 SIP-numbers with 2 lines on each. At hand was an old system unit on which Elastix was successfully installed. And then the fun began.
Part 1. Network setup.
A bit of theory: to ensure the quality of communication, Kazaktelecom divides the physical ADSL channel into 2 logical channels that do not affect each other. It turns out that with the ADSL modem two interfaces will come out, one for the Internet, the other for ID Phone (SIP). Accordingly, Elastix must also be connected to both of these interfaces. But here one more problem arises. ID Phone distributes the IP address via DHCP, so the interface on Elastix must be configured to receive IP via DHCP. The second interface is used to access the Internet, respectively, should have Default Gateway - the main gateway. It turns out that the main gateway is registered on both interfaces. To solve this problem, it was decided to use a second network card. The idea is that the second network card connects the asterisk directly to the ADSL modem in the ports for ID Phone. The network card receives a dynamic IP address of type 10.20.130.11. The problem is that in this situation, the Elastix server acquires two Default Gateways. One is already previously registered on Megaline 192.168.100.1 and the second is received via DHCP from the ID Phone network. Traffic starts to wander, nothing works. How to be
First of all, go to the settings of the ADSL router (in my case 192.168.100.1 ) and turn off DHCP for one of the Ethernet ports (in my case the 4th), into which Elastix will be connected directly from the second network card. On my TP-Link TD-W8951ND, it looks like this:
Connect the second network card (if you have not done it before) and connect to the Elastix server via SSH, and then enter the command
The result looks something like this:
We see that the device called eth0 has a static IP (in my case it is 192.168.100.6 ), through which we connect to the web interface. This means that the network card that we are going to configure to work with Kazaktelecom's DHCP is eth1 .
It turns out, unlike Windows, Linux can be taught to receive by DHCP not everything that is offered, but certain parts. Such as IP address, domain, DNS server, etc. BUT NOT Default Gateway! To do this, using the SSH client we connect to the server and create a file called
where X is the number of your network card. In my case it is
send host-name "asterisk"; request subnet-mask, broadcast-address, time-offset, host-name;
Now in the SSH client we restart the network service with the command
service network restart
After that, the network card will receive the address via DHCP, but without the default gateway. Next, create a file
in which we write:
GATEWAY0=192.168.100.6 NETMASK0=255.0.0.0 ADDRESS0=10.0.0.0
Further. We change the contents of the files:
/ etc / sysconfig / network-scripts / ifcfg-eth0
# Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller DEVICE="eth0" BOOTPROTO=static HWADDR=ваш mac-адрес ONBOOT=yes TYPE=Ethernet IPADDR=192.168.100.6 NETMASK=255.255.255.0 NOZEROCONF=yes BROADCAST=192.168.100.255 NETWORK=192.168.100.0 DEFROUTE=yes NM_CONTROLLED="no" NAME="eth0" # # the GATEWAY is sometimes in: /etc/sysconfig/network GATEWAY=192.168.100.1
/ etc / sysconfig / network-scripts / ifcfg-eth1
# Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ DEVICE=eth1 BOOTPROTO=dhcp ONBOOT=yes HWADDR=ваш mac-адрес TYPE=Ethernet IPADDR= NETMASK= NOZEROCONF=yes NM_CONTROLLED="no"
/ etc / sysconfig / network
NETWORKING=yes NETWORKING_IPV6=no HOSTNAME=host.asterisk GATEWAY=192.168.100.1 DNS1=192.168.100.1 DNS2=22.214.171.124
/ etc / hosts
# Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost 192.168.100.6 localhost.localdomain
This completes the setup of network cards. Just in case, again for clarity:
192.168.100.1 - the static address of the ADSL modem
192.168.100.6 - the static address of the Elastix server
Part 2. Setting up Elastix
Open your personal account on idphone.kz and select the desired phone number. In the menu "Personal data -> Equipment or phone settings" we see something like this window.
Do not forget to click the "change password" button.
Go to Elastix-> PBX-> Trunks-> Add SIP Trunk
- Trunk Name: specify any. I am using MegalineTrunk
- Outbound Caller ID: phone number. In my case it is 39 **** 6
- PEER Details:
host=sip.telecom.kz username=922350056 type=friend nat=no qualify=yes canreinvite=nonat insecure=port,invite&invite fromuser=922350056 fromdomain=sip.telecom.kz secret=8GZepVd3 dtmfmode=rfc2833 context=from-trunk disallow=all allow=alaw trunkstyle=customvoip
- Register String: 922350056: 8GZepVd3: firstname.lastname@example.org/922350056
Go to Elastix -> PBX -> Inbound Routes -> Add Incoming Route
- Description: it doesn’t matter, I used the phone number that Elastix should work when dialing
- DID Number: 922350056
- Set Destination: it indicates where you will need to switch the subscriber. You can transfer the call to a specific Extension or enable the voice menu (IVR).
Outbound Routes -> Add Route
- Dial Patterns that will use this Route: here you can see the number pattern for your city. In my case, this is (empty) + empty | [ XXXXXX / empty]
Now we go to Elastix -> System -> Network -> Edit Network Parameters
In my case, the settings look like this:
Host parameter is specified arbitrarily. In principle, it does not affect anything.
Ultimately, you should get something like this: