Forum Discussion
Adding a dynamic generic host to GTM
Hi
I don't think you can do this in GTM as you can in LTM with ephemeral nodes. A couple of altenate methods spring to mind...
Firstly you could do something with an iRule to intercept the DNS request as it goes to the listener, do a DNS lookup and then respond to the request based on this logic. This would look something like
when DNS_REQUEST {
if {[DNS::question type] eq "A"}{
if {[DNS::question name] eq "www.test.local"}{
set result [RESOLVER::name_lookup "/Common/dns2" www.f5.com a]
set answer [DNSMSG::section $result answer]
set first_rr [lindex $answer 1]
set rdata [DNSMSG::record $first_rr rdata]
# Generate an answer
DNS::answer insert "[DNS::question name]. 111 [DNS::question class] [DNS::question type] $rdata"
# Stop further processing of the query after this iRule and send the answer to the client
DNS::return
}
}
}
Or you could create some third party script to do a comparison between the DNS resolution or the server and the GTM Virtual Server address and then, if there are different, you can make some calls to update the GTM VS and Pool config. Below is a bash shell that I've cobbled together that shows the idea - this is very basic with no error handling so would need polishing. But you could use something like this either on the BIGIP and use tmsh calls or externally and make API calls - if the script ran to an acceptable schedule then GTM should be able to keep up with 3rd party DNS changes.
#!/bin/bash
#Setup some variables
#GTM Server Object Name
gtm_srv=My_Laptop
#GTM Server-Virtual Server
gtm_vs=my_server
#DNS Name to lookup
dns=(www.f5.co.uk)
#DNS lookup
dns_rec=$( dig +short $dns | grep -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')
#GTM Virtual Server
gtm_rec=$( tmsh list gtm server $gtm_srv virtual-servers { $gtm_vs { destination }} | grep -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | sed 's/destination//g' | cut -f1 -d":" | sed 's/^ *//g')
echo $dns_rec
echo $gtm_rec
#See if the values are different
if [ "$dns_rec" == "$gtm_rec" ]; then
echo "DNS and GTM are equal, no change"
else
tmsh modify gtm server $gtm_srv virtual-servers delete { $gtm_vs }
tmsh modify gtm server $gtm_srv virtual-servers add { $gtm_vs { destination $dns_rec:80}}
tmsh modify gtm pool a hello members add { $gtm_srv:$gtm_vs }
echo "GTM updated to reflect DNS change"
fi
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