Forum Discussion
Use DNS server list for DNS resolution through F5 LTM irule
We already use DNS resolution using one specific DNS server in RESOLV::lookup. I am trying to figure out a solution where i can use a list of DNS servers and not finding any resources for it.
Can someone help me with it?
Following is a sample i got off devcentral:
Select the first returned IP address as the destination IP (inherits the destination port from the client's destination port).
when RULE_INIT { set static::dns_vs my_dns_vs } when CLIENT_ACCEPTED { Get IP(s) for hostname against 4.2.2.1 name server set ips [RESOLV::lookup @$static::dns_vs -a ";] Log result. If there are multiple IP's it could be a TCL list like {1.1.1.1 2.2.2.2 3.3.3.3}. log local0. "Looked up and found $ips, parsed first element: [lindex $ips 0]" Check if the first list element was empty if {$ips eq ""}{ Input wasn't an IP address, take some default action? } else { Select the IP node [lindex $ips 0] } }
- jayanthi_41101
Nimbostratus
Any help?
- tcastaing_23984
Nimbostratus
Here is a working solution that is choosing randomly a DNS server from the specified list.
FQDN to resolve set FQDN_TO_RESOLVE "www.example.com" DNS server list set DNS_SERVER_LIST {1.1.1.1 2.2.2.2 3.3.3.3} Select a DNS server from the list set SELECTED_DNS_SERVER "[lindex $DNS_SERVER_LIST [expr {int(rand()*[llength $DNS_SERVER_LIST])}]]" Perform the Lookup set FQDN_RESOLVED_IP "[lindex [RESOLV::lookup @$SELECTED_DNS_SERVER -a $FQDN_TO_RESOLVE] 0]"
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