Forum Discussion

Nomar-13's avatar
Nomar-13
Icon for Nimbostratus rankNimbostratus
Feb 16, 2024

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 {
      if { [IP::client_addr] == '192.168.1.100' } {
        set matched_ip 1
      } else { set matched_ip 0 }
    }
    when HTTP_REQUEST {
      if { $matched_ip } {
        node 10.10.1.1 80
      } else { node 10.10.1.2 80 }
    }
    
  • 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 {
      if { [IP::client_addr] == '192.168.1.100' } {
        set matched_ip 1
      } else { set matched_ip 0 }
    }
    when HTTP_REQUEST {
      if { $matched_ip } {
        node 10.10.1.1 80
      } else { node 10.10.1.2 80 }
    }
    
  • Thank you JRham!!.  That was it.  I appreciate your help.