I am trying to log the source IP address of every request that hits a VIP on a 4.2 BigIP to a file, /var/log/ldap_clients.log on the Bigip. Right now there is no irule on the VIP, it is just using a pool.
rule log_client_address {
if ( client_addr != 0.0.0.0 ) {
use pool corp_ldap_3895
log (dont know how from here)
}
else {
use pool corp_ldap_3895
}
}
Any help with syntax and logic is greatly appreciated.
You can modify the facility in the log statement to something other than local0. and/or syslog configuration to change where the log output is written.
Thank you very much for your reply. Are you saying that I do not have to the use pool commands in there, I just need the log statement? I thought I had to include the use pool commands since you can only either assign an irule or a pool…
The GUI’s wizard might limit what you can specify in an iRule in 4.x, but you don’t need to use a pool command in a free-text iRule. If you only want to log the client IP address, the rule I listed should work fine.
If I do not specifiy a pool in the irule won’t the functionality of the VIP be compromised? In 4.x you can either assign a pool for all traffic to use or use an irule. If I set the irule and do not specify a pool to use what will happen to the requests going to that VIP?
Sorry for the bad advice. I didn’t remember that you could only specify an iRule or a pool, but not both in 4.x (it’s been too long…). How about this then:
rule log_client_address {
log local0. "Client IP: " + client_addr
use pool corp_ldap_3895
}
Actually, this was on a v4.5.13 instance but two things
1) Can you do this from the CLI rather than GUI? Vi this part into a text file and then merge the config ( b merge). For some reason, the GUI would not take it but the CLI did.
2) Even from the CLI, you need to specify, severity level
log local0.info “Client IP:” + client_addr
to get it to work.
If this still doesnt work, then its down to a version difference. Let me know if that helps.