Forum Discussion
Matthew_M_23576
Nimbostratus
Oct 25, 2018Odd/Even IP address iRule
I have a VIP with 2 backend nodes, and I am trying to create an iRule that will forward traffic based on whether the last octet of the source IP address is an odd or even number (e.g. for ip_addr 10.10.10.x, if x is odd forward to node 1 or if even forward to node 2). Would that be possible via an iRule? I am still learning tcl, so any help would be appreciated.
- Lee_Sutcliffe
Nacreous
Try this iRule - let me know how you get on
when CLIENT_ACCEPTED { set lastOctet [getfield [IP::client_addr] "." 4] if {($lastOctet % 2) == 0} { log local0. "$lastOctet is even" node 10.10.10.2 } else { log local0. "$lastOctet is odd" node 10.10.10.1 } }
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