# SIP irule for checking dialed string

**URL:** <https://community.f5.com/t/sip-irule-for-checking-dialed-string/10106>\
**Category:** Technical Forums\
**Tags:** irules, devops, application-delivery, ltm, sip\
**Created:** [August 21, 2015, 6:53pm UTC](https://community.f5.com/t/sip-irule-for-checking-dialed-string/10106 "2015-08-21T18:53:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Evelin\_195902](https://avatars.discourse-cdn.com/v4/letter/e/258eb7/32.png) [@Evelin\_195902](https://community.f5.com/u/Evelin_195902)\
**Post date:** [August 21, 2015, 6:53pm UTC](https://community.f5.com/t/sip-irule-for-checking-dialed-string/10106/1 "2015-08-21T18:53:08Z")

</div>

Hi guys, Please help me with creating na irule for checking a dialed string in SIP INVITE request. I need to drop every call that has !=8 or !=0 symbols in the SIP INVITE. Like this:

sip:3286184@206.81.166.10

I need to strip only “3286184” portion, then check if it has 8 or 0 symbols, if not I have to drop the call.

That’s the irule I’ve made but it’s not working for some reason…

```tcl
when SIP_REQUEST {
set meeting_nbr [findstr [SIP::header "INVITE"] ":" 1 "@"]
if { not [string length $meeting_nbr] == 8} || { not [string length $meeting_nbr] == 0} {
log local0. "SIP Drop [SIP::uri]"
    drop
        }
}

```

Please help.

thanks.

---

<div class="post-metadata">

**Author:** ![SyedNazir\_20946](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@SyedNazir\_20946](https://community.f5.com/u/SyedNazir_20946)\
**Post date:** [August 23, 2015, 7:41am UTC](https://community.f5.com/t/sip-irule-for-checking-dialed-string/10106/2 "2015-08-23T07:41:37Z")

</div>

Hi Evelin,

Check below rule. Correct the syntax for regexp if there is any issue.

```tcl
when SIP_REQUEST {

   set meeting_nbr [findstr [SIP::to] ":" 1 "@"]
   if { [regexp {^([0-9]+)$} $meeting_nbr]} {
       log local0. "SIP Drop [SIP::uri]"
       drop
   }
}

```

-- Syed Nazir

---

<div class="post-metadata">

**Author:** ![Evelin\_195902](https://avatars.discourse-cdn.com/v4/letter/e/258eb7/32.png) [@Evelin\_195902](https://community.f5.com/u/Evelin_195902)\
**Post date:** [September 17, 2015, 2:03pm UTC](https://community.f5.com/t/sip-irule-for-checking-dialed-string/10106/3 "2015-09-17T14:03:31Z")

</div>

Thanks Syed, It’s a bit more complicated because we may have valid SIP request without any meeting number: like sip: or sip:.

Here is the final version of my irule:

```tcl
when SIP_REQUEST {
    if { [SIP::method] == "INVITE" && [SIP::uri] matches_regex {^.+@.+$} }
    {
        if { not ([SIP::uri] matches_regex {^(sip:|sips:)[0-9]{7}@}) }
        {            
            log local0. "SIP Drop for [SIP::uri] from [IP::remote_addr] - possible frauder"
            drop   
        }

    }
}

```

I hope this can be useful for other people having similar case.

regards, Evelin
