Forum Discussion

Olowndez's avatar
Olowndez
Icon for Nimbostratus rankNimbostratus
Sep 28, 2020

iRule error elseif undefined procedure

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.

  • 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
    	}
    }
  • 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
    	}
    }
  • Hello Andrew:

     

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

     

    Regards.

     

    Omar