Forum Discussion

FFX2014_23725's avatar
FFX2014_23725
Icon for Nimbostratus rankNimbostratus
Apr 02, 2013

iRule to allow private IP and reject public IP

I am new to using iRules. What I’m looking to do is to restrict a page to only be accessible from a private IP address range, and reject connections from all public IP addresses.

 

 

I used the rule below that I found on this forum, however it didn't work 100%. It was successful in allowing private address and restricting public address, however the VIP that is using this rule is hosting multiple websites. When using this rule the restriction is set on all websites, not the one I specifically need it for. How can I modify this to address the issue?

 

 

 

 

when HTTP_REQUEST {

 

 

if { [HTTP::host] equals "www.website.com" and ([matchclass [IP::remote_addr] equals $::PoolOfAllowedAddresses ]) } {

 

 

pool poolofallowedservers

 

 

}

 

 

else {

 

 

reject

 

 

}

 

 

}

 

 

1 Reply

  • you should just need a slilght change in logic:

    when HTTP_REQUEST {
    
        if { [HTTP::host] equals "www.website.com" and ! ([matchclass [IP::remote_addr] equals $::PoolOfAllowedAddresses ]) } {
            reject
        }
        else {
            pool poolofallowedservers
        }
    }