# Irule to allow specific IPs

**URL:** <https://community.f5.com/t/irule-to-allow-specific-ips/75266>\
**Category:** Technical Forums\
**Tags:** irules, waf, header-insert, security\
**Created:** [October 10, 2024, 1:46pm UTC](https://community.f5.com/t/irule-to-allow-specific-ips/75266 "2024-10-10T13:46:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vshah](https://avatars.discourse-cdn.com/v4/letter/v/cc9497/32.png) [@Vshah](https://community.f5.com/u/Vshah)\
**Post date:** [October 10, 2024, 1:46pm UTC](https://community.f5.com/t/irule-to-allow-specific-ips/75266/1 "2024-10-10T13:46:54Z")

</div>

I have a site which is [abc.com](http://abc.com)  
Trying to achieve below requirements-  
1) If uri is / it should redirect to [abc.com/xyz](http://abc.com/xyz) - open for all  
2) If uri is /rdp\_xyz\_tshoot should accessible to internal network - (here we can use the datagroup list)

As this site is migrated to akamai where they have requirement to use below irule-  
when HTTP\_REQUEST {&nbsp;  
&nbsp; &nbsp; if { [HTTP::header exists True-Client-IP] } {  
&nbsp; &nbsp; &nbsp; &nbsp; set trueclientip [HTTP::header True-Client-IP]  
&nbsp; &nbsp; &nbsp; &nbsp; HTTP::header replace X-Forwarded-For $trueclientip  
&nbsp; &nbsp; }  
}

Cause for above akamai irule=  
Normally the True-Client-IP header includes the real IP of the clients when requests are coming from Akamai.&nbsp;  
It will be unaffected and be sent as part of the request to the pool member. So, your backend servers could look for that header and do something with  
its value. However, if you want the F5 to translate it to the X-Forwarded-For header,&nbsp;  
you can use an iRule to convert the Akamai True-Client-IP header to the X-Forwarded-For header.

we are trying with below irule which is not working-  
when HTTP\_REQUEST {

if { ([HTTP::uri] starts\_with “/rdp\_xyz\_tshoot”) && (not[class match [IP::client\_addr] equals allowed\_IPs])}  
{ reject }

if { [HTTP::uri] == “/” &nbsp;}&nbsp;  
&nbsp;{  
&nbsp; &nbsp; &nbsp; HTTP::redirect “https://[HTTP::host]/abc\_login.jsp”  
&nbsp; &nbsp;}

}

Please help

---

<div class="post-metadata">

**Author:** ![Brenda\_Faviola](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/brenda_faviola/32/10857_2.png) [@Brenda\_Faviola](https://community.f5.com/u/Brenda_Faviola)\
**Post date:** [October 16, 2024, 3:34pm UTC](https://community.f5.com/t/irule-to-allow-specific-ips/75266/2 "2024-10-16T15:34:15Z")

</div>

I’m moving to technical Forum for visibility

---

<div class="post-metadata">

**Author:** ![zamroni777](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/zamroni777/32/1473_2.png) [@zamroni777](https://community.f5.com/u/zamroni777)\
**Post date:** [October 17, 2024, 1:14pm UTC](https://community.f5.com/t/irule-to-allow-specific-ips/75266/3 "2024-10-17T13:14:00Z")

</div>

in tcl “==” is for number comparison.  
for text/string, use “eq”

you should also check /var/log/ltm to see some details of irules error.
