KTS 4M GSM Gateway Setup with FreePBX (Trunk Mode)
Step-by-step KTS 4M GSM gateway setup with FreePBX in trunk mode. Static LAN IP, per-SIM SIP ports, Call Num=# with d/a transforms, create SIP trunks and test.
How to set up KTS 4M GSM gateway with FreePBX in Trunk mode? Step-by-step configuration guide, connection instructions, and tips from experienced users since the official manual is unavailable.
KTS 4M can be run as a trunk-mode GSM gateway (gsm шлюз) for FreePBX by giving the gateway a static LAN IP, enabling trunk/Single‑Server mode, and creating one SIP trunk per SIM in FreePBX that points to the gateway IP and per‑channel SIP port. Configure the gateway’s LAN→Mobile routing (use Call Num = #, use d/a transforms to add/remove digits), create Outbound Routes in FreePBX that use the KTS trunks, and test with SIP debug; community-tested peer settings like host=KTS_IP, port=5060/5062, type=friend, allow=ulaw&alaw are a practical starting point. Below is a step‑by‑step, field‑tested guide with examples and troubleshooting tips collected from FreePBX/GoIP/Yeastar users when the official KTS manual is missing.
Contents
- Overview & prerequisites
- Network & initial KTS 4M setup (gsm шлюз)
- KTS 4M SIP / Trunk-mode settings (voip gsm шлюз)
- Create SIP Trunks in FreePBX (sip шлюз)
- Dial plan, Outbound Routes & digit manipulation (настройка gsm шлюза)
- Testing, debug and verification
- Common issues & tips from experienced users
- Sources
- Conclusion
Overview & prerequisites
Short version: set the KTS 4M into trunk (or single‑server) mode, map each SIM channel to a port the PBX can reach, then create matching SIP trunks in FreePBX and route calls through them. The KTS 4M acts like other multi‑SIM GSM gateways (Yeastar TG, GoIP, Dinstar) — so many community fixes and examples transfer directly.
Prerequisites
- FreePBX admin access and a working extension to test from.
- KTS 4M web UI access (LAN IP + admin credentials).
- Local network connectivity between KTS 4M and the FreePBX server (place both on same LAN for initial testing).
- IP plan and dialing plan (know how your local numbers should be rewritten to E.164).
- Backup FreePBX configuration before you change trunks or outbound rules.
Why trunk mode? Trunk mode means the gateway sends/receives SIP to/from your PBX IP (no public PSTN registration). That keeps signaling local and simple — good for reliability and security.
Network & initial KTS 4M setup (gsm шлюз)
- Assign a static LAN IP to the KTS 4M
- Login to the KTS web UI, set a static address (example 192.168.1.200/24), gateway and DNS.
- Confirm you can ping the device from the FreePBX server.
- Time and firmware
- Set NTP on the gateway so logs and call timestamps are correct (GoIP users reported improved stability after doing this) — see GoIP notes in community examples and Habr writeup: GoIP/GoIP4 tips.
- Update gateway firmware if a newer stable release is available.
- Secure the device
- Change the admin password. Restrict web access to the LAN or specific IPs.
- If possible, restrict SIP access so only the FreePBX server IP can reach the gateway’s SIP ports (ACL).
- Per‑channel SIP port (important)
- Many multi‑SIM gateways use a different SIP port per channel (community users often used 5060 for SIM1, 5062 for SIM2 — check the KTS Forward/Port settings).
- Document the port each SIM uses; you’ll create a FreePBX trunk that points to the gateway IP + that port.
- Mode selection
- If KTS offers “Single Server Mode” or “Trunk Mode”, pick that (this replicates how GoIP and similar devices connect to a single PBX). Habr’s GoIP example used Single Server Mode for trunk operation.
KTS 4M SIP / Trunk-mode settings (voip gsm шлюз)
The gateway must forward SIP calls to the PBX IP and forward mobile calls to the PBX as SIP. Two common KTS settings areas you’ll use: LAN→Mobile (how gateway calls the PBX) and Mobile→LAN (where mobile calls land).
A. LAN → Mobile (how device sends dialed mobile calls to FreePBX)
- In the gateway UI, find the “LAN to MOBILE” / outbound routing page.
- Set the route slot for each SIM to point to your FreePBX IP and the channel port. Example fields (UI names vary):
- URL / Destination:
sip:192.168.1.50:5060(replace with your PBX IP & channel port) - Call Num:
#(this forwards the dialed number as-is) - Use digit transforms if you need to add or remove digits (community example):
#d1a0044 - Explanation:
#= send dialed number,d1= delete 1 leading digit,a0044= add0044prefix. - Example: dialing
01274→#d1a0044→00441274.
(These LAN→MOBILE settings and the Call Num trick were documented in a FreePBX community post with field examples — practical when manuals are missing: https://community.freepbx.org/t/how-to-set-up-a-gsm-gateway-on-freepbx/9720)
B. Mobile → LAN (incoming mobile calls to FreePBX)
- Configure each SIM’s incoming rule to send calls to your PBX IP/port and optionally specify the destination extension (or leave the PBX to route based on CLI/DID).
- On Yeastar-style gateways this is done with “IP to Mobile” / IP->SIP rules — see the Yeastar example if you need a reference layout: https://support.yeastar.com/hc/en-us/articles/115011635787-How-to-Connect-FreePBX-to-Yeastar-TG-Gateway
C. Other gateway settings (useful community tips)
- SIP From: set to Tel/User if available.
- CLID Presentation: Off if you don’t want mobile callers to see the gateway admin number.
- LAN ANSWER MODE: set to “Alerted” if Asterisk fails to see ring otherwise (community tip).
- Check “Forward Settings” to learn which port each SIM uses and adjust your FreePBX trunks accordingly.
Create SIP Trunks in FreePBX (sip шлюз)
Create one trunk per SIM channel for precise routing and failover control.
A. General steps in FreePBX GUI
- Connectivity → Trunks → Add Trunk → Add SIP (chan_sip) or Add PJSIP Trunk depending on your system.
- Name trunks clearly (e.g.,
KTS4M-GSM1,KTS4M-GSM2).
B. Example chan_sip PEER details (adapt port per SIM)
; Example for SIM1 (adjust IP and port)
type=friend
host=192.168.1.200
port=5060
disallow=all
allow=ulaw,alaw
; context can be left to FreePBX defaults; some users used:
; context=from-internal
; insecure=very ; older Asterisk syntax seen in community posts; use with caution
- Leave Register String blank if the gateway does not register to FreePBX (trunk mode).
- If you use chan_pjsip (PJSIP), create an endpoint/registration-free trunk in the PJSIP interface and map the gateway IP as a static peer.
C. Inbound routing
- After trunk creation, go to Connectivity → Inbound Routes and create rules that match the incoming CLI or the trunk name to send calls to an extension, ring group or IVR.
- If the gateway sends a specific DID or CLI for each SIM, use that to route inbound calls to specific extensions (Yeastar docs show mapping examples).
D. Outbound trunk order
- Create an Outbound Route and put KTS trunks in the desired sequence (use trunk groups if you want round‑robin or failover).
For a concrete Yeastar-style setup example, see Yeastar’s FreePBX integration guide: https://support.yeastar.com/hc/en-us/articles/115011635787-How-to-Connect-FreePBX-to-Yeastar-TG-Gateway
Dial plan, Outbound Routes & digit manipulation (настройка gsm шлюза)
- Decide dial patterns on FreePBX
- Example: if users dial local numbers as
8XXXXXXXXX, create a dial pattern8|.to strip the prefix and send the rest. - In FreePBX dial pattern syntax, a common approach is to use
PrependandMatch Patternfields.
- Combine gateway and PBX transformations
- Option A (rewrite on PBX): Let PBX strip/add digits, then send cleaned E.164 to gateway.
- Option B (rewrite on gateway): Send raw dialed number to gateway (Call Num =
#) and use the gateway’sd/atransforms to produce the final dial string. This is often simpler when the gateway handles international prefixes.
- Example gateway-level rewrite (useful when you can’t edit all phones)
- Gateway “Call Num”:
#d1a0044 - Dialed:
01274→ Result sent from gateway:00441274 - This exact trick comes from community configuration examples and is very practical when manuals don’t include dial‑plan syntax: https://community.freepbx.org/t/how-to-set-up-a-gsm-gateway-on-freepbx/9720
- Outbound routing in FreePBX
- Connectivity → Outbound Routes → Add Outbound Route
- Give it a name (e.g., “GSM Out”)
- Set Dial Patterns (match your mobile patterns)
- Under Trunk Sequence, choose
KTS4M-GSM1,KTS4M-GSM2(order controls failover)
Testing, debug and verification
- Basic connectivity
- Ping the KTS IP from the FreePBX server.
- Ensure you can browse the KTS web UI from your admin workstation.
- Make an outbound test call
- From a FreePBX extension, call a mobile number that should go out via the KTS trunk.
- Watch the call logs on the KTS web UI and in FreePBX CDR.
- SIP debug on FreePBX / Asterisk
- For chan_sip:
asterisk -rvvv
sip set debug on
- For PJSIP:
asterisk -rvvv
pjsip set logger on
- Observe INVITE/200/ACK flow and the Request‑URI / To/From headers to make sure the gateway and PBX agree on the dialed number and codecs.
- RTP / One‑way audio
- Confirm RTP ports are open between KTS and PBX. FreePBX usually uses UDP 10000–20000 by default.
- Disable SIP ALG on routers between devices; ALG breaks SIP.
- Incoming call test
- Call the mobile number associated with SIM1 and confirm it rings the PBX extension you configured.
- If inbound calls land but show wrong CLI, check gateway CLID settings (CLID Presentation Off/On).
Common issues & tips from experienced users
- Per‑channel ports: Many users report each SIM uses its own SIP port. Check KTS “Forward Settings” and create matching trunks (e.g., 5060, 5062). See community notes on this: https://community.freepbx.org/t/how-to-set-up-a-gsm-gateway-on-freepbx/9720
- Use
Call Num = #and the device’sd/atransform for simple digit rewriting; it avoids changing every phone’s dial plan. - If Asterisk doesn’t see ringing, try LAN ANSWER MODE = Alerted on the gateway (community tip).
- Codec set: allow
ulaw,alawinitially (lowest friction). If you need bandwidth efficiency, change codecs later and test. - Don’t expose gateway SIP ports to the Internet. If you must, use strong passwords, ACLs and register methods — but the safest option is a LAN‑only trunk to your PBX.
- If your KTS requires “Single Server Mode” (GoIP analog), it’s usually because that mode simplifies forwarding to a single PBX — see the GoIP/GoIP4 notes on practical config: https://habr.com/ru/articles/180855/
- Vendor parity: the steps used for Yeastar/Dinstar and GoIP devices are good references — Yeastar’s step list for TG gateways is useful when adapting KTS: https://support.yeastar.com/hc/en-us/articles/115011635787-How-to-Connect-FreePBX-to-Yeastar-TG-Gateway and a Dinstar walkthrough gives practical UI screenshots for similar tasks: https://www.itsupportwale.com/blog/configure-dinstar-gsm-gateway-with-freepbx/
- Keep a small test plan: change one setting, test, and document the result. Community forums (FreePBX threads) are invaluable when the official manual is missing: https://community.freepbx.org/t/external-gsm-gateway-to-freepbx/41861
Sources
- HOW TO: Set up a GSM Gateway on FreePBX
- How to Connect FreePBX to Yeastar TG Gateway
- Настройка Voip-GSM шлюза Hybertone GoIP4 и Asterisk PBX c помощью FreePBX (Habr)
- Configure Dinstar GSM Gateway with FreePBX (ITSupportWale)
- External GSM Gateway to FreePBX (community troubleshooting)
Conclusion
Setting up a KTS 4M as a trunk‑mode gsm шлюз for FreePBX is straightforward once you follow three pillars: reliable network settings (static IP + NTP), clear gateway LAN↔Mobile routing (use Call Num = # and d/a transforms for digit manipulation), and matching SIP trunks in FreePBX that point to the gateway IP and per‑channel ports. Start simple (one SIM, one trunk), verify audio and SIP messages with Asterisk debug, then add trunks/failover rules. When the vendor manual is missing, community posts and Yeastar/Dinstar examples provide practical, field‑tested patterns that work for most multi‑SIM GSM gateways — adapt their settings to KTS 4M and you’ll have a stable trunked GSM solution.