For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

EdC's avatar
EdC
Icon for Nimbostratus rankNimbostratus
May 04, 2017

iRule to provide alternate DNS CNAME response based on geolocation of Requestor

I have created a WideIP for testing.siterequest.com and want to be able to respond to a DNS request for this host with one of two CNAMEs based on geolocation.

If the source IP address is based in China, then I want to respond with cname.cncloud.com. Any other response should be to cname.cloud.com. The reason for doing this is based upon the fact that we use a specific CDN provider within China to improve application performance.

I attempted to use a simple iRule on the WideIP as below:

when DNS_REQUEST {
if { [whereis [IP::client_addr] country] equals "CN"} {
  cname cname.cncloud.com
  } else {
  cname cname.cloud.com
}
}

I have no default pool associated with the WideIP. Even from a host within China, all DNS responses return cname.cloud.com.

As an additional test, I created two pools and used the advanced settings to define a CNAME for each one. cloudcn_pool and cloud_pool.

The new irule is defined as such:

when DNS_REQUEST {
if { [whereis [IP::client_addr] country] equals "CN"} {
  pool cloudcn_pool
  } else {
  pool cloud_pool
  }
}

This iRule appears to have the desired effect, but there is one additional issue that is being reported. If a client performs a lookup directly against the DNS listener of one of my GTM devices, the lookup response is blank.

Through further testing, it appears that this blank response ONLY occurs when using a Microsoft OS and the nslookup command.

What am I missing? Is there a better way to do what I am trying to do?