Kamailio – block voip call use geoip2
Kamailio – block voip call use geoip2

Kamailio – block voip call use geoip2

# Modules Section

loadmodule “geoip2.so”
modparam(“geoip2”, “path”, “/usr/share/geoip/GeoLite2-Country.mmdb”);

request_route {

    if (geoip2_match("$si", "src")) {
            xlog("L_INFO", "Country is: $gip2(src=>cc)\n");
    }

    xlog("L_INFO", "Incoming $si:$sp - $rm - $ru, $fu");
......

!ifdef WITH_ANTIFLOOD

.....  
  if($gip2(src=>cc)=="FR") {
            xlog("L_INFO", "Block traffic is from France");
            sl_send_reply("403", "Drop SIP Call from France");
            exit;
    }

    if($ua =~ "FPBX|friendly|scanner|sipcli|sipvicious|VaxSIPUserAgent") {
            # silent drop for scanners - uncomment next line if want to reply
            # sl_send_reply("200", "OK");
            exit;
    }
....

send Country in INVITE ?

# Manage outgoing branches
branch_route[MANAGE_BRANCH] {
xdbg("new branch [$T_branch_idx] to $ru\n");
append_hf("X-Country: $gip2(src=>cc)\r\n");
route(NATMANAGE);
}

asterisk show X-Country

NoOp(${SIP_HEADER(X-Country)})

Leave a Reply

Your email address will not be published. Required fields are marked *