Forum Discussion
Implementing F5 DNS and Creating Custom CNAME Redirects
when DNS_REQUEST priority 500 {
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}. 300 IN CNAME ${modified_name}."
log local0. "cname_record is ${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::header rd 0
DNS::header ra 0
DNS::header ad 0
DNS::return
}
}
[root@NF42GTT1-A3:Active:Standalone] config # dig @172.16.53.53 www22.example.com
; <<>> DiG 9.11.31 <<>> @172.16.53.53 www22.example.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 60738
;; flags: qr aa; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www22.example.com. IN A
;; ANSWER SECTION:
www22.example.com. 300 IN CNAME www22.example.2.com.
;; Query time: 4 msec
;; SERVER: 172.16.53.53#53(172.16.53.53)
;; WHEN: Fri Sep 22 15:44:52 CST 2023
;; MSG SIZE rcvd: 76
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