Forum Discussion

yuanqiang_22112's avatar
yuanqiang_22112
Icon for Nimbostratus rankNimbostratus
Jul 13, 2016

Irules for tcp option

 

scenario: F5 to load balance for mysql database,f5 set the automap function,The user needs to see the client's real IP ; solove : I create the irules to insert client true ip ,but when I associated the irules ,Client can't connect mysql through F5 V_IP; If not associated the irules ,client can connect mysql through F5 V_IP;Below is my irulse ,please help me what's the problem of the irulse .

 

when CLIENT_ACCEPTED { set INPUT_OPTION [TCP::option get 28] binary scan $INPUT_OPTION c ver set ver [expr { $ver & 0xff }] set forwarded_ip [IP::addr parse $INPUT_OPTION 1] log local0. "The IP address was $forwarded_ip for version $ver" }

 

6 Replies

  • could you post /var/log/ltm output to see if any error occured ?

     

    for TCP::option to work you need to touch the tcp profile as well, have you done that ?

     

  • Hamish's avatar
    Hamish
    Icon for Cirrocumulus rankCirrocumulus

    Hi.

     

    Looks to me like you're using the wrong example code. If I read your description correctly, you want to INSERT the client IP into the connection so the backend (mysql) can read it? However you're using the example iRule that GETS the option28 information and displays it on the client-side of the connection.

     

    The code to SET the option is documented as

     

    when SERVER_CONNECTED {
      scan [IP::client_addr] {%d.%d.%d.%d} a b c d
      TCP::option set 29 [binary format cccc $a $b $c $d] all
    }

    You still have to get mysql to read and process that inserted option information of course.

     

  • @hamish,@ Arnaud Lemaire--please look these images ,with your irules ,Still appeared the problem;please help me take a look ,thanks !

     

  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus

    I hope this one will be of help to you:

     

    https://devcentral.f5.com/questions/a-binary-irule-question-help

     

    .

     

  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus

    And this one: https://devcentral.f5.com/wiki/iRules.TCP__option.ashx .