Wangzixuan_3147
May 21, 2018Nimbostratus
irule read from TCP option
irule-1 works well
when LB_SELECTED {
set src_cli_addr [IP::client_addr]
snatpool SNAT_10.128.10.88
}
when SERVER_CONNECTED {
scan $src_cli_addr {%d.%d.%d.%d} e b c d
TCP::option set 28 [binary format cccc $e $b $c $d] all
set tcp_option_content [binary format cccc $e $b $c $d]
log local0. "insert tcp option is $tcp_option_content"
binary scan $tcp_option_content H* cli_addr_H
log local0. "source_ip is $cli_addr_H"
}
irule-2 can not read the date from tcp option 28
when CLIENT_ACCEPTED {
TCP::collect
}
when CLIENT_DATA {
set option_cli_addr [TCP::option get 28]
log local0. "option_cli_addr is: $option_cli_addr"
binary scan $option_cli_addr H* addr
scan $addr "%2x%2x%2x%2x" ip1 ip2 ip3 ip4
log local0. "$ip1-$ip2-$ip3-$ip4"
set src_cli_addr "$ip1.$ip2.$ip3.$ip4"
log local0. "cli-addr is $src_cli_addr"
snatpool SNAT_10.128.10.88
TCP::release
}