Forum Discussion
Ken_B_50116
Cirrostratus
Jun 12, 2012How to select a pool based on client's hostname?
I need to write an iRule that will select a pool based on the requesting client's DNS hostname. I know an iRule can perform a reverse DNS lookup to get the client's hostname from the source IP addres...
Ken_B_50116
Cirrostratus
Jun 13, 2012Again, thanks for taking the time to work up that code. For the sake of simplicity, I'm going to try a version that avoids needing any data groups. This iRule is focused on matching the hostname and not the domain name, or the end of the FQDN.
when RULE_INIT {
Log debug to /var/log/ltm? 1=yes, 0=no.
set static::dns_debug 0
set static::dns_server 10.10.9.8
}
when CLIENT_ACCEPTED {
Get PTR for client's IP address
set ptr [RESOLV::lookup @$static::dns_server -ptr [IP::client_addr]]
if {$static::dns_debug}{log local0. "[IP::client_addr]:[TCP::client_port]: Resolved $ptr"}
Check if a pointer record was returned
if {$ptr eq ""}{
No PTR, so use the VS default pool
if {$static::dns_debug}{log local0. "[IP::client_addr]:[TCP::client_port]: No PTR!"}
pool [LB::server pool]
} else {
switch -glob -- [string tolower $ptr] {
"wtscern*" { pool pool_Multum_prod }
"wtsc4prod*" { pool pool_Multum_prod }
"wtsc4test*" { pool pool_Multum_nonprod }
"wtsc4cert*" { pool pool_Multum_nonprod }
"wtsc4edu*" { pool pool_Multum_nonprod }
"vmqa*" { pool pool_Multum_nonprod }
}
}
}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
