Implementing geographical IP filtering with Asterisk VoIP systems for enhanced security and intelligent call routing.
GeoIP filtering allows you to control access to your Asterisk VoIP system based on the geographical location of incoming connections. This helps prevent unauthorized access and reduces the risk of toll fraud from high-risk countries.
; Block specific countries in extensions.conf
exten => _X.,1,GotoIf($["${GEOIP_COUNTRY}"="CN"]?blocked)
exten => _X.,n,GotoIf($["${GEOIP_COUNTRY}"="RU"]?blocked)
exten => _X.,n,Dial(SIP/${EXTEN})
exten => _X.,n(blocked),Hangup()
; Allow only specific countries
exten => _X.,1,GotoIf($["${GEOIP_COUNTRY}"="GB"]?allowed)
exten => _X.,n,GotoIf($["${GEOIP_COUNTRY}"="US"]?allowed)
exten => _X.,n,Hangup()
exten => _X.,n(allowed),Dial(SIP/${EXTEN})
; Different rules for business hours
exten => _X.,1,GotoIf($[${HOUR}>8 & ${HOUR}<17]?business:after)
exten => _X.,n(business),GotoIf($["${GEOIP_COUNTRY}"!="GB"]?blocked)
exten => _X.,n(after),GotoIf($["${GEOIP_CONTINENT}"!="EU"]?blocked)
Contact our technical team for assistance with implementing GeoIP filtering.