Forum Discussion
Aforester_2020
Feb 03, 2012Nimbostratus
redirect to pool member based on Subnet
I am very new to iRule creation. I have a group of subnets that need to be directed to a specific pool member when any traffic from them comes into the VIP.
Any help is appreciated!
- nitassEmployeee.g.
[root@ve1023:Active] config b virtual bar list virtual bar { snat automap destination 172.28.19.79:80 ip protocol 6 rules myrule } [root@ve1023:Active] config b rule myrule list rule myrule { when CLIENT_ACCEPTED { set vs "[IP::local_addr]:[TCP::local_port]" if {[IP::addr [IP::client_addr] equals 172.28.19.0/24]}{ pool foo1 } else { pool foo2 } } when SERVER_CONNECTED { log local0. "[IP::client_addr]:[TCP::client_port] -> $vs -> [IP::server_addr]:[TCP::server_port]" } } [root@ve1023:Active] config b pool foo1 list pool foo1 { members 200.200.200.101:80 {} } [root@ve1023:Active] config b pool foo2 list pool foo2 { members 200.200.200.102:80 {} } [root@ve1023:Active] config cat /var/log/ltm Feb 3 08:39:57 local/tmm info tmm[4369]: Rule myrule SERVER_CONNECTED: 172.28.19.80:50344 -> 172.28.19.79:80 -> 200.200.200.101:80 Feb 3 08:40:11 local/tmm info tmm[4369]: Rule myrule SERVER_CONNECTED: 192.168.204.8:53455 -> 172.28.19.79:80 -> 200.200.200.102:80
- Aforester_2020NimbostratusThank you. What does the set vs do? Do i edit that at all or do I just leave it as is? And if I need to do multiple subnets do I just repeat the line or would it be better to do a data group?
- nitassEmployeevs variable and SERVER_CONNECTED event are used for logging. please feel free to remove it.
[root@ve1023:Active] config b rule myrule list rule myrule { when CLIENT_ACCEPTED { set vs "[IP::local_addr]:[TCP::local_port]" if {[class match -- [IP::client_addr] equals subnet_list]}{ pool foo1 } else { pool foo2 } } when SERVER_CONNECTED { log local0. "[IP::client_addr]:[TCP::client_port] -> $vs -> [IP::server_addr]:[TCP::server_port]" } } [root@ve1023:Active] config b class subnet_list list class subnet_list { network 172.28.19.0/24 } [root@ve1023:Active] config cat /var/log/ltm Feb 3 08:51:04 local/tmm info tmm[4369]: Rule myrule SERVER_CONNECTED: 172.28.19.80:59652 -> 172.28.19.79:80 -> 200.200.200.101:80 Feb 3 08:51:07 local/tmm info tmm[4369]: Rule myrule SERVER_CONNECTED: 192.168.204.8:53813 -> 172.28.19.79:80 -> 200.200.200.102:80
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