Difference between revisions of "Block Country"

From Tech-Wiki
Jump to: navigation, search
(Created page with "Category:F5 Networks '''Back to iRules''' # negative logic when CLIENT_ACCEPTED { # Get the country client IP switch [whereis [IP::clien...")
 
 
Line 2: Line 2:
 
'''[[F5 Networks#iRules|Back to iRules]]'''
 
'''[[F5 Networks#iRules|Back to iRules]]'''
  
# negative logic
+
Block using negative logic
 
  when CLIENT_ACCEPTED {
 
  when CLIENT_ACCEPTED {
 
     # Get the country client IP  
 
     # Get the country client IP  
Line 19: Line 19:
 
  }
 
  }
  
# positive logic  
+
Block using positive logic  
 
  when CLIENT_ACCEPTED {
 
  when CLIENT_ACCEPTED {
 
     # Get the country client IP  
 
     # Get the country client IP  

Latest revision as of 19:48, 20 May 2019

Back to iRules

Block using negative logic

when CLIENT_ACCEPTED {
   # Get the country client IP 
   switch [whereis [IP::client_addr] country] {
       "CN" -
       "RU" {
           set allowed 0
       }
       default { set allowed 1 }
   }
}
when HTTP_REQUEST {
   if {$allowed == 0}{
       HTTP::respond 403 content {Blocked!}
   }
}

Block using positive logic

when CLIENT_ACCEPTED {
   # Get the country client IP 
   switch [whereis [IP::client_addr] country] {
       US -
       CA -
       MX {
           set allowed 1
       }
       default { set allowed 0 }
   }
}
when HTTP_REQUEST {
   if {$allowed == 0}{
       HTTP::respond 403 content {Blocked!}
   }
}