irule to Redirect client from specific Public IP to a specific node

Hello,

I have a virtual server that is accessible by users on the internet with one pool.  This pool has 2 nodes.

I have a scenario where I need users coming from a specific PUBLIC IP to go to a specific node in the pool.  All other clients should always go to the other node.  I have tried a number of variations of irules but I am not getting consistent results.  It doesn’t matter where the client is coming from, they end up accessing both nodes eventually.

The f5 is performing SSL offloading to port 80 on both nodes.

Can someone help me figure out where I am going wrong with this irule?

when CLIENT_ACCEPT {
 if { [IP::addr [IP::client_addr] equals XXX.XXX.XXX.XXX] } {node 10.10.1.1 80
 } else {
node 10.10.1.2 80
 }
}

Thanks for any help that can be provided.

Hi @Nomar-13

If the public IP is just a single IP and not a range, you do not want IP::addr as that is used for comparisons. Try something like this instead:

when CLIENT_ACCEPTED <span class="token punctuation">{</span>
  <span class="token builtin">if</span> <span class="token punctuation">{</span> <span class="token punctuation">[</span>IP::client_addr<span class="token punctuation">]</span> <span class="token operator">==</span> '192.168.1.100' <span class="token punctuation">}</span> <span class="token punctuation">{</span>
    <span class="token keyword">set</span> <span class="token variable">matched_ip</span> 1
  <span class="token punctuation">}</span> <span class="token builtin">else</span> <span class="token punctuation">{</span> set matched_ip 0 <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
when HTTP_REQUEST <span class="token punctuation">{</span>
  <span class="token builtin">if</span> <span class="token punctuation">{</span> $<span class="token variable">matched_ip</span> <span class="token punctuation">}</span> <span class="token punctuation">{</span>
    node 10.10.1.1 80
  <span class="token punctuation">}</span> <span class="token builtin">else</span> <span class="token punctuation">{</span> node 10.10.1.2 80 <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

Thank you JRham!!.  That was it.  I appreciate your help.