Forum Discussion
Jeremy_Lanzarot
Nimbostratus
Sep 24, 2008Irule to log client source IP
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.
- hoolio
Cirrostratus
You shouldn't need to test the IP address, you can just log it:rule log_client_address { log local0. "Client IP: " + client_addr }
- Jeremy_Lanzarot
Nimbostratus
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... - hoolio
Cirrostratus
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. - Jeremy_Lanzarot
Nimbostratus
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? - hoolio
Cirrostratus
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 }
- Claret_Carvalho
Nimbostratus
I can confirm this also works. Is there also a way to log the virtual ip being accessed in this release - Jeremy_Lanzarot
Nimbostratus
Hi, I tried to paste this into my 4.2 PTF 10 box: - hoolio
Cirrostratus
nhoh0ft, I don't have a 4.x unit to test on. claretian, you should be able to log server_addr to get the VIP address:rule log_client_address { log local0. "Client IP: " + client_addr + ", Server IP: " + server_addr use pool corp_ldap_3895 }
- Claret_Carvalho
Nimbostratus
Hi, - Claret_Carvalho
Nimbostratus
Hi,
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects