iRule with two data groups both using external files one working (addr) and one not (str)
I have an iRule in place that checks the IP address of an off-site host,
then it checks the IP address of the client and with a class match to see if it is contained in an external file (type addr)
if it is, the node is selected as the off-site host,
if not it checks the name of the client with a class match to see if it is contained in an external file (type str)
if it is, the node is selected as the off-site host,
if not the connection is dropped
The iRule works as far as checking the off-site host and checking the client IP address against the external address list but when the IP of the client is not in the IP list but the name of the client is, the class match is not matching.
My iRule:
when CLIENT_ACCEPTED {
set ips [RESOLV::lookup @x.x.x.x -a "smtp-relay.gmail.com"]
set nps [RESOLV::lookup @x.x.x.x [IP::client_addr]]
log local0. "Looked up smtp-relay.gmail.com and found $ips, parsed first element: [lindex $ips 0]"
log local0. "Looked up client IP and found $nps, parsed first element: [lindex $nps 0]"
if
{[class match [IP::client_addr] equals whitelist-smtps] or
[class match [lindex $nps 0] ends_with whitelist-smtp-names]} {
log local0. "accepted client IP = [IP::client_addr]"
log local0. "accepted client name = [lindex $nps 0]"
node [lindex $ips 0]
}
else {log local0. "smtp client dropped [IP::client_addr]"
drop }
}
The two data groups have external files that were imported into the ifiles area while creating the data groups.
the whitelist-smtps file looks like this:
host 10.32.8.92 := "host1",
host 10.41.69.188 := "host2",
host 10.44.4.158 := "host3",
host 10.63.253.164 := "host4",
host 10.65.11.144 := "host5",
host 10.65.14.220 := "host6",
host 10.66.1.43 := "host7",
and the whitelist-smtp-names file looks like this:
"str1" := "pims.cc.nd.edu",
"str2" := "controls.ame.nd.edu",
"str3" := "maul.chem.nd.edu",
"str4" := "grumpy.cse.nd.edu",
"str5" := "wizard.cse.nd.edu",
"str6" := "ariel.ee.nd.edu",
"str7" := "services.ee.nd.edu",
"str8" := "nomex.eeit.nd.edu",
What am I doing wrong?