F5 Sites
  • F5.com
  • LearnF5
  • NGINX
  • MyF5
  • Partner Central
Contact
  • Under Attack?
  • F5 Support
  • DevCentral Support
  • F5 Sales
  • NGINX Sales
  • F5 Professional Services
Brand LogoSkip to content
Forums
CrowdSRC
Articles
Groups
EventsSuggestionsHow Do I...?
RegisterSign In
  1. DevCentral
  2. CrowdSRC
  3. CodeShare

Apache Style Logging with HSL

Problem this snippet solves: When SNATing to servers, the client IP is lost. This was information our security group and developers wanted to have available, so I created an iRule to use the HSL func...
Published Jan 30, 2015
Version 1.0
apache
application delivery
devops
hsl
iRules
logging
Matt_Hyclak_376's avatar
Matt_Hyclak_376
Icon for Fog rankFog
Joined September 10, 2008
View Profile
Matt_Hyclak_376's avatar
Matt_Hyclak_376
Icon for Fog rankFog
Joined September 10, 2008
View Profile
hypercoyote_208's avatar
hypercoyote_208
Icon for Nimbostratus rankNimbostratus
Sep 01, 2015
After some messing around, I was able to produce the following that would grab the client's actual IP, their SNAT IP, the actual pool member IP, it's associated virtual server and the time of the initial connection. It will only log one entry when the connection to the server is torn down as opposed to multiple entries for every HTTP element that's accessed. The only concern I have with this setup is whether or not it will catch DDoS attempts. I'm not sure if the fact that it logs on SERVER_CLOSED means that it won't log when the server has too many open connections. when CLIENT_ACCEPTED { set now [clock format [clock seconds] -format "%Y/%b/%d:%H:%M:%S %z"] } when SERVER_CONNECTED { set view_clientip [IP::client_addr] set view_clientsnat [IP::local_addr] set view_serverip [IP::remote_addr] set view_servervip [clientside {IP::local_addr}] } when SERVER_CLOSED { set hsl [HSL::open -proto UDP -pool hsl_logging_servers] HSL::send $hsl "<190>snat_log: clientIP:$view_clientip {snat:$view_clientsnat} serverIP:$view_serverip {vip:$view_servervip} connected:$now\n" } The log entry looks like this: 2015-09-01 09:46:22Local7.Info10.10.0.3snat_log: clientIP:192.168.1.10 {snat:172.16.31.100} serverIP:192.168.100.10 {vip:172.31.10.50} connected:2015/Sep/01:09:45:50 -0500 edit: the comment formatting makes this look terrible.

ABOUT DEVCENTRAL

DevCentral NewsTechnical ForumTechnical ArticlesTechnical CrowdSRCCommunity GuidelinesDevCentral EULAGet a Developer Lab LicenseBecome a DevCentral MVP

RESOURCES

Product DocumentationWhite PapersGlossaryCustomer StoriesWebinarsFree Online CoursesF5 CertificationLearnF5 Training

SUPPORT

Manage SubscriptionsProfessional ServicesProfessional ServicesCreate a Service RequestSoftware DownloadsSupport Portal

PARTNERS

Find a Reseller PartnerTechnology AlliancesBecome an F5 PartnerLogin to Partner Central

F5 logo©2024 F5, Inc. All rights reserved.
TrademarksPoliciesPrivacyCalifornia PrivacyDo Not Sell My Personal Information