Difference between revisions of "M4 RTPEngine GeoIP"
| (9 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
RTPEngine GeoIP allows the SIP proxy to select the geographically closest or most appropriate RTPEngine instance to handle media (RTP/RTCP) traffic based on the IP address of the calling party. | |||
RTPEngine GeoIP allows the SIP proxy to select the geographically closest or most appropriate RTPEngine instance to handle media (RTP/RTCP) traffic based on the IP address of the calling party | |||
This feature uses GeoIP database from https://www.maxmind.com/ | This feature uses GeoIP database from https://www.maxmind.com/ | ||
| Line 7: | Line 5: | ||
= Configuration = | = Configuration = | ||
Before using this feature, GeoIP database must be downloaded | Before using this feature, GeoIP database must be downloaded: | ||
1. Create account at https://www.maxmind.com/<br/> | 1. Create account at https://www.maxmind.com/<br/> | ||
| Line 20: | Line 18: | ||
* '''kamailio_rtpengine_geo_enabled''' - If set to 1, enables the GeoIP routing logic in the rtpengine module. When enabled, the module attempts to use geolocation data to select an RTPEngine server list. Default 0 (disabled). | * '''kamailio_rtpengine_geo_enabled''' - If set to 1, enables the GeoIP routing logic in the rtpengine module. When enabled, the module attempts to use geolocation data to select an RTPEngine server list. Default 0 (disabled). | ||
* '''kamailio_rtpengine_geo_db_path''' - Path to GeoIP database. Default value '/usr/share/GeoIP/GeoLite2-City.mmdb'. | * '''kamailio_rtpengine_geo_db_path''' - Path to GeoIP database. Default value '/usr/share/GeoIP/GeoLite2-City.mmdb'. | ||
* '''kamailio_rtpengine_geo_use_sdp_ip''' - | * '''kamailio_rtpengine_geo_use_sdp_ip''' - If set to 1, instructs the GeoIP module to use the IP address found in the Session Description Protocol (SDP) "c=" line for the GeoIP lookup, instead of the SIP message's source IP. This is useful for identifying the IP address the media will actually originate from. Default 0 (disabled). | ||
* '''kamailio_rtpengine_geo_servers_default''' - List of server IDs separated by comma. At least one media server ID must be set. Defines the default RTPEngine set. This serves as a mandatory fallback in case IP is not found in geolocation database or if region is not configured. For example, call is originated from EU, but EU location is not configured - in this case, default server list will be used. | * '''kamailio_rtpengine_geo_servers_default''' - List of server IDs separated by comma. At least one media server ID must be set. Defines the default RTPEngine set. This serves as a mandatory fallback in case IP is not found in geolocation database or if region is not configured. For example, call is originated from EU, but EU location is not configured - in this case, default server list will be used. | ||
* '''kamailio_rtpengine_geo_servers_eu''' - List of server IDs separated by comma. Maps EU location to a specified RTPEngine server | * '''kamailio_rtpengine_geo_servers_eu''' - List of server IDs separated by comma. Maps EU location to a specified RTPEngine server list. | ||
* '''kamailio_rtpengine_geo_servers_us_east''' - List of server IDs separated by comma. Maps US East location to a specified RTPEngine server | * '''kamailio_rtpengine_geo_servers_us_east''' - List of server IDs separated by comma. Maps US East location to a specified RTPEngine server list. Optional. | ||
* '''kamailio_rtpengine_geo_servers_us_west''' - List of server IDs separated by comma. Maps US West location to a specified RTPEngine server | * '''kamailio_rtpengine_geo_servers_us_west''' - List of server IDs separated by comma. Maps US West location to a specified RTPEngine server list. Optional. | ||
* '''kamailio_rtpengine_geo_servers_canada_east''' - List of server IDs separated by comma. Maps Canada East location to a specified RTPEngine server | * '''kamailio_rtpengine_geo_servers_canada_east''' - List of server IDs separated by comma. Maps Canada East location to a specified RTPEngine server list. Optional. | ||
* '''kamailio_rtpengine_geo_servers_canada_west''' - List of server IDs separated by comma. Maps Canada West location to a specified RTPEngine server | * '''kamailio_rtpengine_geo_servers_canada_west''' - List of server IDs separated by comma. Maps Canada West location to a specified RTPEngine server list. Optional. | ||
* '''kamailio_rtpengine_geo_servers_latin_america''' - List of server IDs separated by comma. Maps Latin America location to a specified RTPEngine server | * '''kamailio_rtpengine_geo_servers_latin_america''' - List of server IDs separated by comma. Maps Latin America location to a specified RTPEngine server list. Optional. | ||
* '''kamailio_rtpengine_geo_servers_asia_pacific''' - List of server IDs separated by comma. Maps Asia/Pacific location to a specified RTPEngine server | * '''kamailio_rtpengine_geo_servers_asia_pacific''' - List of server IDs separated by comma. Maps Asia/Pacific location to a specified RTPEngine server list. Optional. | ||
* '''kamailio_rtpengine_geo_servers_africa''' - List of server IDs separated by comma. Maps Africa location to a specified RTPEngine server | * '''kamailio_rtpengine_geo_servers_africa''' - List of server IDs separated by comma. Maps Africa location to a specified RTPEngine server list. Optional. | ||
* '''kamailio_rtpengine_geo_servers_middle_east''' - List of server IDs separated by comma. Maps Middle East location to a specified RTPEngine server | * '''kamailio_rtpengine_geo_servers_middle_east''' - List of server IDs separated by comma. Maps Middle East location to a specified RTPEngine server list. Optional. | ||
<br/> | <br/> | ||
| Line 37: | Line 35: | ||
<br/> | <br/> | ||
After configuration, Kamailio must be reconfigured and restarted: | After configuration variables are set, Kamailio must be reconfigured and restarted: | ||
/usr/src/m4/kamailio/kamailio_cfg_update.sh | /usr/src/m4/kamailio/kamailio_cfg_update.sh | ||
systemctl restart kamailio | systemctl restart kamailio | ||
=== Example === | |||
kamailio_rtpengine_geo_enabled = 1 | |||
kamailio_rtpengine_geo_servers_default = 1,2,3 | |||
kamailio_rtpengine_geo_servers_eu = 2,3 | |||
kamailio_rtpengine_geo_servers_us_east = 4 | |||
kamailio_rtpengine_geo_servers_us_west = 5 | |||
If call comes from EU, then one of the two configured RTPEngine servers with ID 2 and 3 will be used.<br/> | |||
If call comes from US East, then RTPEngine server with ID 4 will be used.<br/> | |||
If call comes from US West, then RTPEngine server with ID 5 will be used.<br/> | |||
If call comes from any other region or in case of geolocation error (for example IP not found in the database, private IP), then one of the default RTPEngine servers with ID 1, 2 and 3 will be used.<br/> | |||
= Automatic GeoIP database update = | = Automatic GeoIP database update = | ||
| Line 54: | Line 65: | ||
Cron will automatically update GeoIP database twice a week at 2:32 AM on Sunday and Wednesday. | Cron will automatically update GeoIP database twice a week at 2:32 AM on Sunday and Wednesday. | ||
If different update period is required, modify '''/etc/cron.d/m4_geoipupdate''' cron file in Kamailio server to your needs. | If different update period is required, modify '''/etc/cron.d/m4_geoipupdate''' cron file in Kamailio server to your needs and restart crond service. | ||
Latest revision as of 04:41, 25 November 2025
RTPEngine GeoIP allows the SIP proxy to select the geographically closest or most appropriate RTPEngine instance to handle media (RTP/RTCP) traffic based on the IP address of the calling party.
This feature uses GeoIP database from https://www.maxmind.com/
Configuration
Before using this feature, GeoIP database must be downloaded:
1. Create account at https://www.maxmind.com/
2. Login to your account
3. Under 'GeoIP / GeoLite' section, select 'Download files'
4. Select 'GeoLite City' database and download as gzip
5. Extract the archive and copy database file 'GeoLite2-City.mmdb' to Kamailio server, /usr/share/GeoIP directory
When database base file is downloaded, RTPEngine GeoIP must be configured in Kamailio server, configuration file /etc/m2/system.conf:
- kamailio_rtpengine_geo_enabled - If set to 1, enables the GeoIP routing logic in the rtpengine module. When enabled, the module attempts to use geolocation data to select an RTPEngine server list. Default 0 (disabled).
- kamailio_rtpengine_geo_db_path - Path to GeoIP database. Default value '/usr/share/GeoIP/GeoLite2-City.mmdb'.
- kamailio_rtpengine_geo_use_sdp_ip - If set to 1, instructs the GeoIP module to use the IP address found in the Session Description Protocol (SDP) "c=" line for the GeoIP lookup, instead of the SIP message's source IP. This is useful for identifying the IP address the media will actually originate from. Default 0 (disabled).
- kamailio_rtpengine_geo_servers_default - List of server IDs separated by comma. At least one media server ID must be set. Defines the default RTPEngine set. This serves as a mandatory fallback in case IP is not found in geolocation database or if region is not configured. For example, call is originated from EU, but EU location is not configured - in this case, default server list will be used.
- kamailio_rtpengine_geo_servers_eu - List of server IDs separated by comma. Maps EU location to a specified RTPEngine server list.
- kamailio_rtpengine_geo_servers_us_east - List of server IDs separated by comma. Maps US East location to a specified RTPEngine server list. Optional.
- kamailio_rtpengine_geo_servers_us_west - List of server IDs separated by comma. Maps US West location to a specified RTPEngine server list. Optional.
- kamailio_rtpengine_geo_servers_canada_east - List of server IDs separated by comma. Maps Canada East location to a specified RTPEngine server list. Optional.
- kamailio_rtpengine_geo_servers_canada_west - List of server IDs separated by comma. Maps Canada West location to a specified RTPEngine server list. Optional.
- kamailio_rtpengine_geo_servers_latin_america - List of server IDs separated by comma. Maps Latin America location to a specified RTPEngine server list. Optional.
- kamailio_rtpengine_geo_servers_asia_pacific - List of server IDs separated by comma. Maps Asia/Pacific location to a specified RTPEngine server list. Optional.
- kamailio_rtpengine_geo_servers_africa - List of server IDs separated by comma. Maps Africa location to a specified RTPEngine server list. Optional.
- kamailio_rtpengine_geo_servers_middle_east - List of server IDs separated by comma. Maps Middle East location to a specified RTPEngine server list. Optional.
Note: kamailio_rtpengine_geo_servers_xxx use server IDs defined in GUI (MAINTENANCE -> Servers). These servers should be active and marked as media servers.
After configuration variables are set, Kamailio must be reconfigured and restarted:
/usr/src/m4/kamailio/kamailio_cfg_update.sh systemctl restart kamailio
Example
kamailio_rtpengine_geo_enabled = 1 kamailio_rtpengine_geo_servers_default = 1,2,3 kamailio_rtpengine_geo_servers_eu = 2,3 kamailio_rtpengine_geo_servers_us_east = 4 kamailio_rtpengine_geo_servers_us_west = 5
If call comes from EU, then one of the two configured RTPEngine servers with ID 2 and 3 will be used.
If call comes from US East, then RTPEngine server with ID 4 will be used.
If call comes from US West, then RTPEngine server with ID 5 will be used.
If call comes from any other region or in case of geolocation error (for example IP not found in the database, private IP), then one of the default RTPEngine servers with ID 1, 2 and 3 will be used.
Automatic GeoIP database update
To update GeoIP database automatically:
1. Login to your account at https://www.maxmind.com/
2. Under 'Account' section, select 'Manage license keys'
3. Generate new license key
4. Copy 'Account ID' and 'License key' to config file /etc/GeoIP.conf located in Kamailio server
5. Save config file
Cron will automatically update GeoIP database twice a week at 2:32 AM on Sunday and Wednesday.
If different update period is required, modify /etc/cron.d/m4_geoipupdate cron file in Kamailio server to your needs and restart crond service.