For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Shivesh_Rege's avatar
Shivesh_Rege
Icon for Nimbostratus rankNimbostratus
Jul 06, 2016

Irule not working as expected with variable

Friends,

 

Could someone help me with below Irule , were I am trying to see in Geodb if the client ip is part of countries CU,IR,KP,SD,SY,UA or state Sevastopol,Krym in that case set a SEC variable to value .Based on that value have header insert as well if there exists Forwarded-For header take content/values of that and insert into custom header.

 

Thanks all in advance, Shivesh

 

Irule

when CLIENT_ACCEPTED { set srcip [IP::client_addr] set country [whereis $srcip country] set region [whereis $srcip state] switch [whereis $srcip country ] { "CU" - "IR" - "KP" - "SD" - "SY" - "UA" [whereis $srcip state ] { "Sevastopol'" - "Krym" { set SEC 1 } { set SEC 0 } } } } when HTTP_REQUEST { switch {[HTTP::header values "X-Forwarded-For"] ne ""{ HTTP::header insert "ABCD-INFRA-OrigXFF" [HTTP::header values "X-Forwarded-For" ]}} HTTP::header replace ABCD-INFRA-XFF [$srcip] HTTP::header replace X-Forwarded-For [$srcip] switch $SEC { "1" { HTTP::header insert ABCD-INFRA-IPI $srcip HTTP::header insert ABCD-INFRA-GeoCountry $country HTTP::header insert ABCD-INFRA-GeoRegion $region HTTP::header insert ABCD-INFRA-SEC True } "0" { HTTP::header insert ABCD-INFRA-IPI $srcip HTTP::header insert ABCD-INFRA-GeoCountry $country HTTP::header insert ABCD-INFRA-GeoRegion $region HTTP::header insert ABCD-INFRA-SEC False } } }

 

1 Reply

  • Use the "preformatted code" button - 4th from left when posting code. This will make it better readable.