Jump to content
Toggle menu
  • 51 articles
  • 24 files
  • 4 users
  • 750 edits
Tech-Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Block Country

From Tech-Wiki


Technical reference for Block Country.

Reference

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!}
   }
}

See also