For extending your traditional PBX to a remote office, out-building or second location using analog endpoints, the best solution is to use two of Grandstream gateways, one for the FXS connection the other for the FXO. Tying a second location together to your PBX has become a regular go-to solution with thousands of deployments established worldwide. Configuration and setup are not difficult and can be accomplished in a matter of hours given the right hardware is in hand. The cost of the equipment (gateway devices) is extremely affordable. Grandstream makes well established gateways in several sizes, with both the 4 and 8 port models popular, handling just enough phones for most small secondary locations. To complete the remote location's connectivity two gateways are normally needed. One as the FXS gateway and one as the FXO gateway, for example using Grandstream's GXW4104 to GXW4004. The result is to extend analog phone lines over IP with FXS to FXO mapping.
Your second location can be an out building or a remote office in another country. Mapping the FXS ports allows phones to use the Internet to connect to the home locations gateway and to an IP-PBX that uses some traditional phone lines. Note the ports of 5060, 5062, 5064 and 5066.
Grandstream's GXW400x fxs gateway connected to a corresponding FXO gateway offers an affordable solution that connects a remote location to the home PBX. The remote location's gateway should be behind a firewall for security. Below is a video explaining the configurations for the Grandstream gateways.
NOTE: By default the GUI of the GXW400x device is disabled and the first thing to do when installing one is to get connected by setting up your IP address and connect with a analog phone connected to an FXS port using a dial menu so you can enable the GUI interface.