Forum Discussion
JCMATTOS_41723
Nimbostratus
Nov 21, 2008Loadbalance using names?
Hello Everyone,
We are trying to loadbalance thru our LTM's using names instead of IP's. We contacted F5 support and they said there might be way using an iRule. Essentially, we are trying to loadbalance to an external site which changes IP's often and everytime they make a change it breaks our product. I should also mention we are using the proxypass irule to do header rewriting, not sure if it matters. Please help! Thx...
- James_Quinby_46Historic F5 AccountJC -
- JCMATTOS_41723
Nimbostratus
I applied the irule and tmm/named.conf change and I keep getting this error? And I did restart the tmm...Still no luck! Does this work with 9.4.5? Thx! - hoolio
Cirrostratus
You're using $::server_ip before setting a value for it. Can you try the example below instead. Also, you might want to add some error handling if the name resolution doesn't return an IP address before trying to use it for the connection. You can use IP::addr (Click here) to do this:when RULE_INIT { Hostname to resolve address for set ::hostname "example.com" Resolve the hostname every X connections set ::max 10 Force a lookup on the first connection set ::count 10 } when CLIENT_ACCEPTED { Increment the global count of TCP connections incr ::count If we're over the limit, try to resolve the hostname if { $::count > $::max } { NAME::lookup $::hostname } else { Under the max, so use the saved IP address for this connection node $::server_ip 80 } } when NAME_RESOLVED { set answer [NAME::response] log local0. "Received answer for $::hostname: $answer" Check if response is an IP address if {[IP::addr $answer mask 255.255.255.255]}{ Save the most recent answer for the hostname set ::server_ip $answer Reset the count as we've successfully resolved the name set ::count 0 Specify the updated IP address for this connection node $::server_ip 80 Current answer wasn't an IP address, so check if there is a previous valid IP } elseif {[info exists ::server_ip] and [IP::addr $::server_ip mask 255.255.255.255]}{ Specify the updated IP address for this connection node $::server_ip 80 No valid IP address to use, so take some default action? } else { log local0. "[IP::client_addr]:[TCP::client_port]: Error: No valid IP address for $::hostname" } }
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