Location>code7788 >text

SIP gateway (Gateway) operation in FreeSWITCH

Popularity:815 ℃/2025-04-18 17:50:15

freeswitch is a simple and easy-to-use VOIP open source softswitch platform.

The following is a technical guide on the operation of SIP gateways (Gateway) in FreeSWITCH, compiled based on the official documentation provided:

1. Gateway life cycle management

1. Create a new SIP Profile and start

FreeSWITCH supports multi-SIP Profile (such asinternal/external). After creating a new profile, you need to start manually:

freeswitch> sofia profile <new_profile_name> start  

Example: Create a new namecustomProfile

freeswitch> sofia profile custom start  

2. Configure overload and hot update profile&gateway

Dynamic reload configuration (not affecting the current call)

# Rescan the configuration file only (not interrupting service)
 freeswitch> sofia profile <profile_name> rescan reloadxml

 # Completely restart the Profile (interrupt the current connection)
 freeswitch> sofia profile <profile_name> restart reloadxml

NoticerescanThe core parameters such as IP address and UDP port cannot be updated.restart

3. Gateway deletion operation

Delete the specified gateway or batch cleanup:

# Delete a single gateway
 freeswitch> sofia profile <profile_name> killgw <gateway_name>

 # Delete all gateways
 freeswitch> sofia profile <profile_name> killgw _all_

4. Force gateway restart (trigger re-registration)

freeswitch> sofia profile <profile_name> killgw <gateway_name>  
freeswitch> sofia profile <profile_name> rescan  

Application scenarios: Force re-registration after modifying the gateway password, or repairing recovery after network interruption.

2. Real-time modification of gateway configuration

1. Add/modify gateways

Assume that the gateway file is located inconf/sip_profiles/external/Table of contents:

# After editing the configuration file, trigger dynamic loading
 freeswitch> sofia profile external rescan reloadxml

2. Malfunction configuration hotfix

If you find a configuration error (such as an IP address error):

# 1. Stop the problem gateway
 freeswitch> sofia profile external killgw faulty_gw

 # 2. Modify the configuration file
 vim conf/sip_profiles/external/faulty_gw.xml

 # 3. Reload the configuration
 freeswitch> sofia profile external rescan reloadxml

3. Gateway status monitoring

1. Gateway health status list

# List active gateways
 freeswitch> sofia profile <profile> gwlist up

 # List faulty gateways
 freeswitch> sofia profile <profile> gwlist down

Dependency conditions: The gateway needs to be configuredpingParameters (periodic heartbeat detection):

<param name="ping" value="30"/> <!-- Send OPTIONS probe every 30 seconds -->

2. Gateway data query

# Get the inbound variable value
 sofia_gateway_data <gateway_name> ivar <variable_name>

 # Get outbound variable value
 sofia_gateway_data <gateway_name> ovar <variable_name>

 # Automatically match variable types
 sofia_gateway_data <gateway_name> var <variable_name>

Application scenarios: Check the gatewaycodec-prefsorexpire-secondsParameter value.

4. Advanced operation skills

1. Security configuration update policy

  • Grayscale update: Pass firstkillgwRemove the old gateway and load the new configuration test
  • Configure backup: Backup XML file before modification (such asgw_backup_202310.xml

2. Automated operation and maintenance suggestions

  • Combinedmod_event_socketDevelop monitoring scripts to receive gateway status events in real time
  • usemod_distributorImplement automatic traffic switching of faulty gateways

Conclusion

By flexibly using the gateway operation commands of the Sofia module, efficient connection between FreeSWITCH and external SIP services can be achieved.

Regular monitoring: regular executiongwlist up/downCheck gateway health.

Empty as usual

Seek truth and get truth