Docker化FreeSWITCH配置SDP以引用宿主机IP的问题
Got it, let's sort out this issue where your FreeSWITCH container's SDP is using the internal container IP instead of your host machine's IP. Here's a practical step-by-step solution tailored to your provided Sofia profile details:
1. Update the Sofia Internal Profile Config
First, edit the conf/sip_profiles/internal.xml file inside your FreeSWITCH container (pro tip: mount this config file from your host to the container for easier future edits). Add or adjust these key parameters:
<!-- Replace with your actual host machine IP (e.g., 192.168.1.100 or public IP) --> <param name="ext-ip" value="YOUR_HOST_MACHINE_IP"/> <!-- Let FreeSWITCH listen on all container network interfaces --> <param name="rtp-ip" value="0.0.0.0"/> <param name="sip-ip" value="0.0.0.0"/> <!-- Enable auto-NAT to ensure SDP consistently uses the external IP --> <param name="auto-nat" value="true"/>
2. Apply Changes with a Profile Restart
Run these commands inside the FreeSWITCH console to reload the config and restart the internal profile:
freeswitch@36fe182d8fb3> reloadxml freeswitch@36fe182d8fb3> sofia profile internal restart
3. Verify the Configuration
Check if the settings took effect by re-running your original status command:
sofia status profile internal
You should now see your host IP reflected in the profile details. When FreeSWITCH sends SDP during calls, the c= line will reference your host machine's IP instead of the container's private internal IP.
4. Confirm Docker Port Mapping
Make sure you've mapped all required ports from your host to the container when starting it. FreeSWITCH needs:
- SIP port (5060/udp)
- RTP port range (default 16384-32768/udp)
Example Docker run command:
docker run -d \ -p 5060:5060/udp \ -p 16384-32768:16384-32768/udp \ your-freeswitch-image-name
5. Check Host Firewall Rules
Don't forget to open the mapped ports on your host's firewall (iptables, ufw, Windows Firewall, etc.) so external devices can reach FreeSWITCH via your host IP.
内容的提问来源于stack exchange,提问作者Unai

