Forum Discussion
iRule giving error: rule [/common/ecs_rule] error: /common/ecs_rule:6: error: [undefined procedure:
Hi
I am trying to run a setup with GTM.
Here I have ECS enabled on client requesting DNS query. Behind F5 I have 2 DNS server configured. Now I can see the packet recived by F5 has client subnet information.
But F5 still round robin between the server while selecting the server for a query. I want to forward request to a particluar server instead of round robin based on Client Subnet value. For example if client subnet is
172.31.177.0, send it to server 172.30.112.9 else send it to 172.30.112.8
I am trying to create iRule like below but am not able to create it as getting error: rule [/common/ecs_rule] error: /common/ecs_rule:6: error: [undefined procedure: host]
Any suggestion or way to create this setup?
when DNS_REQUEST {
if { [DNS::edns0 exists] } {
# log local0. [DNS::edns0 subnet address]"
set ecs_address [DNS::edns0 subnet address]
if { $ecs_address == "172.31.177.0" } {
log local0. "Received EDNS request from [IP::client_addr]:$ecs_address"
host 172.30.112.9
}else {
log local0. "Received EDNS request from [IP::client_addr]:$ecs_address"
host 172.30.112.8
}
}
}
- JRahmAdmin
bindummawat is correct, the host command only works in GTM context, you need to use node command in LTM context. Untested, and not for production, but just playing around with how to distinguish between both contexts in a single iRule, something that might work in a lab environment (Seriously, LAB ONLY):
when DNS_REQUEST { if { [catch { [DNS::is_wideip [DNS::question name]] }]} { # DNS::is_wideip is an LTM-only command, and will trigger a Tcl error on GTM # This is a GTM request, using host command } else { # This is an LTM request, using node command } }
bindummawat I found some odd formating such as spaces around variables and events which I have adjusted. Try this iRule and see if you receive the same or another error. If you do receive an error please post it here.
when DNS_REQUEST { if { [DNS::edns0 exists] } { # log local0. [DNS::edns0 subnet address]" set ecs_address [DNS::edns0 subnet address] if { ${ecs_address} == "172.31.177.0" } { log local0. "Received EDNS request from [IP::client_addr]:${ecs_address}" host 172.30.112.9 } else { log local0. "Received EDNS request from [IP::client_addr]:${ecs_address}" host 172.30.112.8 } } }
- bindummawatAltostratus
The same works under GSLB-iRules but did not work Delivery-iRules.
But I found another solution using node <ip> <port> and that worked for my requirement.
Thanks
Recent Discussions
Related Content
* 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