Forum Discussion
10 Replies
Sort By
- Danims_19205NimbostratusHello everyone:
- nitassEmployeee.g.
[root@ve10:Active] config b virtual bar list virtual bar { snat automap pool foo destination 172.28.19.79:80 ip protocol 6 rules myrule profiles { mystats {} tcp {} } } [root@ve10:Active] config b profile mystats list profile stats mystats { defaults from stats field1 net172 field2 net192 field3 others } [root@ve10:Active] config b rule myrule list rule myrule { when CLIENT_ACCEPTED { if { [IP::addr [IP::client_addr] equals 172.28.19.0/16] } { STATS::incr mystats net172 1 } elseif { [IP::addr [IP::client_addr] equals 192.168.206.0/24] } { STATS::incr mystats net192 1 } else { STATS::incr mystats others 1 } } } [root@ve10:Active] config b profile mystats PROFILE STATS mystats parent stats | net172: 100 | net192: 1 | others: 0
- Danims_19205Nimbostratusooooo thank´s i try it.
- Danims_19205Nimbostratusooooo thank´s i try it.
- RubenMNimbostratus
Hi there
- RubenMNimbostratus
Confirmed. the iRule has a problem. If I set the first if condition to "true", first field stars to increase.
¿Any suggestions with the iRule networks evaluation?
- What_Lies_Bene1CirrostratusI'm not sure switch matches client addresses to subnets like an if statement would? If it does, you need some quotation marks at least;
when CLIENT_ACCEPTED { switch [IP::addr [IP::client_addr]] { "10.120.0.0/16" { STATS::incr mystats Stats_GER 1 } "10.110.0.0/16" { STATS::incr mystats Stats_CZ 1 } default { STATS::incr mystats Stats_Other 1 } } } [/code
- RubenMNimbostratusWe included the quotation in at the network definitions and still doesn't work. I'm very disappointed with the iRules languaje. I thought I would be more reliable and intuitive, but every time we need an iRule working, it needs rewriting and testing again and again util it works (when it does so!).
- What_Lies_Bene1CirrostratusAs with anything, experience and practise make things rather easier. So, just to be clear, you have created a Statistics Profile called 'mystats' and relevant counters with the names specified above and then assigned that profile to the Virtual Server yes? And everything matches case-wise? Remember everything is case sensitive with iRules.
when CLIENT_ACCEPTED { if { [IP::addr [IP::client_addr] equals 10.120.0.0/16] } { log local0. "Matched 10.120/16, incrementing Stats_GER" STATS::incr mystats Stats_GER 1 } elseif { [IP::addr [IP::client_addr] equals 10.110.0.0/16] } { log local0. "Matched 10.110/16, incrementing Stats_CZ" STATS::incr mystats Stats_CZ 1 } else { log local0. "Matched nothing, incrementing Stats_Other" STATS::incr mystats Stats_Other 1 } }
- RubenMNimbostratus
Finally we found solution to this very riddle.
The point was we have many partitions at our F5 (with its own route-domain). So, the correct declaration a network (IP address indeed) being checked by an iRule is as follows:
if { [IP::addr [getfield [IP::client_addr] "%" 1] equals 10.120.0.0/255.255.0.0] } { ....
where the "%" 1 forces LTM to check every route-domain till exact pattern shows up, if we understood correctly.
Special thanks to this link:
https://devcentral.f5.com/community/group/aft/2163370/asg/50
Regards.