Forum Discussion
Ferzat_263580
Nimbostratus
May 12, 2016Redirect hosts using iRules
Hi all,
How can I achieve the below using iRules.
if clients from [network1, network2...] querying [sub.domain.com] --answer--> 1.2.3.4;
Yann_Desmarest
Cirrus
May 12, 2016Ok, let's try this one 🙂
when DNS_REQUEST {
set ttl 1800
set A "[DNS::question name]. $ttl [DNS::question class] [DNS::question type]"
if { [string tolower [DNS::question name]] ends_with "sub.domain.com" } {
DNS::answer insert "$A 1.2.3.4"
}
DNS::return
}
- Ferzat_263580May 13, 2016
Nimbostratus
Thank you Yann. How can I filter on a specific network for the above. e.g. if clients = match-clients { 10.1.1.0/13; 10.2.1.0/13; ...etc } querying for "sub.domain.com" do when DNS_REQUEST { set ttl 1800 set A "[DNS::question name]. $ttl [DNS::question class] [DNS::question type]" if { [string tolower [DNS::question name]] ends_with "sub.domain.com" } { DNS::answer insert "$A 1.2.3.4" } DNS::return } - Yann_DesmarestMay 13, 2016
Cirrus
You have to use "class match" command to compare [IP::client_addr] with a datagroup that contains the filtered IP subnet. You can find several peace of code in devcentral - Ferzat_263580May 17, 2016
Nimbostratus
Thanks Yann, is the below correct when DNS_REQUEST { if { [string tolower [DNS::question name]] ends_with "sub.domain.com" } { if { ( [IP::addr [IP::client_addr] equals 10.1.0.0/13] ) or ( [IP::addr [IP::client_addr] equals 10.2.0.0/13] ) } { set ttl 10800 set A "[DNS::question name]. $ttl [DNS::question class] [DNS::question type]" DNS::answer insert "$A 10.10.10.2" } } else { return } DNS::return }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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