Configure SIP (Sofia) in FreeSWITCH:If you’ve installed FreeSWITCH successfully, the next step is configuring SIP profiles using Sofia SIP.
This guide covers:
- Internal SIP profile
- External SIP profile
- User extensions
- NAT configuration
- SIP trunk setup basics
📌 What is Sofia SIP?
mod_sofia is the SIP stack used by FreeSWITCH.
It handles:
- SIP registration
- Call routing
- SIP trunks
- NAT traversal
- Authentication
📂 Important SIP Configuration Directory
All SIP profiles are located in:
/usr/local/freeswitch/conf/sip_profiles/
Main files:
internal.xml
external.xml
1️⃣ Understanding SIP Profiles
FreeSWITCH uses two default profiles:
| Profile | Purpose |
|---|---|
| internal | Extensions (1000, 1001, etc.) |
| external | SIP trunk providers |
2️⃣ Check If Sofia Is Running
Enter CLI:
/usr/local/freeswitch/bin/fs_cli
Then run:
sofia status
You should see:
Profile internal RUNNING
Profile external RUNNING
If not running:
reloadxml
sofia profile internal restart
3️⃣ Configure Internal SIP Profile
Open:
nano /usr/local/freeswitch/conf/sip_profiles/internal.xml
Important parameters:
<param name="sip-port" value="5060"/>
<param name="rtp-ip" value="$${local_ip_v4}"/>
<param name="sip-ip" value="$${local_ip_v4}"/>
For local network, this is fine.
4️⃣ Configure Public IP (NAT Setup)
If your server has a public IP:
Edit:
/usr/local/freeswitch/conf/vars.xml
Find:
<X-PRE-PROCESS cmd="set" data="external_sip_ip=auto"/>
<X-PRE-PROCESS cmd="set" data="external_rtp_ip=auto"/>
Change to your public IP:
<X-PRE-PROCESS cmd="set" data="external_sip_ip=YOUR_PUBLIC_IP"/>
<X-PRE-PROCESS cmd="set" data="external_rtp_ip=YOUR_PUBLIC_IP"/>
Save and reload:
reloadxml
sofia profile internal restart
5️⃣ Create SIP Extension (Example 2000)
Go to:
/usr/local/freeswitch/conf/directory/default/
Create file:
nano 2000.xml
Add:
<include>
<user id="2000">
<params>
<param name="password" value="mypassword"/>
</params>
<variables>
<variable name="toll_allow" value="local"/>
<variable name="accountcode" value="2000"/>
<variable name="user_context" value="default"/>
</variables>
</user>
</include>
Reload:
reloadxml
6️⃣ Test Registration
Use softphone:
- Username: 2000
- Password: mypassword
- Domain: Server IP
- Port: 5060
Check registration:
sofia status profile internal reg
7️⃣ Configure SIP Trunk (External Profile)
Edit:
/usr/local/freeswitch/conf/sip_profiles/external.xml
Example trunk:
<gateway name="mytrunk">
<param name="username" value="trunkuser"/>
<param name="password" value="trunkpass"/>
<param name="proxy" value="sip.provider.com"/>
<param name="register" value="true"/>
</gateway>
Restart profile:
sofia profile external restart
Check status:
sofia status gateway mytrunk
8️⃣ Open Firewall Ports
sudo ufw allow 5060/udp
sudo ufw allow 16384:32768/udp
🔎 Useful Sofia Commands
Inside CLI:
| Command | Purpose |
|---|---|
| sofia status | Show profiles |
| sofia status profile internal reg | Show registered users |
| sofia profile internal restart | Restart profile |
| sofia global siptrace on | Enable SIP debug |


