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 somewhere (good information on this issue is
enough ), I also wanted to elaborate on its integration with the city SIP numbers of a Kazakhstani provider.

I think it is worth mentioning right away that I have no relation to this provider (except for the fact that I am the user of their services).
What we need:
For clarity:
')
So. Our company has at its disposal 2 SIP-numbers with 2 lines on each. At hand was an old sistemnik on which the Elastix was successfully installed. This is where the fun began.
Part 1. Network Setup.
A bit of theory: to ensure the quality of communication, Kazakhtelecom divides the physical channel ADSL into 2 logical channels that do not affect each other. It turns out that two interfaces will come out of the ADSL modem, one for the Internet, the other for ID Phone (SIP). Accordingly, Elastix must also be connected to both of these interfaces. But there is another problem. The 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, must have a 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 the second network card. The idea is that the second network card asterisk is connected directly to the ADSL-modem in the ports for ID Phone. The network card receives a dynamic IP address type 10.20.130.11. The problem is that in this situation, the Elastix server acquires two Default Gateway. One already registered on Megaline 192.168.100.1 and the second, received via DHCP from the network ID Phone. Traffic starts to wander, nothing works. How to be?
First of all, go to the ADSL router settings (in my case
192.168.100.1 ) and turn off DHCP for one of the Ethernet ports (in my case 4th), to which Elastix will be connected directly from the second network card. On my
TP-Link TD-W8951ND, it looks like this:

We connect the second network card (if we have not done this before) and through SSH we connect to the Elastix server, and then enter the command
ifconfig
The result looks 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. So, the network card that we are going to configure to work with Kazaktelecom's DHCP is
eth1 .
It turns out that, unlike Windows, Linux can be taught to receive via DHCP not all 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 connect to the server and create a file called
/etc/dhclient-eth<X>.conf
where X is your network card number. In my case it is
/etc/dhclient-eth1.conf
write:
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
/etc/sysconfig/network-scripts/route-eth<X> ( )
in which we write:
GATEWAY0=192.168.100.6 NETMASK0=255.0.0.0 ADDRESS0=10.0.0.0
Further. Modify file contents:
/ etc / sysconfig / network-scripts / ifcfg-eth0
/ etc / sysconfig / network-scripts / ifcfg-eth1
/ etc / sysconfig / network
NETWORKING=yes NETWORKING_IPV6=no HOSTNAME=host.asterisk GATEWAY=192.168.100.1 DNS1=192.168.100.1 DNS2=8.8.8.8
/ etc / hosts
This completes the configuration of network cards. Just in case, once again for clarity:
192.168.100.1 - 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 press the "change password" button.
Go to
Elastix-> PBX-> Trunks-> Add SIP TrunkGo to
Elastix -> PBX -> Inbound Routes -> Add Incoming Route- Description: it does not matter, I used the phone number, when dialing which should work Elastix
- DID Number: 922350056
- Set Destination: here it is indicated where you want 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: this is the number pattern for your city. In my case it is (empty) + empty | [[23] XXXXXX / empty]
Now go to
Elastix -> System -> Network -> Edit Network ParametersIn my case, the settings are as follows:

Host parameter is optional. In principle, does not affect anything.
Ultimately, something like this should turn out:
