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
5 Replies
- Deb_Allen_18Historic F5 AccountHi Madi -
If I understand correctly what you're after, I don't think you can do that with LTM/iRules.
In order to get status of a node, it has to be a defined pool member in the LTM configuration, which of course will not be the case for dynamic destinations.
HTH
/deb - madi_56757
Nimbostratus
hey,
What a bummber!
OK I think you had understand me correctly!
but is it possible to send the request to the fist address, and if this request failed use the second address!
and please, can somebody tell me how is the rule for the routine
when NAME_RESOLVED {
set ip [NAME::response]
log local0. "IP - $ip"
select all ip's because I can get a lot of!
on this point we have to find the routin
set ip1 [getfield $ip " " 1]
set ip2 [getfield $ip " " 2]
set ip3 [getfield $ip " " 3]
...
use node $ip1 80
if this request failed
use node $ip2 80
...
HTTP::release
}
thanks
Madi - 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 - Deb_Allen_18Historic F5 AccountAh, HTTP::retry was introduced in LTM 9.2.0, so you'll need to upgrade.
With your current iRule, you should be able to see in a packet trace the request being sent to the first server when HTTP::release is issued. However, the HTTP::retry command you removed is the mechanism by which the same request could be re-sent to a different server, so you won't see any subsequent requests being sent until you add that back in.
Good luck!
/deb - Deb_Allen_18Historic F5 AccountJust realize the HTTP::retry request syntax isn't correct.
Try this instead: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 } }
/deb
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