M4 RTPEngine GeoIP
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 (User Agent).
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, Kamailio must be reconfigured and restarted:
/usr/src/m4/kamailio/kamailio_cfg_update.sh systemctl restart kamailio
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.