FreeSWITCH (Sofia gateway)
Configure the SIP Trunk on FreeSWITCH
SIP gateway to PortalPBX in the FreeSWITCH external profile, with inbound and outbound dialplan.

Before you start
- FreeSWITCH 1.10+ and fs_cli access.
- Trunk details provided by PortalPBX.
Your trunk details
PortalPBX sends them when the trunk is activated. Replace each placeholder with your real value.
- SIP server (host or domain)
- <servidor-sip>
- Port and transport
- <puerto> · UDP / TCP / TLS
- SIP username
- <usuario>
- SIP password
- <contraseña>
- Assigned DID number(s)
- <DID>
- Authentication mode
- Registro / IP
- Enabled codecs
- G.711 (alaw/ulaw) · G.729*
* G.729 only if enabled on your trunk.
Step by step
- 1
Create the gateway
Create conf/sip_profiles/external/portalpbx.xml:
<include> <gateway name="portalpbx"> <param name="realm" value="<servidor-sip>"/> <param name="proxy" value="<servidor-sip>"/> <param name="username" value="<usuario>"/> <param name="password" value="<contraseña>"/> <param name="register" value="true"/> <param name="caller-id-in-from" value="true"/> <param name="ping" value="60"/> </gateway> </include> - 2
Inbound calls
In conf/dialplan/public route the DID to your extension or IVR:
<extension name="portalpbx-did"> <condition field="destination_number" expression="^<DID>$"> <action application="transfer" data="1000 XML default"/> </condition> </extension> - 3
Outbound calls
In the default context:
<extension name="salida-portalpbx"> <condition field="destination_number" expression="^(\d{7,15})$"> <action application="set" data="effective_caller_id_number=<DID>"/> <action application="bridge" data="sofia/gateway/portalpbx/$1"/> </condition> </extension> - 4
Reload and verify
In fs_cli:
reloadxml sofia profile external rescan sofia status gateway portalpbx
Recommendations
- In vars.xml check external_rtp_ip and external_sip_ip if you are behind NAT.
- Prefer G.711 alaw/ulaw; use G.729 only if it is enabled on your trunk and supported by your equipment.
- Disable SIP ALG on your router or firewall: it is the most common cause of one-way audio and dropped registrations.
- If your PBX is behind NAT, set the public IP and local network, and open the RTP range your system uses.
- Restrict SIP access with a firewall and use long extension passwords to prevent toll fraud.
- Dial numbers in the format stated in your activation sheet (national or international) and check the caller ID.
Common errors
FAIL_WAIT / NOREG
The gateway does not register: credentials, realm or connectivity.
INCOMPATIBLE_DESTINATION
Codecs: include PCMA/PCMU in global_codec_prefs.
Need a hand?
We configure it with you, remotely
If the manual setup does not work, contact support or open a ticket. We review registration, routes, codecs and NAT with you through a secure remote session.