For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

superd_88943's avatar
superd_88943
Icon for Nimbostratus rankNimbostratus
Jul 16, 2014

iRule for FTP traffic

Hi all..

 

Im looking to create the following iRule:

 

scans for traffic on port 21 (FTP) from source = proxy servers (10.1.1.1 & 10.1.1.2)

 

and destination: 212.10.10.10 and 212.11.11.11

 

Load balance to 1.1.1.1

 

else LB to default pool

 

Can someone give me an idea of what this iRule might look like?

 

Much appreciated.. :)

 

6 Replies

  • Give this a shot:

    when CLIENT_ACCEPTED {
     if { ( ( [IP::addr [IP::client_addr] equals 10.1.1.1] ) or ( [IP::addr [IP::client_addr] equals 10.1.1.2] ) ) and ( ( [IP::addr [IP::local_addr] equals 212.10.10.10] ) or ( [IP::addr [IP::local_addr] equals 212.11.11.11] ) ) } {
        pool proxy_pool
     } else {
        pool default_pool
     }
    }
    
  • Thanks a million kevin.. how would this look if i wanted to tie it down to TCP port 21 only?

     

    :)

     

  • Given the nature of FTP, i am using passive i.e. client makes both connections, could it potentially become a problem, if listening on port 21 only?

     

  • Iv tried implementing the the following iRule but getting some parse errors. Any idea on where the syntax is wrong?

    when CLIENT_ACCEPTED {
    if { [[IP::client_addr] equals "10.10.10.10"]] and  [[TCP::remote_port] equals "21"] } {
    node 10.9.9.9
        log local0. "FTP connection"
    }
    else {
        pool side-http
    }
    }
    

    Another iRule im testing is for all FTP traffic, but for some reason i dont see it triggering

    when CLIENT_ACCEPTED {
    if {[TCP::remote_port] != 21} {
    
    node 10.9.9.9
    log local0. "FTP connection"
    }
    else {
    pool side-http
    }
    }
    

    Any feedback on either much appreciated!

  • Just a thought, but your FTP VIP should have:

     

    1. An FTP profile defined - this I believe helps with the ephemeral port management, and

       

    2. Port 21 defined as the destination VIP

       

    You shouldn't have to filter on the destination port in the iRule if it's defined in the VIP itself, and you'll find this much more challenging to do manually given the dual-port nature of the protocol.