Forum Discussion
Mario_Eury_6049
Nimbostratus
Dec 18, 2006Switch Command
I'm trying to use the "switch" syntac command to load balance traffic based on a client's subnet/network address. I have a list of subnets that would need to be listed to load balance to the test_pool and everything else would go to the default pool. Here is what I have.
when CLIENT_ACCEPTED {
set IPADDR [IP::remote_addr]
switch $IPADDR {
192.168.100.0/255.255.255.192
{
pool test_pool
}
default
{
pool default_pool
}
}
}
The actual "syntac" of this rule works, but I can't seem to get the "functionality" to work. Can anyone help with this.
3 Replies
Sort By
- hoolio
Cirrostratus
I don't think you can do comparisons within the switch conditions. You could try using an if/elseif/elseif/else format:when CLIENT_ACCEPTED { set IPADDR [IP::remote_addr] if { [IP::addr $IPADDR equals 192.168.100.0/26] }{ pool test_pool } elseif { [IP::addr $IPADDR equals 10.10.0.0/16] }{ pool condition2_pool } else { pool default_pool } }
- Mario_Eury_6049
Nimbostratus
thanks for the reply. I can use the if/elseif syntac, but for what i'm trying to do, that would be a long script. We use vlans and most of our segments are 64 and 128 address segments. Campus wide we have about 800 vlans. If I was to elseif all the segments for this, it would be too long. I'm trying to figure out how to use the switch command to list all my variables to test against then send the client to the right pool. Hopefully, i explained it a little better. Thanks - hoolio
Cirrostratus
You could add your subnets and corresponding pools to a class (called a datagroup in the GUI) and then use the findclass command to get the mapping.
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