Forum Discussion
Move Permanently execpt for different ip's
Hello,
I have this irule and it's working fine but now i have to add a new ipaddress in the range C.D.0.0/16. How can i do this?
when HTTP_REQUEST { if {not ([IP::addr [getfield [IP::client_addr] "%" 1] equals A.B.0.0/16]) } { set my_loc "https://[HTTP::host][HTTP::uri]" TCP::respond "HTTP/1.1 301 Moved Permanently\r\nLocation: $my_loc\r\nConnection: close\r\nContent-Length: 0\r\n\r\n" TCP::close
} }
Greetings, Fred
4 Replies
- Brad_Parker
Cirrus
This should do the trick.
when HTTP_REQUEST { if { not ([IP::addr [getfield [IP::client_addr] "%" 1] equals A.B.0.0/16] || [IP::addr [getfield [IP::client_addr] "%" 1] equals C.D.0.0/16]) } { HTTP::respond 301 noserver Location "https://[HTTP::host][HTTP::uri]" Connection close TCP::close } } - Fred_Zandvliet_
Nimbostratus
Hi Brad,
Thanks for your answer but it's not working. If the ip-address is C.D.A.A then the first part of the rule is already triggered.
It has to be something like "if not ip A.B.0.0/16 or if not C.D.0.0/16 then .." But I can't figure out what the syntax must be ..
Greetings, Fred
- Brad_Parker
Cirrus
I over looked how the not would affect the elseif, I have updated it to use an OR(||). This should do the trick.
- Fred_Zandvliet_
Nimbostratus
Hi Brad,
Yep that did it! Thanks for your support!!
Greetings, Fred Zandvliet
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com