iRule redirect based on port

All,

I am trying to redirect to two different hosts base on port number. One server is hosting SMTP and the other POP3. The following rule seems valid but dosen’t seem to work. Any suggestions?

when CLIENT_DATA {

if { [TCP::remote_port] contains “110” } {

pool POP3

}

elseif { [TCP::remote_port] contains “25” } {

pool SMTP

} else {

discard}

}

(Moved post to iRules v9.x forum.)

Try this instead:

when CLIENT_ACCEPTED {
  if {[TCP::remote_port] == 110} {
    pool POP3
  } elseif {[TCP::remote_port] == 25} {
    pool SMTP
  } else {
    discard
  }
}

/deb

If the F5 is receiving the request, shouldn’t the rule examine TCP::local_port on the client side? I think it would be TCP::remote port on the server side.

Why don’t you use 2 separate virtual servers (with the same IP and different ports) with each pointing to a different pool?