Forum Discussion

AbdullahAlshehri's avatar
AbdullahAlshehri
Icon for Altostratus rankAltostratus
Apr 26, 2022

F5 iRule Geolocation restriction

Hello, I want to know how I can restrict the access to specific one country only via iRule. For example: allow only users to access from "US" and block all other countries.
  • David_Gill's avatar
    Apr 28, 2022
    when FLOW_INIT {
    
        #
        # Drop everything except US
        #
        if { ! ([whereis [IP::client_addr] country] equals "US") } {
            log -noname local0. "Dropping connection from [IP::client_addr]/[whereis [IP::client_addr] state country continent ]"
            drop
        } 
    }

    AFM not required.