Forum Discussion
Craig_13881
Jul 25, 2011Nimbostratus
Return DNS replies to specific clients
I'm trying to return DNS replies to only a couple of different subnets. If the request comes in from anything else, I'd like to ignore it, or return a bogus response. Trying to get this to work, but I'm sure I'm doing something wrong.
when DNS_REQUEST {
if { [IP::addr [IP::client_addr]/24 equals 10.0.0.0/24] or \
[IP::addr [IP::client_addr]/24 equals 192.168.76.0/24]
} {
pool Good_Pool
} else {
pool Dead_Pool }
}
- The_BhattmanNimbostratusHi Craig,
- Craig_13881NimbostratusHello. I'm running this on a GTM.
- Ryan_Paras_7933NimbostratusI don't have a GTM to test with :(
- Ryan_Paras_7933NimbostratusAfter getting some inspiration from this thread ... http://devcentral.f5.com/Community/GroupDetails/tabid/1082223/asg/50/aft/1177010/showtab/groupforums/Default.aspx
- Craig_13881NimbostratusI was originally sent to this thread by F5 support, but that didn't really meet my needs. http://devcentral.f5.com/wiki/iRules.DNS_REQUEST.ashx
- Ryan_Paras_7933Nimbostratusif you are looking to just drop traffic, I think you can just not define a default pool and only define a pool within the irule for the good conditional. Does that make sense?
- The_BhattmanNimbostratusHi Craig,
when DNS_REQUEST { if { !([IP::addr [IP::client_addr]/24 equals 10.0.0.0/24]) or !([IP::addr [IP::client_addr]/24 equals 192.168.76.0/24]) } { cname www.blahblahblah.com } }
- Craig_13881NimbostratusThat looks perfect, but when I test it out, I get www.blahblahblah.com even though the source IP in the packet capture is in the 192.168.76.0/24 range. I should mention that I'm testing this from my workstation, which is asking a Microsoft DNS server, and that DNS server is handing the request off to the GTM. I can see blahblahblah showing up in a Wireshark trace on my PC and I've verify the source IP that hitting the GTM with a TCPdump. I may try just putting the IP address of the DNS server in the iRule as a host entry instead of a subnet and see if I can get it to work. It's like the "if" condition is coming up "true" when it should evaluate to "false".
when DNS_REQUEST { if { !([IP::addr [IP::client_addr]/24 equals 10.0.0.0/24]) or !([IP::addr [IP::client_addr]/24 equals 192.168.76.0/24]) or !([IP::addr [IP::client_addr]/24 equals 172.16.1.0/24]) } { cname www.blahblahblah.com } }
- Craig_13881NimbostratusThe iRule below works, I just need to get the syntax correct for the subnets and I'll be good. Going to play around with that some more. 10.0.0.53 is the IP of the internal DNS server making the request to the GTM.
when DNS_REQUEST { if { ![IP::addr [IP::client_addr] equals 10.0.0.53] } { cname www.blahblahblah.com } }
- Craig_13881NimbostratusGot it! Had to change the "or" to an "and". I was never all that great with double negatives. 🙂
when DNS_REQUEST { if { !([IP::addr [IP::client_addr]/24 equals 10.0.0.0]) and !([IP::addr [IP::client_addr]/24 equals 172.16.1.0]) } { cname www.blahblahblah.com } } Thanks for you help. This seems to be working perfectly!
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