Forum Discussion

Sajid_284881's avatar
Sajid_284881
Icon for Nimbostratus rankNimbostratus
Jun 22, 2017

Block URI based on Source IPs

Dear Team, i need to block the following URI for all internet users but needs to allow for some LAN users based on ip address following are the URIs that i need to block

 

 

for testing pupose i have created a below i rule but this i rule is not working fine

 

when HTTP_REQUEST { log local0. "Path = [string tolower [HTTP::path]]" log local0. "Client IP = [IP::client_addr]" if { [string tolower [HTTP::path]] contains "MyHiddenLoginPage.aspx" } { if { !([IP::addr [IP::client_addr] equals 10.0.0.8]) } { discard log local0. " Just discarded a request! "} else { log local0. "Just processed a request!" } } }

 

5 Replies

  • What testing have you performed, and what results are you getting vs what you expect?

     

    I tried to pretty this up a bit as it was difficult to read from your OP. Does this look like what you have? (When you post one of these, use the 'pre-formatted code' button to make the code more readable.)

     

    when HTTP_REQUEST {
        log local0. "Path = [string tolower [HTTP::path]]"
        log local0. "Client IP = [IP::client_addr]"
        if { [string tolower [HTTP::path]] contains "MyHiddenLoginPage.aspx" } {
            if { !([IP::addr [IP::client_addr] equals 10.0.0.8]) } {
                discard
                log local0. " Just discarded a request!"
            } else {
                log local0. "Just processed a request!"
            }
        }
    }

    One immediate issue I notice is your If-test. You use the 'string tolower' conversion to make the string all lower-case, but then you attempt to test against a mixed-case string. That will never match. Change your test text to all lower-case, or if you want a case-sensitive match remove the 'string tolower' operation.

     

    When you move to production do you plan to use a data-group to hold your 'LAN user' IPs for the IP address match? That would be a good idea to allow flexibility and scalability for your matches. There are many DevCentral posts for using data-groups for matching, though you may already be familiar with the syntax.

     

  • i tried drop instead of discard still the result is same page is still opening