Forum Discussion
Martin_Woodhous
Nimbostratus
Mar 21, 2007if, elseif and adding comments within.
I'm trying to write a rule to redirect users based on source IP subnet.
i've come up with the following, but i'd like to be able to add comments to identify each subnet to a name (this could be in a comment field or otherwise) to make it easier to (human) read.
I don't seem to be able to add comments within the "if" statement. Is this right or am i just formatting it wrong?
Also, is this the most efficient way to write the rule? or can i create a table of some kind and reference that? There may be more than one subnet going to a particular pool.
Thanks in advance!
rule redirect-based-on-source {
when CLIENT_ACCEPTED {
if { [IP::addr [IP::client_addr] equals 10.212.249.0/255.255.255.224] } {
pool Pool-1}
elseif { [IP::addr [IP::client_addr] equals 172.20.208.160/255.255.255.224] } {
pool Pool-2}
elseif { [IP::addr [IP::client_addr] equals 173.20.208.160/255.255.255.224] } {
pool Pool-3}
else {
pool Pool4
}
}
}
2 Replies
- Wes_98712
Nimbostratus
Hmm...interesting, I've added comments all over the place as follows:if { [ matchclass $my_uri contains $::some_class] } { if { $my_uri starts_with "/somestring" } { set my_host somenewhost set my_uri [HTTP::uri] HTTP::redirect "http://$my_host$myuri" } else { log local0. "URL: http://$my_host$my_uri" pool somepool }
Perhaps it is the placement of the that is in question? Not sure, but this works for me. - Martin_Woodhous
Nimbostratus
Gentlemen, Thanks for the information - in the end i was placing the comments in the wrong place. It's taken me this long to get access to the system to be able to update it. Thanks for your help.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects