Implementing F5 DNS and Creating Custom CNAME Redirects
We are currently implementing a solution in Azure and have encountered some DNS-related issues. I think it's a good idea to implement F5 DNS. However, I wonder if we can create an iRule to set up a CNAME for a specific domain. In other words, if a domain like "example.com" is received, the iRule would inspect this request and respond to the user with a CNAME from "example.com" to "example.2.com".
I have created the following irule:
when DNS_REQUEST {
set original_name [DNS::question name]
if { [string tolower $original_name] ends_with "example.com" } {
set modified_name [string map {"example.com" "example.2.com"} [string tolower $original_name]]
DNS::question name $modified_name
set cname_record "${original_name} IN CNAME ${modified_name}."
log local0. "$cname_record"
set new_rr [DNS::rr $cname_record]
log local0. "$new_rr"
DNS::answer clear
DNS::answer insert $new_rr
DNS::header aa 1
DNS::return
}
}
If I see the logs it looks good:
<DNS_REQUEST>: test.example.com. IN CNAME test.example.2.com.
<DNS_REQUEST>: test.example.com. 3600 IN CNAME test.example.2.com
However, when I perform an nslookup, dig, or access the domain directly from the browser, it doesn't work.
nslookup:
nslookup test.example.com
Server: UnKnown
Address: x.x.x.x
Name: test.example.com
dig:
dig @x.x.x.x test.example.com
;; Question section mismatch: got test.example.2.com/A/IN
Browser:
DNS_PROBE_FINISHED_NXDOMAIN
Any idea if this is possible?