Forum Discussion

Bruce_Morris's avatar
Bruce_Morris
Icon for Nimbostratus rankNimbostratus
Jul 01, 2019

iRule for IP Forward Virtual Server (same IP as real server) to listen on multiple ports and forward on to Real Server IP

Hi,

I have written an iRule for a Virtual Server (IP Forward - 10.1.1.1) to listen on multiple ports (range) and forward to real server with same IP address:

 

when CLIENT_ACCEPTED {

  if {([TCP::local_port] >= 23001)

  && ([TCP::local_port] <= 23005) } {

   node 10.1.1.1

  } else reject}

 

Can someone tell me if my syntax is correct?

 

Thanks,

Bruce

 

3 Replies

  • You have a missing close parenthesis after 'else'. You will also need to make sure you VIP listens on all ports too. Other than that your iRule looks ok

    when CLIENT_ACCEPTED {
        if {([TCP::local_port] >= 23001) && ([TCP::local_port] <= 23005)} {
            node 10.1.1.1
        } else {
            reject
        }
    }
    • Bruce_Morris's avatar
      Bruce_Morris
      Icon for Nimbostratus rankNimbostratus

      Hi Lee, thanks for the reply. I have the Virtual Server configured as suggested, but it is still rejecting valid connections, any thoughts?

       

      Thanks,

      Bruce

      • Lee_Sutcliffe's avatar
        Lee_Sutcliffe
        Icon for Nacreous rankNacreous

        Try adding some logging, you'll find the log entries in /var/log/ltm:

        when CLIENT_ACCEPTED {
            log local0. "recevied request from [TCP::local_port]"
            if {([TCP::local_port] >= 23001) && ([TCP::local_port] <= 23005)} {
                log local0. "forwarding to node"
                node 10.1.1.1
            } else {
                log local0. "rejecting request from [TCP::local_port]"
                reject
            }
        }