Forum Discussion
madi_56757
Nimbostratus
Dec 05, 2006dynamic destination conditioned by dns query
hello all,
I have a question regarding my rule.
I get a lot of IPs of my DNS query and i like to forward my traffic to this addresses, or to one of this address, but not without the test if the node available
---------------------------------------------------------------------
when HTTP_REQUEST {
set uri [HTTP::uri]
set hostname [getfield [HTTP::host] ":" 1]
set port [URI::port $uri]
log local0. "Uri - $uri"
log local0. "Hostname - $hostname"
log local0. "Port - $port"
Start a name resolution on the hostname
NAME::lookup $hostname
Hold HTTP data until hostname is resolved
HTTP::collect
}
when NAME_RESOLVED {
set ip [NAME::response]
log local0. "IP - $ip"
use everytime the first IP address this works very well
set saddress [getfield $ip " " 1]
log local0. "saddress - $saddress"
use node saddress 80
HTTP::release
}
OK and now what i need, instead of use everytime the fist IP address
select all ip's
OK on this point we have to find a routin
set ip1 [getfield $ip " " 1]
set ip2 [getfield $ip " " 2]
set ip3 [getfield $ip " " 3]
...
than monitor and use the node
if "$ip1:80" available
use node $ip1 80
ifelse "$ip2:80" available
use node $ip2 80
...
HTTP::release
}
I think I am close to my goal but
could anyone help me?
thanks
Madi
- Deb_Allen_18Historic F5 AccountHi Madi -
- madi_56757
Nimbostratus
hey, - Deb_Allen_18Historic F5 AccountYou might be able to use LB_FAILED to catch the condition:
when NAME_RESOLVED { set ip [NAME::response] log local0. "IP - >$ip<" if {($ip == "")}{ HTTP::redirect http://host.domain.com/sorry.html } else { set index 0 use node [lindex $ip 0] 80 HTTP::release } } when LB_FAILED { incr index if {!([lindex $ip $index] =="")}{ use node [lindex $ip $index] 80 HTTP::retry } else { HTTP::redirect http://host.domain.com/sorry.html } }
- Deb_Allen_18Historic F5 AccountAh, HTTP::retry was introduced in LTM 9.2.0, so you'll need to upgrade.
- Deb_Allen_18Historic F5 AccountJust realize the HTTP::retry request syntax isn't correct.
when HTTP_REQUEST { set request [HTTP::request] set hostname [getfield [HTTP::host] ":" 1] log local0. "Uri - [HTTP::uri] Hostname - $hostname Port - [TCP::local_port]" HTTP::collect NAME::lookup $hostname } when NAME_RESOLVED { set ip [NAME::response] log local0. "IP - >$ip<" if {($ip == "")}{ HTTP::redirect http://host.domain.com/sorry.html } else { set index 0 use node [lindex $ip 0] 80 HTTP::release } } when LB_FAILED { incr index if {!([lindex $ip $index] =="")}{ use node [lindex $ip $index] 80 HTTP::retry $request } else { HTTP::redirect http://host.domain.com/sorry.html } }
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