cancel
Showing results for 
Search instead for 
Did you mean: 

iRule error elseif undefined procedure

Olowndez
Nimbostratus
Nimbostratus

Hello guys:

 

I am trying to configure an iRule that performs load balancing based on the client IP. I need to load balance based on entire networks and based on some specific IP address. Those entire networks are 172.16.0.0/16, 172.17.0.0/16, 172.18.0.0/16, 192.168.20.0/24 and others. On the other hand, some specific client IPs are 172.17.0.20 (to be load balanced to pool_B), 192.168.20.10 (to be load balanced to pool_C) and others. Therefore, I guess I need to configure an iRule considering a data group so I can group all the nets and then, configure the LB lines to the specific client IPs. The iRule I wrote is:

 

when CLIENT_ACCEPTED {  if { [class match [IP::client_addr] equals My_NETS] } {   pool pool_A   snatpool snat_pool_A  }  elseif { [IP::addr [IP::client_addr] equals 172.17.0.20] } {   pool pool_B   snatpool snat_pool_B  }  elseif { [IP::addr [IP::client_addr] equals 192.168.20.10] } {   pool pool_C   snatpool snat_pool_C  } }

 

But I'm getting this error: 01070151:3: Rule [/Common/test] error: /Common/test:11: error: [undefined procedure: elseif][elseif { [class match [IP::client_addr] equals 172.17.0.20] } {

 

I hope you could help me with this question.

 

Thaks.

1 ACCEPTED SOLUTION

Andrew-F5
F5 Employee
F5 Employee

What software version are you running? I wasn't able to reproduce the issue in v14.1.2.7.

 

I imagine you're running into something like what's described in this other DevCentral post.

 

You can try restructuring your iRule as follows to see if the error goes away:

when CLIENT_ACCEPTED { if { [class match [IP::client_addr] equals My_NETS] } { pool pool_A snatpool snat_pool_A } elseif { [IP::addr [IP::client_addr] equals 172.17.0.20] } { pool pool_B snatpool snat_pool_B } elseif { [IP::addr [IP::client_addr] equals 192.168.20.10] } { pool pool_C snatpool snat_pool_C } }

 

View solution in original post

2 REPLIES 2

Andrew-F5
F5 Employee
F5 Employee

What software version are you running? I wasn't able to reproduce the issue in v14.1.2.7.

 

I imagine you're running into something like what's described in this other DevCentral post.

 

You can try restructuring your iRule as follows to see if the error goes away:

when CLIENT_ACCEPTED { if { [class match [IP::client_addr] equals My_NETS] } { pool pool_A snatpool snat_pool_A } elseif { [IP::addr [IP::client_addr] equals 172.17.0.20] } { pool pool_B snatpool snat_pool_B } elseif { [IP::addr [IP::client_addr] equals 192.168.20.10] } { pool pool_C snatpool snat_pool_C } }

 

Olowndez
Nimbostratus
Nimbostratus

Hello Andrew:

 

Thank you very much..! As you recommended, I restructured the iRule and it worked like a charm. 🙂

 

Regards.

 

Omar