There is a task: to submit one telephone number and Ethernet to one remote point. From the main building to this point there are already terminated optics. This problem can be solved in several ways, but we had two voice gateways DLink 7022S in stock, so the solution was in the palm of your hand.
Nevertheless, a cursory search in the documentation and on the Internet did not give an answer to how to achieve the desired.

Under the cut is not an overview of the gateways and not a manual, but an example of solving a specific task. Not the most elegant way, of course, but quite working.
')
So, the connection scheme will be as follows:

No SIP servers should be used, the call should be transparent to the user, that is, without dialing additional digits. Gateways are connected to each other by WAN ports. A telephone cable from the PBX or from the operator and an Ethernet cable to the LAN port are connected to the device at the central node. On the remote side, a telephone and a computer are connected to it.

In the beginning I had doubts about the performance of such a scheme. Can gateways interact in this way? Many articles on the Internet described the connection of this gateway to Asterisk or other SIP servers. It turns out this is quite possible.
DLink 7022S carries on the body 1 WAN port, a switch to 4 LAN ports, 2 Line ports (FXO) to connect to the telephone network and 2 Phone ports (FXS) to connect phones. On the front panel a lot of status indicators.
On the experimental setup, we connect two WAN ports with a normal patchcord. In fact, of course, there can be any IP network.
Let's start with telephony, because it was her work that initially seemed dubious. The first step is to configure the IP addresses on the WAN ports for the communication of the gateways. Since these DLinks are essentially mini-ATSs, it’s naive to hope that everything will work without tuning. So it happened. Next, I will describe the algorithm settings.
Configure the gateway on the central site
The address on the computer is issued via DHCP. The default address is 192.168.8.254. It is better to let the broadcast ping 192.168.8.255 and you will see what address you answer. Authorization fields are empty.
IP addresses
We work with the Network Settings group. The WAN IP address will be used to connect two gateways:
The LAN IP address does not have to be on the same subnet as the WAN address and, on the contrary, must belong to the local area network of the enterprise in order to be managed.

In order not to fence the fence from new subnets and routes, you can configure the operation mode of the bridge:

Now configure the SIP parameters:
The scheme of work will be as follows:
1) when the call arrives at the first FXO port of the gateway on the central node (on which the 601 number is configured), it will automatically be redirected to the number 701, which will be configured on the first FXS port of the gateway on the remote point. Similarly for the second.
2) when the call is made from a remote point through the first FXS port (number 701), the number 601 will automatically be called - the number of the 1st FXO port of the gateway on the central node. Similarly for the second port.
Here you need to specify other phone numbers instead of default ones.
Set up numbers 601 and 602 for FXO ports, respectively:

Also disable the use of SIP-servers:

In the phone book, you need to make two entries with the corresponding numbers and an indication of the address through which the call to this number will be made. In our case, this is not yet configured the address of the second device:

At the last turn, we set up the call so that when dialing the internal number of the PBX, the call passes without dialing. If you do not do this, after dialing the internal number, a female voice will say: “Dial phone number” - and you will need to dial 601 or 602 to get on one of the two connected phones. That is, in fact, the numbers 601 and 602 that we configured are internal. And the next setting, we indicate that the call should automatically go to the appropriate ports.

Once again I will explain: if the call comes to the first FXO port (a line is inserted from the PBX or from the operator), it will automatically (thanks to the Hot Line checkbox) go to number 701, which in turn is entered in the phone book with the IP address second gateway.
To save the settings, it is
not enough to click Accept on the settings page - you need to go to the System Operation group, set both checkboxes and click Accept.

Almost similarly configured second device
Configure the IP address for the WAN and LAN ports.
If in the first case the bridge mode was set, then it is better to do the same here, although DLink can be done here by a router, which, for example, will issue network parameters via DHCP. We do not need it and therefore I set the bridge mode:

For a WAN, the address must be on the same subnet as the WAN address of the first device:

Here in SIP you can leave the same numbers as the default:

Similar to the first case, disable the use of SIP-servers.

We also add two lines to the Phone book, only now we specify other numbers and the IP address of the first device.

And in order to make the calls pass smoothly, we will again set up the Hotline - automatic call:

Save the settings and reboot the device.
You can check the connection between the two gateways through the menu Status-> Ping Test

From this window we can conclude that the devices most likely work on linux.
Now you can make a test call. If you did everything according to the instructions, then the call will definitely pass. When you pick up the handset, the Phone indicator glows yellow,

when establishing a connection with the second gateway, the Line indicator will light up on the second

What problems are noticed:
1) call delay and hang up in a few seconds. Almost no attention is attracted, especially since the voice is not late.
2) Sometimes right after loading, the gateway confuses the phones and sends them to the wrong devices. For example, the call to number 104 comes in at 123. But after the final download, the situation is corrected.
Remarks:
The numbers 601, 602, 701, 702 are exclusively internal for this group of gateways and there is no need to start them on the PBX.
It is recommended to immediately change the login / password for access.

Similarly, other DLink devices of this genre work and are configured.
The principle of adjustment is slightly less than fully taken
here .